用java选择selenium下拉选择框的一个选项
2015-08-31 17:04
627 查看
用selenium 选择select下的option
可以用
但是注意不要在上面的语句前加driver.findElement(By.id("User_user_type")).click();
不然就会只展开下拉列表,鼠标在Advertise上,但是并不会选中。一直处于这个状态
还有一些其他方法,可参考下面的链接
http://sqa.stackexchange.com/questions/12029/how-do-i-work-with-dropdowns-in-selenium-webdriver
<select selected="selected" class="ordername" style="width:120px" name="User[user_type]" id="User_user_type"> <option value="0">Please Choose</option> <option value="1" selected="selected">one</option> <option value="2">Advertiser</option> <option value="4">Agent</option> </select>
可以用
Select userSelect=new Select(driver.findElement(By.id("User_user_type"))); userSelect.selectByVisibleText("Advertiser");或者
WebElement adrOption=driver.findElement(By.cssSelector("#User_user_type option[value='2']")); adrOption.click();
但是注意不要在上面的语句前加driver.findElement(By.id("User_user_type")).click();
不然就会只展开下拉列表,鼠标在Advertise上,但是并不会选中。一直处于这个状态
还有一些其他方法,可参考下面的链接
http://sqa.stackexchange.com/questions/12029/how-do-i-work-with-dropdowns-in-selenium-webdriver
相关文章推荐
- spring mvc + MyBatis + Easyui
- SpringMVC中使用Interceptor拦截器
- spring整合webservice
- java 获取路径
- java中回调机制
- java 完全解耦[编程思想之9.4]
- Java并发编程(一) 基础知识
- Java中有关Null的9件事
- eclipse+pydev 安装和配置
- 《Data Structures and Algorithm Analysis in Java》Second Edition中文版笔记
- Java- 受检的异常(checked Exception)
- java.sql.SQLException: Access denied for user 'root'
- svn设置忽视某个文件夹不提交 Eclipse VS2012
- Java处理文章内容无效的img标签
- Java设计模式之抽象工厂模式
- 环境变量
- java中方法体的作用
- java 静态内部类、局部内部类、匿名内部类
- [leetcode-127]Word Ladder(java)
- Java并发编程之闭锁CountDownLatch和栅栏(CyclicBarrier)