//打印出所有选项值
Select sel = new Select(driver1.findElement(ById.xpath(".//*[@id='GangManId']")));
List<WebElement> options = sel.getOptions();
for (WebElement option : options) {
System.out.println(option.getText()); //Prints "Option", followed by "Not Option"
}
//使用name值选中
WebElement mySelectElm = driver1.findElement(By.id("GangManId"));
Select mySelect= new Select(mySelectElm);
mySelect.selectByVisibleText("于庆洋");
//使用value值选中
WebElement mySelectElm = driver1.findElement(By.id("GangManId"));
Select mySelect= new Select(mySelectElm);
mySelect.selectByValue("10");
最后
以上就是迷路篮球最近收集整理的关于基于java,selenium选择下拉框的某一个选项的全部内容,更多相关基于java,selenium选择下拉框内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复