Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 循环下拉式webdriver_Java_Selenium_Selenium Webdriver - Fatal编程技术网

Java 循环下拉式webdriver

Java 循环下拉式webdriver,java,selenium,selenium-webdriver,Java,Selenium,Selenium Webdriver,我如何在下拉列表中循环浏览9个选项。。。比如说,它有9个不同的值,我如何使用select使它通过所有这些值 例如,值为 红色 蓝色 绿色 紫色的 到目前为止我有 for (int i=0; i<4; i++){ WebElement ClubDropDown = driver.findElement(By.id("tenantList")); Select CDropdown = new Select(ClubDropDown); // This is

我如何在下拉列表中循环浏览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中(inti=0;i的

Select cDropdown = new Select(ClubDropDown);
cDropdown.getOptions().forEach(el -> {
                //do something
});
注意:在Java8中,从小写字母
ClubDropDown->ClubDropDown

开始变量名

Select cDropdown = new Select(ClubDropDown);
cDropdown.getOptions().forEach(el -> {
                //do something
});

<小写字母>代码> CopbDROPUTRO-> CUBBRODROPUT/<代码>

您能考虑共享相关HTML DOM吗?请提一下您的手动测试步骤,以便我们更好地指导您。谢谢您考虑共享相关HTML DOM?请提一下您的手动测试步骤,以便我们更好地指导您。谢谢!s