在 Selenium 4 及以上版本 wait.until throws java: method until in class org.openqa.selenium.support.ui.FluentWait<T> cannot be applyed

In Selenium 4 and above versions wait.until throws java: method until in class org.openqa.selenium.support.ui.FluentWait<T> cannot be applied

我用过

WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(60));
wait.until(ExpectedConditions.visibilityOf(driver.findElement(By.linkText("Home"))));

但在 wait.until 行中,当 运行 代码时,它会抛出以下错误。

java: method until in class org.openqa.selenium.support.ui.FluentWait cannot be applied to given types; required: java.util.function.Function<? super org.openqa.selenium.WebDriver,V> found:
org.openqa.selenium.support.ui.ExpectedCondition<org.openqa.selenium.WebElement> reason: cannot infer type-variable(s) V (argument mismatch; org.openqa.selenium.support.ui.ExpectedCondition<org.openqa.selenium.WebElement> cannot be converted to java.util.function.Function<? super org.openqa.selenium.WebDriver,V>)

我尝试了中的所有解决方案,但无济于事。谢谢。

就我而言,当我按如下方式更新 selenium-firefox-driver 时,问题就解决了。 早些时候,我有 3.141.59.

<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-firefox-driver</artifactId>
    <version>4.1.4</version>
</dependency>