Using XPath to identify Web objects from Selenium WebDriver
来源:互联网 发布:淘宝晒单福利图 编辑:程序博客网 时间:2024/04/28 07:02
Using XPath to identify Web objects from Selenium WebDriver
XPath can be used by following methods,
driver.FindElement(By.XPath("//Tag[@name='name']"))
In the below example, to find a web object of <input> tag category withname as deposit, XPath can be formed as XPath("//Input[@name='deposit']") andC# statement for the same can be formed as
driver.FindElement(By.XPath("//Input[@name='deposit']"))
Screen reference
HTML reference
<tr>
<td width="30%" nowrap="" align="left">
<input type="text class=" onkeyup="javascript:doCheckTBox(this,2,2)" size="8" value="2000000" name="deposit" flat"="" style="text-align: right;">
</td>
</tr>
2. To find a web object by class attribute
driver.FindElement(By.XPath("//Tag[@class='class-name']"))
In the below example, to find a web object of <td> tag category withclass as navtab_selected, XPath can be formed as XPath("//td[@class='navtab_selected']") andC# statement for the same can be formed as
driver.FindElement(By.XPath("//td[@class='navtab_selected']"))
Screen reference
HTML reference
<td align="center" class="navtab_selected">
<a href="/">Home</a>
</td>
4. To find a web object by using the contained text
3. To find a web object by multiple attributes
driver.FindElement(By.XPath("//Tag[@type='type-name' and @name='name']"))
In the below example, to find a web object of <input> tag category withtype as button and name as btnGo, XPath can be formed as XPath("//input[@type='button' and @name='btnGo']") andC# statement for the same can be formed as
driver.FindElement(By.XPath("//input[@type='button' and @name='btnGo']"))
Screen reference
HTML reference
<input type="button" onclick="javascript: doSubmitCompareRateProduct()" value="Go" class="flat" name="btnGo">4. To find a web object by using the contained text
I have a well formed XHTML page. I want to find the web object with URL, for which I have the text that is linked.
Example
<a href="http://TestURL.com">Text of the URL</a>
The XPath expression to find the URL link with text as Text of the URL is
//a[text()='Text of the URL']
0 0
- Using XPath to identify Web objects from Selenium WebDriver
- Using NUnit to Execute Selenium WebDriver Tests
- webdriver selenium xpath
- Selenium Webdriver Xpath
- Using Selenium 2 ( WebDriver ) to run qUnit test page
- Migrating Unit Tests from Selenium to Watir Webdriver
- How to Locate Web Elements with Selenium WebDriver?
- 使用 from selenium import webdriver
- selenium webdriver xpath 定位页面元素
- selenium webdriver by xpath 定位元素
- How to Handle Javascript Alert, Prompt, Confirmation dialog using selenium webdriver?
- MIT deep-learning system autonomously learns to identify objects
- Using a palette from .NET to display properties of multiple AutoCAD objects
- Returning Objects from Web Services
- Selenium Webdriver下click失效问题解决, xpath 多重
- 在Selenium Webdriver中使用XPath Contains、Sibling函数定位
- using JMX to Manage Web Applications (from tts)
- How to run Selenium webdriver on IE
- Win7上Git图形界面安装及配置过程
- android 图片Bitmap的旋转
- xpath提取xml文档数据
- hdoj 1429 胜利大逃亡(续) (BFS+位压缩判重)
- 使用crontab自动执行php文件
- Using XPath to identify Web objects from Selenium WebDriver
- 笔记16--控件遇到的问题汇总
- z-index在ie7下不起作用
- [随笔]VS的相对路径
- 卡方检验(Chi square statistic)
- Cassandra源码学习:数据模型
- 我和我的输入提示--需要的树结构
- JAVA学习脚印6: java方法调用机制
- 黑马程序员_对象,构造函数以及构造代码块