selenium: [🐛 Bug]: wait.until is not usable

What happened?

My “wait.until” function worked fine yesterday, but all a sudden now is not runnable.

Error message: reason: no instance(s) of type variable(s) V exist so that ExpectedCondition<WebElement> conforms to Function<? super WebDriver, V>

I have looked it up online, and people said it is related to the inconsistent versions of Guava and Selenium. However, I have already checked my project structure, and there are no other extra versions of Guava and Selenium.

How can we reproduce the issue?

I am not sure how to reproduce since I don’t know what’s wrong. The only thing I can provide is what I am using. Sorry and thanks.

Please see my pom.xml below:

   <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>4.1.3</version>
        </dependency>

  <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>31.1-jre</version>
     </dependency>

The code I have run:

public void visibilityOfElementLocatedByXpath(String xpath){
        WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));
        wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(xpath)));
    }

In addition, I am using JAVA 17, maven project with IntelliJ IDEA with MacBook Air (M1,2020).

java: method until in class org.openqa.selenium.support.ui.FluentWait<T> 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>)

Operating System

MacBook Air (M1,2020) - macOS Monterey 12.2.1

Selenium version

4.1.3

What are the browser(s) and version(s) where you see this issue?

Not-related

What are the browser driver(s) and version(s) where you see this issue?

Not-related

Are you using Selenium Grid?

No

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 22 (18 by maintainers)

Commits related to this issue

Most upvoted comments

Reading the comments in ExpectedCondition, I see:

// NB: this originally extended Guava's Function interface since Java didn't have one. To avoid code
// such as "com.google.common.base.Function condition = ExpectedConditions.elementFound(By);"
// breaking at compile time, we continue to extend Guava's Function interface.

I wonder how much users’ code we would break if we switch to the Java Function one.