因此,我尝试使用以下代码从类型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"
您可以使用哪种方法从该类型的列表中选择一个选项?
答案 0 :(得分:0)
因此,由于您的列表不是标准选择,因此Selenium Select失败。相反,您应该能够执行以下操作。
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
改编自Selenium tests are not able to interact with any of the elements的Python答案