要先选中这个弹出层的form元素,再找下拉框

public void downSelectBox(){
driver.get("https://www.imooc.com/user/setprofile");
driver.findElement(By.className("pull-right")).click();
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//先获取弹出层的form表单
WebElement formElement = driver.findElement(By.id("profile")); WebElement job = formElement.findElement(By.id("job"));
Select downList = new Select(job);
downList.selectByIndex(2);
//downList.selectByValue("1");
//downList.selectByVisibleText("学生");
downList.selectByIndex(3);
//这个只能取消多选下拉框
//downList.deselectByIndex(3);
List<WebElement> list = downList.getAllSelectedOptions();
for(WebElement option : list){
System.out.println(option.getText());
}
System.out.println(downList.getFirstSelectedOption().getText());
}

selenium选错弹出层的下拉框的更多相关文章

  1. ios11,弹出层内的input框光标错位 键盘弹出时,输入信息,光标一直乱跳

      之前开发了一个微信项目,维护期中苹果手机突然出现光标错位现象,经过排查,发现是最新的ios11系统的锅. 具体情况:弹出层使用position: fixed:弹出层内附带input/textare ...

  2. Selenium系列(十) - 针对Select下拉框的操作和源码解读

    如果你还想从头学起Selenium,可以看看这个系列的文章哦! https://www.cnblogs.com/poloyy/category/1680176.html 其次,如果你不懂前端基础知识, ...

  3. 前端组件:支持多选,支持选项筛选的下拉框选择器(基于Jquery和Bootstrap)

    效果图一:多选 效果图二:选项筛选 最后奉献源码,复制出来直接可用 <!DOCTYPE html> <html> <head> <meta charset=& ...

  4. checkbox勾选事件,JQ设置css,下拉框JQ选中

    <input id="CheckMainCompany" type="checkbox"/> $(function() { $("#Che ...

  5. 自定义样式的select下拉框深入探索

    第一个版本: 首先实现自定义select下拉框应该具有的功能,我是选择将原来的select隐藏掉,自己在jquery代码中动态写进去<dl><dd><dt>这样的结 ...

  6. 用jQuery解决弹出层的问题

    在BS 项目中 经常需要用到这种弹出层.做这种弹出层一般都会遇到下面几个问题:0,弹出层必须定义在input的下边显示.1,点击input弹出div层.2,点击div层外面任何地方,关闭div层.3, ...

  7. OA项目之弹出层中再弹出层

    弹出层中再弹出一层如图: <asp:TextBox runat="server" ID="txtUName" CssClass="span2&q ...

  8. Selenium常用操作汇总二——如何操作select下拉框

    下面我们来看一下selenium webdriver是如何来处理select下拉框的,以http://passport.51.com/reg2.5p这个页面为例.这个页面中有4个下拉框,下面演示4种选 ...

  9. selenium 显示等待wait.until 常用封装 及下拉框的选择操作等

    from selenium.webdriver.common.by import Byfrom selenium.webdriver.support.ui import WebDriverWait a ...

随机推荐

  1. Beetl学习总结(3)——高级功能

    3.1. 配置GroupTemplate Beetl建议通过配置文件配置配置GroupTemplate,主要考虑到未来可能IDE插件会支持Beetl模板,模板的属性,和函数等如果能通过配置文件获取,将 ...

  2. mybatis源码阅读-执行器Executor(四)

    说明 前面二看到了 sqlSession最终是找到MapperStatement然后委托给Executer执行的 Executer到底做了什么 接口定义 public interface Execut ...

  3. 清北学堂模拟赛d5t4 套路

    分析:题目非常短,看起来非常难,其实把图一画就明白了.有向图,每个点的出度都是1,那么整个图肯定是环上套链,链上的边无论怎样反向都不会形成环,环上的边也可以随便反向,但是最终不能反为同向的,总方案数减 ...

  4. CodeForces - 205B - Little Elephant and Sorting

    先上题目: Little Elephant and Sorting time limit per test 1 second memory limit per test 256 megabytes i ...

  5. 记一个简单的webpack.config.js

    module.exports = { entry: './basic/app.js', output: { path: './assets/', filename: '[name].bundle.js ...

  6. 微信的token验证

    微信的token验证 在微信公众平台的基本配置中,需要输入token,这个token不是那个access_token springmvc验证代码: @RequestMapping(value=&quo ...

  7. footer在最低显示

    footer在最低显示 http://stackoverflow.com/questions/585945/how-to-align-content-of-a-div-to-the-bottom

  8. Shredding Company (hdu 1539 dfs)

    Shredding Company Time Limit: 5000/2000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others ...

  9. iOS - 社会化分享-微信分享,朋友圈分享

    我仅仅做了文字和图片分享功能 1. TARGETS - Info - URL Types identifier -> weixin URL Schemes ->  应用id 2.在AppD ...

  10. Nginx1.6 for centos6.5安装

    Nginx 学习文档:http://www.cnblogs.com/zhoulf/archive/2013/02/09/2909653.html 下载地址:http://nginx.org/en/do ...