概述
//打印出所有选项值
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选择下拉框的某一个选项所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复