Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/308.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

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 如何从下拉列表中仅捕获未选择的值_Java_Selenium_Selenium Webdriver - Fatal编程技术网

Java 如何从下拉列表中仅捕获未选择的值

Java 如何从下拉列表中仅捕获未选择的值,java,selenium,selenium-webdriver,Java,Selenium,Selenium Webdriver,我想从下拉列表中捕获未选择的值。 请帮助我Select sel=new Select(driver.findElement(By.id(“”)); Select sel = new Select(driver.findElement(By.id(""))); List<WebElement> alloption = sel.getOptions(); for (WebElement webElement : alloption) { boolean checkele=webE

我想从下拉列表中捕获未选择的值。 请帮助我

Select sel=new Select(driver.findElement(By.id(“”));
Select sel = new Select(driver.findElement(By.id("")));
List<WebElement> alloption = sel.getOptions();
for (WebElement webElement : alloption) {
    boolean checkele=webElement.isSelected();
    if(checkele==false) {
        System.out.println("non-selected elements : "+webElement.getText());
    }
}
List alloption=sel.getOptions(); for(WebElement WebElement:alloption){ 布尔checkele=webElement.isSelected(); if(checkele==false){ System.out.println(“未选择的元素:+webElement.getText()); } }
请分享您的代码试用版。我不知道怎么做。这就是为什么我要求分享你的html代码的下拉列表。