Selenium webdriver 从WebDriver下拉列表中选择一个项目

Selenium webdriver 从WebDriver下拉列表中选择一个项目,selenium-webdriver,Selenium Webdriver,您需要在下拉列表中选择特定项目。在这个阶段,困难在于列表在单击时没有响应 WebDriver,Selenium 3.141.59,谷歌浏览器 网站 在操作系统项中,我需要选择“Free….”driver.switchTo().frame(0) 如果出现下拉列表,上述代码必须正常运行 driver.switchTo().frame("myFrame"); WebElement operatingSystem = new WebDriverWait(driver, 10) .until(Expec

您需要在下拉列表中选择特定项目。在这个阶段,困难在于列表在单击时没有响应

WebDriver,Selenium 3.141.59,谷歌浏览器

网站 在操作系统项中,我需要选择“Free….”driver.switchTo().frame(0)

如果出现下拉列表,上述代码必须正常运行

driver.switchTo().frame("myFrame");

WebElement operatingSystem = new WebDriverWait(driver, 10)
.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//md-select-value/span/div[contains(text(),'Free')]/../../..")));
operatingSystem.click();
WebElement checkFree = new WebDriverWait(driver, 10)
.until(ExpectedConditions.elementToBeClickable(By.xpath("//md-option/div[contains(text(),'Free')]/..")));
checkFree.click();
Select fruits = new Select(driver.findElement(By.id("subjects")));
    fruits.selectByVisibleText("maths");
    fruits.selectByIndex(1);