首页 > 解决方案 > 无法使用直到 WebDriverWait 的方法

问题描述

我收到以下错误:

The method until(Function<? super WebDriver,V>) in the type FluentWait<WebDriver> is not applicable for the arguments (ExpectedCondition<Boolean>)

我的代码是这样的:

try {
            WebDriverWait wait = new WebDriverWait(getDriver(), 60);
            wait.until(
                    ExpectedConditions.invisibilityOfElementLocated(By.cssSelector("div[class='ui-block']")));
        } catch (Exception e) {
            e.printStackTrace();
        }

我的 pom.xml 依赖项如下所示:

       <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>3.141.59</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-server</artifactId>
            <version>3.141.59</version>
        </dependency>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-chrome-driver</artifactId>
            <version>3.141.59</version>
        </dependency>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-firefox-driver</artifactId>
            <version>3.141.59</version>
        </dependency>

        <dependency>
            <groupId>com.google.inject</groupId>
            <artifactId>guice</artifactId>
            <version>4.2.2</version>
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.48</version>
            <scope>compile</scope>
        </dependency>

        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>7.0.0</version>
        </dependency>

我试图寻找这个错误并知道它是由于番石榴依赖性问题,我把它做成了最新的 25-jre 和 21。但没有帮助。有人可以提出解决方案吗?

标签: seleniumselenium-webdriverwebdriverwait

解决方案


这是兼容性问题。要解决它,您可以使用 Guava 版本 21 + selenium 版本 3.2.0 + JDK 8。

有关更多详细信息,您可以查看以下链接:

https://softwaretestingboard.com/q2a/1907/function-webdriver-fluentwait-webdriver-applicable-arguments#axzz68BFzmEjv

我希望它会帮助你。


推荐阅读