I\'ve been struggling with selenium to fix this issue:
java.lang.NoSuchMethodError: org.openqa.selenium.support.ui.Wait.until(Lcom/google/common/base/Function
This error message...
java.lang.NoSuchMethodError: org.openqa.selenium.support.ui.Wait.until(Lcom/google/common/base/Function;)Ljava/lang/Object;
...implies that the Guava version was incompatible.
As you are using selenium-server-standalone-3.12.0 as per the contents of selenium-java-3.12.0 client kits the supported guava version is:
guava-23.6-jre
An immediate solution would be to:
guava-23.6-jre.jar
In your first update as you have confirmed that Guava version is 23.6-jre
, the real issue seems to be constructor of FluentWait. The argument type for withTimeout
and pollingEvery
post Selenium v3.11.0, which was:
pollingEvery(long duration, java.util.concurrent.TimeUnit unit)
withTimeout(long duration, java.util.concurrent.TimeUnit unit)
Are now Deprecated and the new type is java.time.Duration. So your effective code block will be:
Wait wait = new FluentWait(driver)
.withTimeout(Duration.ofSeconds(30))
.pollingEvery(Duration.ofMillis(500))
.ignoring(NoSuchElementException.class);
You can find a detailed discussion in The type FluentWait is not generic; it cannot be parameterized with arguments error for FluentWait Class through Selenium and Java
Additionally,
As per the best practices you need to:
Test
as a non-root user.driver.quit()
within tearDown(){}
method to close & destroy the WebDriver and Web Client instances gracefully.You can find a relevant detailed discussion in: