我如何循环浏览下拉列表中的 9 个选择...比如说它有 9 个不同的值,我如何使用 select 让它遍历所有这些值?
例如。值为 红色的 蓝色的 绿色的 紫色
到目前为止我已经
for (int i=0; i<4; i++){
WebElement ClubDropDown = driver.findElement(By.id("tenantList"));
Select CDropdown = new Select(ClubDropDown);
// This is the part I'm stuck on how to make it loop through the drop downs and preform the defined public void cases
OpenMp(); // This is one of my public void test cases
}
最佳答案
在Java8中
Select cDropdown = new Select(ClubDropDown);
cDropdown.getOptions().forEach(el -> {
//do something
});
附注变量名从小写字母开始 ClubDropDown ->clubDropDown
关于java - 循环下拉网络驱动程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44392818/