我想找到Select
WebElement
:
WebElement select = driver.findElement(By.id("gender"));
因此,如果我想将 wait 与 ExpectedConditions
一起使用,然后与我的元素 selectByVisibleText
、selectByValue
...
我应该选择什么ExpectedConditions
:presenceOfElementLocated
或elementToBeClickable
最佳答案
elementToBeClickable
应该适合 - 它等待元素可见并启用:
WebDriverWait wait = new WebDriverWait(driver, 10);
WebElement select = wait.until(ExpectedConditions.elementToBeClickable(By.id("gender")));
Select genderDropdown = new Select(select);
genderDropdown.selectByVisibleText("male");
关于java - Selenium:我应该选择什么预期条件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37030131/