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 如何从“选项”中选择选项;mdb select";列表_Java_Selenium_Selenium Webdriver_Automated Tests - Fatal编程技术网

Java 如何从“选项”中选择选项;mdb select";列表

Java 如何从“选项”中选择选项;mdb select";列表,java,selenium,selenium-webdriver,automated-tests,Java,Selenium,Selenium Webdriver,Automated Tests,因此,我尝试使用以下代码从类型为mdb select的列表中选择一个选项: Select dropdown = new Select(driver.findElement(By.id("selectEntidaBancaria"))); dropdown.selectByVisibleText("Davivienda S.A."); 但是Java显示了以下错误: org.openqa.selenium.support.ui.UnexpectedTagNameException: Elemen

因此,我尝试使用以下代码从类型为
mdb select
的列表中选择一个选项:

Select dropdown = new Select(driver.findElement(By.id("selectEntidaBancaria")));

dropdown.selectByVisibleText("Davivienda S.A.");
但是
Java
显示了以下错误:

org.openqa.selenium.support.ui.UnexpectedTagNameException: Element should have been "select" but was "mdb-select"

您可以使用什么方法从该类型的列表中选择选项?

因此,由于您的列表不是标准选择,Selenium选择失败。相反,您应该能够执行以下操作

driver.findElement(By.id("selectEntidaBancaria")).click(); //click on the list to bring up choices

wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//mdb-select[contains(.,'Davivienda S.A.')]")); //wait for dropdown to appear and be clickable

driver.findElement(By.xpath("//mdb-select[contains(.,'Davivienda S.A.')]")).click(); // and click on it

改编自Python answer at

,因此由于您的列表不是标准选择,Selenium选择失败。相反,您应该能够执行以下操作

driver.findElement(By.id("selectEntidaBancaria")).click(); //click on the list to bring up choices

wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//mdb-select[contains(.,'Davivienda S.A.')]")); //wait for dropdown to appear and be clickable

driver.findElement(By.xpath("//mdb-select[contains(.,'Davivienda S.A.')]")).click(); // and click on it

改编自Python的回答

文本或URL中共享HTML应有帮助文本或URL中共享HTML应有帮助