selenium选错弹出层的下拉框
生活随笔
收集整理的這篇文章主要介紹了
selenium选错弹出层的下拉框
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
要先選中這個彈出層的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());}?
轉載于:https://www.cnblogs.com/tarrying/p/9681561.html
總結
以上是生活随笔為你收集整理的selenium选错弹出层的下拉框的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Oracle数据库中游标的游标的使用
- 下一篇: 自动化收益评估