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应有帮助