I am having terrible time with this and I apologize in advance as I am working in Java as opposed to .NET where I am the most familiar.
I had a FluentWait in my test automation suite that was identifying a page object that was being sent as a way to wait for a page to load. A couple of days ago it all of a sudden started returning a NoSuchMethod error. This had happened before and I ungraded the google guava dependency in gradle. I upgraded my Selenium server to the latest version on seleniumhq (3.141.59) and I updated my guava dependency in my gradle build script to the latest version (27.0-jre). And I went to a WebDriverWait instead of the FluentWait. Nothing has worked so far
My test suite is set up with two projects, one with test scripts and project specific helper functions, and one core project that has basic functionality that is used across all projects that use the automation. This is where the wait functions are at
As an interesting side note, I also found that are several deprecated things within the FluentWait and WebDriverWait code such as the way that the polling interval and timeout are set. If I set the polling interval and timeout using Duration.of(xx) instead of (xx, TimeUnit.) I get an error in the top level project and execution is halted, but the core compiles with no problem. This is leading me to believe that there might be something else going on within my dependencies and this is also where my inexperience with Java and gradle doesn't help.
Here is the WebDriverWait code without using the Duration
public static void WaitForPageLoad(WebDriver localDriver, By by)
{
localDriver.manage().timeouts().implicitlyWait(0, TimeUnit.SECONDS);
WebDriverWait wait = new WebDriverWait(localDriver, 30);
wait.pollingEvery(500, TimeUnit.MILLISECONDS);
wait.withTimeout(30, TimeUnit.SECONDS);
wait.ignoring(NoSuchElementException.class);
Function<WebDriver, Boolean> objPes = new Function<WebDriver, Boolean>()
{
public Boolean apply(WebDriver localDriver)
{
return localDriver.findElement(by).isEnabled();
}
};
wait.until(objPes);
localDriver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
Sleep(500);
}
Here are my import statements
dependencies {
compile('com.ameritas.webcoe.testing:testing-core:1.0.62-SNAPSHOT')
compile('org.springframework.boot:spring-boot-configuration-processor')
compile('org.springframework.boot:spring-boot-starter')
compile('com.google.guava:guava:27.0-jre')
compileOnly('org.projectlombok:lombok:1.16.18')
testCompile 'commons-io:commons-io:2.6'
testCompile 'org.json:json:20170516'
testCompile 'org.apache.poi:poi:3.16'
testCompile 'org.apache.poi:poi-ooxml:3.16'
testCompile 'com.microsoft.sqlserver:mssql-jdbc:6.2.2.jre8'
testCompile 'io.rest-assured:json-path:3.0.7'
testCompile 'org.mongodb:mongo-java-driver:3.7.1'
testCompile 'net.sourceforge.jtds:jtds:1.3.1'
testCompile('org.springframework.boot:spring-boot-starter-test')
testCompile "org.seleniumhq.selenium:selenium-java:${seleniumVersion}"
testCompile "org.seleniumhq.selenium:selenium-support:${seleniumVersion}"
testCompile "org.seleniumhq.selenium:selenium-api:${seleniumVersion}"
drivers.each { driver ->
testCompile "org.seleniumhq.selenium:selenium-${driver}-driver:${seleniumVersion}"
}
}
And, finally, here is the stacktrace of the exception
java.lang.NoSuchMethodError: org.openqa.selenium.support.ui.WebDriverWait.until(Ljava/util/function/Function;)Ljava/lang/Object;
at com.ameritas.webcoe.testing.common.WaitOps.WaitForPageLoad(WaitOps.java:59)
at com.ameritas.webcoe.scripts.testing.frontend.pw.pageobjects.login.LoginPage.<init>(LoginPage.java:29)
at com.ameritas.webcoe.scripts.testing.frontend.pw.scripts.PW_Frontend_SmokeTest.accountRecoveryFlowSmokeTest(PW_Frontend_SmokeTest.java:102)
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:104)
at org.testng.internal.MethodInvocationHelper$1.runTestMethod(MethodInvocationHelper.java:205)
at org.springframework.test.context.testng.AbstractTestNGSpringContextTests.run(AbstractTestNGSpringContextTests.java:175)
at org.testng.internal.MethodInvocationHelper.invokeHookable(MethodInvocationHelper.java:217)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:641)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:851)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1177)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:129)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:112)
at org.testng.TestRunner.privateRun(TestRunner.java:756)
at org.testng.TestRunner.run(TestRunner.java:610)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:387)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:382)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:340)
at org.testng.SuiteRunner.run(SuiteRunner.java:289)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1293)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1218)
at org.testng.TestNG.runSuites(TestNG.java:1133)
at org.testng.TestNG.run(TestNG.java:1104)
at org.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:72)
at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:123)