3

I have been using these 2 function in Selenium, they were working fine. Now they dont, there is an error saying:

No instance(s) of type variable(s) V exist so that ExpectedCondition<WebElement> conforms to Function<? super WebDriver, V>

I have not updated Selenium nor anything else in the project. What could be the cause?

worth mentioning, the function they both reside is:

public static void safeClick(WebDriver driver, WebElement element, Boolean checkVisibility) {
    JavascriptExecutor executor = (JavascriptExecutor) driver;
    executor.executeScript("arguments[0].scrollIntoView(true);", element);
    executor.executeScript("arguments[0].focus();", element);

    if (checkVisibility) {
      WebDriverWait wait = new WebDriverWait(driver, 5);
      wait.until(ExpectedConditions.visibilityOf(element));
      wait.until(ExpectedConditions.elementToBeClickable(element));
    }

   executor.executeScript("arguments[0].click();", element);
  }
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
abbas
  • 235
  • 1
  • 3
  • 14

1 Answers1

3

This error message...

No instance(s) of type variable(s) V exist so that ExpectedCondition<Boolean> 
conforms to Function<? super WebDriver, V>

...implies that there is a mismatch between the Selenium client version and versions.

A bit more details about the Selenium client version and the Guava version you are using would have helped us to debug the issue in a better way.


Solution

Ensure the following combination of Selenium client version and the Guava version:

  • Selenium v3.12.0 : guava-23.6-jre
  • Selenium v3.13.0 : guava-25.0-jre
  • Selenium v3.14.0 : guava-25.0-jre
  • Selenium v3.141.0 : guava-25.0-jre
  • Selenium v3.141.5 : guava-25.0-jre
  • Selenium v3.141.59 : guava-25.0-jre

References

You can find a relevant detailed discussion in:

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • Tnx. I have downloaded guava 25 jar file but the problem still exists. I am now sure the version of the Rest Assured library II am using is not compatible with 3.13 Selenium. Do you know which version I have to use? – abbas Jun 03 '20 at 19:48
  • abbas did you get the solution for this problem? – DevX Apr 19 '21 at 16:41
  • 1
    I was having this problem with my wait.until(ExpectedConditions.elementToBeClickable(myGetElementFunction())) that was previously working but started giving the same error as OP when I cleared my .m2 folder and ran mvn install. This fixed my problem: I realized I didn't have guava installed, and I had to specifically get version 25.0-jre. Thanks! – Hien Apr 27 '21 at 15:15