OS: Windows 7
Selenium Version: 3.2.0
Browser: Chrome (problem is not related to browser)
Browser Version: 56.0.2924.87 (64-bit)
Java: jdk 1.8 (latest)
I had the following setup:
OS: Windows 7
Selenium Version: 3.0.1
Browser: Chrome (problem is not related to browser)
Browser Version: 56.0.2924.87 (64-bit)
Java: jdk 1.8 (latest)
I was using guava - 18.0 version and had a tests which were running fine.
Then I decided to upgrade the whole selenium grid environment to use 3.2.0 webdriver. I went through the changes and updated the pom.xml file to use 3.2.0 selenium-java and guava 21.0.
Then I ran the same tests and all of them failed in the following code fragment:
public void waitForElementToLoad(By locator, long timeOutInSeconds) {
new WebDriverWait(webDriver, timeOutInSeconds).until(ExpectedConditions.visibilityOfElementLocated(locator));
}
with the following reason:
java.lang.NoSuchMethodError: org.openqa.selenium.support.ui.WebDriverWait.until(Ljava/util/function/Function;)Ljava/lang/Object;
If the error above is expected please add some suggestions how to use WebDriverWait + ExpectedConditions
The tests are failing because of the changes done related to FluentWait. Same piece of code works fine with 3.0.1 and guava 18.0.
@Test
public void example() throws Throwable {
webDriver.get("https://www.google.com/");
new WebDriverWait(webDriver, 30000).until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("input[name='q']")));
}
Thank you in advance!
I was checking the change log for 3.2.0 here, and it says:
FluentWait.until(Predicate<?>) method. ThisI think this is related to your error.
@diemol Actually, this issue does not appear to be related to the deprecated FluentWait.until(Predicate<?>) method.
The issue deals with the parameter ExpectedConditions.visibilityOfElementLocated() being used in the FluentWait.until() method. ExpectedConditions.visibilityOfElementLocated() is an org.openqa.selenium.support.ui.ExpectedCondition which extends the com.google.common.base.Function class and that extends the java.util.function.Function class.
The method is looking for a java.util.function.Function parameter, so a parameter of type org.openqa.selenium.support.ui.ExpectedCondition should work. Why does it fail using guava-18.jar and then work after upgrading to guava-21.jar?
Actually, I just read the selenium/java/CHANGELOG for version 3.2.0. They upgraded to guava-21.jar
You are completely right @smathistad, the Guava upgrade is the reason. Somehow I overlooked that part.
Uhhh. So what is the resolution?
I have a Java Maven project and all I have for selenium in pom is
org.seleniumhq.selenium
selenium-java
3.3.1
All my fluentwaits are broken since the update.
WebDriverWait wait = new WebDriverWait(browser.getDriver(), JeetConfig.getBrowser().getPageLoadTimeout());
wait.until(ExpectedConditions.presenceOfElementLocated(rootElementLocator));
element = browser.getDriver().findElement(rootElementLocator);
How do I resolve this? Do I just figure out how to add guava to pom? Do I need to change wait signature? Are the docs for waits updated with new examples?
Hi all,
to @MichaelCowanPdx
If you use maven - execute 'mvn dependency:tree -Dverbose' - verbose flag display conflicting dependencies
Make search by results of dependency tree and find "guava" - if there few libs "guava" in different dependencies with conflicts - make exclude for older versions of guava in another dependencies and leave v.21.0 (included to selenium-java beginning from v3.2.0)
This problem may be related to so called Maven "nearest-wins" strategy during resolving version conflicts of transitive dependencies.
Best way - use maven "dependencyManagemenet"
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>21.0</version>
</dependency>
</dependencies>
</dependencyManagement>
In this way maven always resolve conflict with version from dependencyManagement
Yes, I am also getting the same issue with guava version as Latest, My issue get resolved when I mentioned the guava version as 21 in dependency.
I have guava 21.0 added to my pom.xml, running mvn -f pom.xml compile test, the test passed, wait.until is working fine!
However, if I run it through testng.xml, it will throw this error:
java.lang.NoSuchMethodError: org.openqa.selenium.support.ui.WebDriverWait.until(Ljava/util/function/Function;)Ljava/lang/Object;
at
at
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:696)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:882)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1189)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:124)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108)
at org.testng.TestRunner.privateRun(TestRunner.java:767)
at org.testng.TestRunner.run(TestRunner.java:617)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:348)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:343)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:305)
at org.testng.SuiteRunner.run(SuiteRunner.java:254)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
at org.testng.TestNG.run(TestNG.java:1057)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:236)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:81)
Setup:
OS: Mac
Selenium Version: 3.4.0
Browser: Chrome (problem is not related to browser)
Java: jdk 1.8 (latest)
POM.xml
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-firefox-driver</artifactId>
<version>3.4.0</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.13</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.13</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.4.0</version>
</dependency>
<!-- <dependency> <groupId>com.opera</groupId> <artifactId>operadriver</artifactId>
</dependency> -->
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.json</artifactId>
<version>1.0.4</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8.21</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.3.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson2.version}</version>
</dependency>
<dependency>
<groupId>com.jayway.restassured</groupId>
<artifactId>rest-assured</artifactId>
<version>2.9.0</version>
</dependency>
<dependency>
<groupId>com.jayway.restassured</groupId>
<artifactId>json-path</artifactId>
<version>2.9.0</version>
</dependency>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.opera</groupId>
<artifactId>operadriver</artifactId>
<version>1.5</version>
<exclusions>
<exclusion>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-remote-driver</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>21.0</version>
</dependency>
</dependencies>
</dependencyManagement>
Have the same problem. Got the same error when running via testng.xml. Also cannot run via Eclipse, got the same error as well.
My settings:
OS: Win 7
Guava 21.0
Selenium Version: 3.1.0 or later
Browser: Chrome (problem is not related to browser)
Java: jdk 1.8 (latest)
Eclipse: Kepler
Have the same problem. Got the same error when running via testng.xml. Also cannot run via Eclipse -
Neon got the same error as well.
My settings:
OS: Win 7
Guava 22.0
Selenium Version: 3.4
Browser: Chrome (problem is not related to browser)
Java: jdk 1.8 (latest)
Eclipse: Neon
I tried different configurations.
First try.
new WebDriverWait(this, MAX_TIMEOUT_SECONDS).until(ExpectedConditions.visibilityOf(webElement));
Second try from searching google.
Wait
wait.until(ExpectedConditions.visibilityOf(webElement));
Third try from searching google.
Wait
wait.until(new Function
public WebElement apply(WebDriver driver) {
return driver.findElement(By.id("table"));
}
});
They all fail.
Anyone solve this issue with testNG?
This issue happened to me when I added a new dependency to my pom file and re-arranging the new dependency to a lower order in the list seemed to have fixed the issue ..
Using guava version 21, still facing this issue. Any solution found for this? Please help.
Here is my workaround:
@ivnl , Could you please post your maven pom file. I am trying to update with guava dependency 21 version with selenium 3.9.1 but issue is still there.
Waits are working when executed with eclipse. But failed when executed with testNG.
below error occurred.
java.lang.NoSuchMethodError: org.openqa.selenium.support.ui.WebDriverWait.until(Ljava/util/function/Function;)Ljava/lang/Object;
I updated below lines in my gradle file and it resolved above NosuchErrorMethod compilation error for 'webdriverwait.until() method'
compile(group: 'com.google.guava', name: 'guava', version: '24.0-jre')
compile group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '3.9.1'
PS : Looking at release notes for guava core , it seems it has been bifurcated under two libraries (1 jre , 2 android)
Any one get this working with selenium 3.10.0 and guava 21 ?
I am also facing this issue. I dont quite understand why this issue was closed when it is clearly a common occurrence.
Can someone from the Selenium team please re-open this issue?
@mirza-ae Yes, misconfiguring classpath is a common occurrence, but it's not a bug that can be fixed in Selenium code, you should fix dependencies in your project.
I am using Selenium 3.13.0 jars and with guava 26.0-jre.jar.
We don't use maven or gradle. We have jars physically added to the eclipse build path and we refer to the jar location in the classpath to execute the automation jar in runtime as below:
java -cp
I see the following exception whenever I am trying to use WebDriverWait.until(ExpectedConditions):
java.lang.NoSuchMethodError: org.openqa.selenium.support.ui.FluentWait.until(Lcom/google/common/base/Function;)Ljava/lang/Object;
Sample Code which is hitting issue:
public static void clickSearch(WebDriver driver,By by, int timeout){
driver.manage().timeouts().implicitlyWait(0, TimeUnit.SECONDS);
WebDriverWait wait = new WebDriverWait(driver, 2);
WebElement webElement = wait.until(ExpectedConditions.elementToBeClickable(by));
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
//return webElement;
webElement.click();
}
Java JDK : 1.8.0_131-b11
I am still facing this issue.
Even I have faced the same issue adding guva and selenium-support dependencies resolved my issue.
if you are still facing the issue then update selenium standalone server to the selenium version that you are using. there is no maven dependency for selenium standalone server so you have to download the required version and add it to build path.
Note : After adding all above dependencies, delete selenium folder from .m2 folder and build it.
All the best.
As mentioned already in my previous comment, I have got latest guava 26.0-jre.jar and following selenium jars : selenium-api-3.13.0.jar, selenium-java-3.13.0.jar, selenium-remote-driver-3.13.0.jar, selenium-server-standalone-3.13.0.jar, selenium-support-3.13.0.jar, client-combined-3.13.0.jar.
Even though I have the above mentioned jars I am seeing this issue. I have many other jars in classpath too. Not sure if any of them is causing the issue.
@shankar86kd : In your list you do not have selenium support dependency added. As mentioned in my comment, add this dependency and delete selenium from .m2 folder in your location system and rebuild the project again. It should work.
@BalurQA I have selenium-support-3.13.0.jar. And I am not using maven or gradle. We are manually adding the jars in our library. Any help would be appreciated. Thanks !
@shankar86kd : i tried with little lower versions with Java project by adding below jars then it worked for me.
I have added all jars manually.

@BalurQA Yes it was working fine for me when I was on 3.4.0 version. I am trying to upgrade now to latest selenium version as the old version doesnt support latest FF and IE drivers. Hence blocked with this issue.
@shankar86kd : Try deleting/removing the selenium-java-3.13.0.jar from library path since you already have selenium-server-standalone-3.13.0.jar. I hope it will work. When I tried with 3.14 version it did work for me.

Updated the guava jar to 23.0 the issue is resolved
Getting similar issue even after trying all the combinations mentioned in the comments.
java.lang.NoSuchMethodError: org.openqa.selenium.support.ui.WebDriverWait.until(Ljava/util/function/Function;)Ljava/lang/Object;
Can someone please help out to resolve the issue?
@mirza-ae Yes, misconfiguring classpath is a common occurrence, but it's not a bug that can be fixed in Selenium code, you should fix dependencies in your project.
In this specific instance, FluentWait.until() takes a java.util.function.Function but ExpectedConditions.stalenessOf returns a com.google.common.base.Function, even though both FluentWait and ExpectedConditions are from the same selenium jar.
https://github.com/SeleniumHQ/selenium/blob/master/java/client/src/org/openqa/selenium/support/ui/FluentWait.java#L36
https://github.com/SeleniumHQ/selenium/blob/master/java/client/src/org/openqa/selenium/support/ui/ExpectedCondition.java#L20
@idontusenumbers com.google.common.base.Function extends java.util.function.Function since guava version 21, see [1]
[1] https://github.com/google/guava/wiki/Release21#commonbase
I dug a little deeper and found the latest https://github.com/docker-java/docker-java still uses guava 19.
Probably still worth replacing the references in the Selenium code base to use the standard library.
@idontusenumbers The proposed change would hurt our users that have custom conditions returning a com.google.common.base.Function
@barancev it could be done in 4.0; the fix to the user code is easy.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
Hi all,
to @MichaelCowanPdx
If you use maven - execute 'mvn dependency:tree -Dverbose' - verbose flag display conflicting dependencies
Make search by results of dependency tree and find "guava" - if there few libs "guava" in different dependencies with conflicts - make exclude for older versions of guava in another dependencies and leave v.21.0 (included to selenium-java beginning from v3.2.0)
This problem may be related to so called Maven "nearest-wins" strategy during resolving version conflicts of transitive dependencies.
Best way - use maven "dependencyManagemenet"
In this way maven always resolve conflict with version from dependencyManagement