In Selenium-java-3.0.1, I can use WebDriverWait.until for explicit waits:
new WebDriverWait(myChromeDriver, 30).until((ExpectedCondition<Boolean>) wd -> ((JavascriptExecutor) wd).executeScript("return document.readyState").equals("complete"));
Above code was running well in Selenium-java-3.0.1, until we upgraded to Selenium-java-3.2 where class WebDriverWait disappear from client-combined-3.3.0-nodeps.jar all together.
What is the corresponding method call in Selenium 3.2/3.3? Thanks in advance.
Stack trace is as below:
java.lang.NoSuchMethodError: org.openqa.selenium.support.ui.WebDriverWait.until(Lcom/google/common/base/Function;)Ljava/lang/Object;
at au.com.testpro.rft2selenium.objects.TestObject.waitForLoad(Unknown Source)
at au.com.testpro.rft2selenium.objects.TestObject.find(Unknown Source)
at au.com.testpro.rft2selenium.objects.TestObject.find(Unknown Source)
at test.ScriptSuperClass_JZ.findTestObject(ScriptSuperClass_JZ.java:65)
at test.refData_Verify.execute(refData_Verify.java:102)
at au.com.testpro.framework.java.superclasses.JavaFrameworkSuperClass.execute(Unknown Source)
at au.com.testpro.framework.java.superclasses.JavaFrameworkSuperClass.executeCsv(Unknown Source)
at test.refData_Verify.test(refData_Verify.java:486)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Quick fix if you are using the wait.until and don't want to change lots of things :
I had a global WebDriverWait wait before selenium 3.1.0 : WebDriverWait wait = new WebDriverWait(driver, 30, 5000);
I'm simply using this now in 3.3.1 (it works well for me): FluentWait wait = new FluentWait<>(driver) .withTimeout(30, SECONDS) .pollingEvery(5, SECONDS) .ignoring(NoSuchElementException.class);
Of course you need to have com.google.guava 21.0 as a dependency
This Works in selenium 3 like this
WebDriverWait wait = new WebDriverWait(driver,20)
wait.until(ExpectedConditions.visibilityofElementLocatedBy(By.xpath("xxx");
On selenium 4 this looks like
WebDriverWait wait = new WebDriverWait(driver,Duration.ofSeconds(20))
wait.until(ExpectedConditions.visibilityofElementLocatedBy(By.xpath("xxx");
Please update the version of Guava
jar that you are using to v-21
, whenever there is a change in selenium-version, it is recommended to read the release notes, before start using the version.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With