我有一个 Selenium 测试,它检查是否可以在测试页上看到某个字符串。如果页面没有立即加载,我的想法是使用显式等待。
WebElement element = driver.findElement(By.xpath("//*[text()='text']"));
之后我做了:
WebDriverWait wait = new WebDriverWait(driver, 10);
wait.until(ExpectedConditions.visibilityOf(element));
因此,在继续之前,它的等待时间最长为 10 秒。如果它在 10 秒内看到该元素,则测试继续。
但我在 wait.until 收到以下错误
until
(java.util.function.Function<? super org.openqa.selenium.WebDriver,java.lang.Object>)
in FluentWait cannot be applied
to
(org.openqa.selenium.support.ui.ExpectedCondition<org.openqa.selenium.WebElement>)
使用谷歌解决这个问题并没有帮助我。任何人都知道如何解决这个错误?
该元素包含我想要的字符串