Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cocoa/3.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
Selenium webdriver 获取下拉列表中的所有选项,并使用SeleniumWebDriver和java将其与单个选项进行比较_Selenium Webdriver - Fatal编程技术网

Selenium webdriver 获取下拉列表中的所有选项,并使用SeleniumWebDriver和java将其与单个选项进行比较

Selenium webdriver 获取下拉列表中的所有选项,并使用SeleniumWebDriver和java将其与单个选项进行比较,selenium-webdriver,Selenium Webdriver,有谁能告诉我如何获得下拉列表中的所有选项,并使用selenium web驱动程序将其与单个选项进行比较 我试用过这个代码 Select dropdown = new Select(_driver.findElement(EventListOptionList)); List<WebElement> Options = dropdown.getOptions(); for (WebElement el : Options) { if(

有谁能告诉我如何获得下拉列表中的所有选项,并使用selenium web驱动程序将其与单个选项进行比较

我试用过这个代码

Select dropdown = new Select(_driver.findElement(EventListOptionList));
        List<WebElement> Options = dropdown.getOptions();
        for (WebElement el : Options) {
          if(el.getText.equals("event1")){
             System.out.printLn("Option is present")
          }
        }
Select下拉菜单=新选择(_driver.findElement(EventListOptionList));
List Options=dropdown.getOptions();
对于(WebElement el:选项){
if(el.getText.equals(“event1”)){
System.out.printLn(“存在选项”)
}
}
但它显示了这一行的错误

List<WebElement> Options = dropdown.getOptions();
List Options=dropdown.getOptions();

错误是“删除类型参数”

您必须已导入此列表类:“java.awt.List”。因此出现了错误。

请将其删除并导入“java.util.List”。这肯定会解决您的问题。

您能提供HTML代码段吗?这是特定行的编译时错误还是运行时错误?太棒了……)如果这对您有帮助,请将其标记为答案。谢谢。:)