1.sendKeys() 在文本框中输入字符串WebElement searchBox = driver.findElement(By.name("q"));searchBox.sendKeys("webdriver");如果希望在文本框中输入某些特殊字符,如Shift,则需要使用webDriver...
分类:
其他好文 时间:
2015-05-20 18:18:26
阅读次数:
147
在写文件上传脚本的时候,遇到了很多问题,包括元素定位,以及上传操作,现在总结下来以下几点:1. 上传的控件定位要准确,必要时要进行等待WebElement adFileUpload = driver.findElement(By.xpath("//input[@type='file']"));2. ...
分类:
编程语言 时间:
2015-05-04 15:06:34
阅读次数:
193
classselenium.webdriver.remote.webelement.WebElement(parent,id_)Bases:objectRepresents a DOM element.Generally, all interesting operations that intera...
classselenium.webdriver.support.select.Select(webelement)deselect_all()Clear all selected entries. This is only valid when the SELECT supports multipl...
转自http://www.51testing.com/html/87/300987-831171.html1.动态id定位不到元素for example: //WebElement xiexin_element = driver.findElement(By.id("_mail_component_...
分类:
Web程序 时间:
2015-02-10 10:25:33
阅读次数:
198
1.通过ID查找 查找1个:WebElement el=driver.findElement(By.id("com.aurora:id/aurora_action_bar_item")); 列表: List e3=driver.findElements(By.id("com.aurora:id/.....
分类:
移动开发 时间:
2015-02-03 14:56:31
阅读次数:
218
XPath的绝对路径定位方式被测试网页的HMTL代码搜狗搜索搜狗图片百度搜索百度图片绝对路径定位方式: 在被测试网页中,查找第一个 div 标签中的按钮。XPath的表达式: /html/body/div/input[@value="查询"]Java的定位语句: WebElement button=...
分类:
其他好文 时间:
2015-01-31 12:01:25
阅读次数:
285
一般的日期控件都是input标签下弹出来的,如果使用webdriver 去设置日期,1. 定位到该input2. 使用sendKeys 方法比如:但是,有的日期控件是readonly的比如12306的这个这个时候,没法调用WebElement的sendKeys()方案一:使用JS remove re...
分类:
Web程序 时间:
2015-01-08 00:43:25
阅读次数:
341
许多测试失败是因为点击一个元素失败或者在一个不可见的字段中输入文字,或者是在不可输入的文本中输入文字。我们可以在具体操作之前,检查一下元素的状态。WebElement类提供了这样的方法。方法目的isEnabled()检查元素是否启用(只有在input元素设为disabled时,返回false)isS...
分类:
编程语言 时间:
2015-01-06 15:20:09
阅读次数:
284
1. 获取元素文本WebElement类的getText()方法返回元素的innerText属性。所以元素里如果有子节点一样也会被返回出来。如下所示 1 public class GetText { 2 @Test 3 public void testGetText(){ 4 ...
分类:
编程语言 时间:
2015-01-05 16:32:57
阅读次数:
390