SeleniumHQ / selenium

A browser automation framework and ecosystem.
https://selenium.dev
Apache License 2.0
30.72k stars 8.19k forks source link

[🐛 Bug]: Error in Selenium 4.20 (Java) - java.lang.NoSuchMethodError: 'void org.openqa.selenium.remote.service.DriverFinder.<init> #13897

Closed rsenthilr closed 6 months ago

rsenthilr commented 6 months ago

What happened?

When I have upgraded Selenium Webdriver to 4.20.0 and test scripts failing with below error java.lang.NoSuchMethodError: 'void org.openqa.selenium.remote.service.DriverFinder.(org.openqa.selenium.remote.service.DriverService, org.openqa.selenium.Capabilities)' JDK version is 17 Windows 10

How can we reproduce the issue?

Google Chrome - version 124
Change the version of Selenium to 4.20.0
JDK 17
Windows 10

Relevant log output

java.lang.NoSuchMethodError: 'void org.openqa.selenium.remote.service.DriverFinder.<init>(org.openqa.selenium.remote.service.DriverService, org.openqa.selenium.Capabilities)'
    at org.openqa.selenium.chrome.ChromeDriver.generateExecutor(ChromeDriver.java:98)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:88)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:83)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:72)
    at com.core.automation.driver.manager.web.local.ChromeManager.getDriver(ChromeManager.java:21)
    at com.core.automation.driver.factory.web.local.LocalDriverFactory.getDriver(LocalDriverFactory.java:27)
    at com.core.automation.driver.impl.web.LocalDriverWebImpl.getDriver(LocalDriverWebImpl.java:13)
    at com.core.automation.driver.Driver.initDriverWeb(Driver.java:30)
    at com.core.automation.testbase.WebTestBase.setUp(WebTestBase.java:15)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.testng.internal.invokers.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:139)
    at org.testng.internal.invokers.MethodInvocationHelper.invokeMethodConsideringTimeout(MethodInvocationHelper.java:69)
    at org.testng.internal.invokers.ConfigInvoker.invokeConfigurationMethod(ConfigInvoker.java:361)
    at org.testng.internal.invokers.ConfigInvoker.invokeConfigurations(ConfigInvoker.java:296)
    at org.testng.internal.invokers.TestInvoker.runConfigMethods(TestInvoker.java:823)
    at org.testng.internal.invokers.TestInvoker.invokeMethod(TestInvoker.java:590)
    at org.testng.internal.invokers.TestInvoker.invokeTestMethod(TestInvoker.java:221)
    at org.testng.internal.invokers.MethodRunner.runInSequence(MethodRunner.java:50)
    at org.testng.internal.invokers.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:969)
    at org.testng.internal.invokers.TestInvoker.invokeTestMethods(TestInvoker.java:194)
    at org.testng.internal.invokers.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:148)
    at org.testng.internal.invokers.TestMethodWorker.run(TestMethodWorker.java:128)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
    at org.testng.TestRunner.privateRun(TestRunner.java:829)
    at org.testng.TestRunner.run(TestRunner.java:602)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:437)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:431)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:391)
    at org.testng.SuiteRunner.run(SuiteRunner.java:330)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:95)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1256)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1176)
    at org.testng.TestNG.runSuites(TestNG.java:1099)
    at org.testng.TestNG.run(TestNG.java:1067)
    at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:115)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)

Operating System

Windows 10

Selenium version

Java 4.20.0

What are the browser(s) and version(s) where you see this issue?

Chrome 124

What are the browser driver(s) and version(s) where you see this issue?

Selenium Manager

Are you using Selenium Grid?

NA

github-actions[bot] commented 6 months ago

@rsenthilr, thank you for creating this issue. We will troubleshoot it as soon as we can.


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C), add the applicable G-* label, and it will provide the correct link and auto-close the issue.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!

krmahadevan commented 6 months ago

@rsenthilr - NoSuchMethodError is Java's way of telling you that you have a messed up classpath. What I mean by a messedup classpath is that, there are one or more versions of the same library found via your dependencies and Maven/Gradle/Bazel (whatever is your build tool) ended up finding some version of that library, which is NOT compatible with the rest of the project's expectations.

If you are using Maven, first try and use the Maven dependency plugin to ensure that all selenium related dependencies are converging on 4.20.0

The goals that will help you do this would be mvn dependency:tree (or) mvn dependency:analze-report

This should let you fix your issues on your own.

acq-filjo commented 6 months ago

Same when using dotnet, DriverFinder.FullPath() is not there anymore.

krmahadevan commented 6 months ago

@acq-filjo - This is not the same issue as the one logged in this issue. This issue talks about a missing constructor within the DriverFinder class, but your issue seems to be around a missing method. I dont know too much about the dontnet ecosystem, but am guessing that it too should have the notion of dependencies and something that builds up the library path. You might want to apply the same notion that i called earlier, to your system as well.

acq-filjo commented 6 months ago

@krmahadevan Seems like it was deprecated. There was a change before in December with the binary path, and they changed it again, so we have to find ways to locate binary AGAIN, which is quite annoying. https://github.com/SeleniumHQ/selenium/commit/cf5393b05021c36249cd95a117c7636bac49b42f

rsenthilr commented 6 months ago

@krmahadevan - I have checked your suggestion and not seeing any compatibility issue and maven build success. But when I downgrade to 4.19 or 4.18 it is working fine just getting a warning stating CDP version mismatch. So It is something to fix with Selenium 4.20.0

[INFO] Scanning for projects...
[INFO] 
[INFO] ---------------< CoreTestAutomation:CoreTestAutomation >----------------
[INFO] Building CoreTestAutomation 0.0.1-SNAPSHOT
[INFO]   from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- dependency:3.6.0:tree (default-cli) @ CoreTestAutomation ---
[INFO] CoreTestAutomation:CoreTestAutomation:jar:0.0.1-SNAPSHOT
[INFO] +- io.appium:java-client:jar:8.6.0:compile
[INFO] |  +- org.seleniumhq.selenium:selenium-api:jar:4.13.0:compile
[INFO] |  +- org.seleniumhq.selenium:selenium-remote-driver:jar:4.13.0:compile
[INFO] |  |  +- com.google.auto.service:auto-service-annotations:jar:1.1.1:compile
[INFO] |  |  +- com.google.guava:guava:jar:32.1.2-jre:compile
[INFO] |  |  |  +- com.google.guava:failureaccess:jar:1.0.1:compile
[INFO] |  |  |  +- com.google.guava:listenablefuture:jar:9999.0-empty-to-avoid-conflict-with-guava:compile
[INFO] |  |  |  +- org.checkerframework:checker-qual:jar:3.33.0:compile
[INFO] |  |  |  +- com.google.errorprone:error_prone_annotations:jar:2.18.0:compile
[INFO] |  |  |  \- com.google.j2objc:j2objc-annotations:jar:2.8:compile
[INFO] |  |  +- io.netty:netty-buffer:jar:4.1.96.Final:compile
[INFO] |  |  +- io.netty:netty-codec-http:jar:4.1.96.Final:compile
[INFO] |  |  |  +- io.netty:netty-codec:jar:4.1.96.Final:compile
[INFO] |  |  |  \- io.netty:netty-handler:jar:4.1.96.Final:compile
[INFO] |  |  +- io.netty:netty-common:jar:4.1.96.Final:compile
[INFO] |  |  +- io.netty:netty-transport-classes-epoll:jar:4.1.96.Final:compile
[INFO] |  |  +- io.netty:netty-transport-classes-kqueue:jar:4.1.96.Final:compile
[INFO] |  |  +- io.netty:netty-transport-native-epoll:jar:4.1.96.Final:linux-x86_64
[INFO] |  |  +- io.netty:netty-transport-native-kqueue:jar:4.1.96.Final:osx-x86_64
[INFO] |  |  +- io.netty:netty-transport-native-unix-common:jar:4.1.96.Final:compile
[INFO] |  |  +- io.netty:netty-transport:jar:4.1.96.Final:compile
[INFO] |  |  |  \- io.netty:netty-resolver:jar:4.1.96.Final:compile
[INFO] |  |  +- io.opentelemetry:opentelemetry-api:jar:1.28.0:compile
[INFO] |  |  +- io.opentelemetry:opentelemetry-context:jar:1.28.0:compile
[INFO] |  |  +- io.opentelemetry:opentelemetry-exporter-logging:jar:1.28.0:compile
[INFO] |  |  |  +- io.opentelemetry:opentelemetry-sdk-metrics:jar:1.28.0:compile
[INFO] |  |  |  |  \- io.opentelemetry:opentelemetry-extension-incubator:jar:1.28.0-alpha:runtime
[INFO] |  |  |  \- io.opentelemetry:opentelemetry-sdk-logs:jar:1.28.0:compile
[INFO] |  |  +- io.opentelemetry:opentelemetry-sdk-common:jar:1.28.0:compile
[INFO] |  |  +- io.opentelemetry:opentelemetry-sdk-extension-autoconfigure-spi:jar:1.28.0:compile
[INFO] |  |  +- io.opentelemetry:opentelemetry-sdk-extension-autoconfigure:jar:1.28.0:compile
[INFO] |  |  |  \- io.opentelemetry:opentelemetry-api-events:jar:1.28.0-alpha:runtime
[INFO] |  |  +- io.opentelemetry:opentelemetry-sdk-trace:jar:1.28.0:compile
[INFO] |  |  +- io.opentelemetry:opentelemetry-sdk:jar:1.28.0:compile
[INFO] |  |  +- io.opentelemetry:opentelemetry-semconv:jar:1.28.0-alpha:compile
[INFO] |  |  +- org.asynchttpclient:async-http-client:jar:2.12.3:compile
[INFO] |  |  |  +- org.asynchttpclient:async-http-client-netty-utils:jar:2.12.3:compile
[INFO] |  |  |  +- io.netty:netty-codec-socks:jar:4.1.60.Final:compile
[INFO] |  |  |  +- io.netty:netty-handler-proxy:jar:4.1.60.Final:compile
[INFO] |  |  |  +- io.netty:netty-transport-native-epoll:jar:linux-x86_64:4.1.60.Final:compile
[INFO] |  |  |  +- io.netty:netty-transport-native-kqueue:jar:osx-x86_64:4.1.60.Final:compile
[INFO] |  |  |  +- com.typesafe.netty:netty-reactive-streams:jar:2.0.4:compile
[INFO] |  |  |  \- com.sun.activation:jakarta.activation:jar:1.2.2:compile
[INFO] |  |  +- org.seleniumhq.selenium:selenium-http:jar:4.13.0:compile
[INFO] |  |  |  \- dev.failsafe:failsafe:jar:3.3.2:compile
[INFO] |  |  +- org.seleniumhq.selenium:selenium-json:jar:4.13.0:compile
[INFO] |  |  +- org.seleniumhq.selenium:selenium-manager:jar:4.13.0:compile
[INFO] |  |  \- org.seleniumhq.selenium:selenium-os:jar:4.13.0:compile
[INFO] |  |     \- org.apache.commons:commons-exec:jar:1.3:compile
[INFO] |  +- org.seleniumhq.selenium:selenium-support:jar:4.13.0:compile
[INFO] |  +- com.google.code.gson:gson:jar:2.10.1:compile
[INFO] |  +- org.apache.commons:commons-lang3:jar:3.13.0:compile
[INFO] |  +- commons-io:commons-io:jar:2.14.0:compile
[INFO] |  \- org.slf4j:slf4j-api:jar:2.0.9:compile
[INFO] +- com.aventstack:extentreports:jar:5.0.9:compile
[INFO] |  +- io.reactivex.rxjava3:rxjava:jar:3.0.4:compile
[INFO] |  |  \- org.reactivestreams:reactive-streams:jar:1.0.3:compile
[INFO] |  \- org.freemarker:freemarker:jar:2.3.30:compile
[INFO] +- io.rest-assured:rest-assured:jar:5.3.0:compile
[INFO] |  +- org.apache.groovy:groovy:jar:4.0.6:compile
[INFO] |  +- org.apache.groovy:groovy-xml:jar:4.0.6:compile
[INFO] |  +- org.apache.httpcomponents:httpclient:jar:4.5.13:compile
[INFO] |  |  +- org.apache.httpcomponents:httpcore:jar:4.4.13:compile
[INFO] |  |  +- commons-logging:commons-logging:jar:1.2:compile
[INFO] |  |  \- commons-codec:commons-codec:jar:1.11:compile
[INFO] |  +- org.apache.httpcomponents:httpmime:jar:4.5.13:compile
[INFO] |  +- org.hamcrest:hamcrest:jar:2.1:compile
[INFO] |  +- org.ccil.cowan.tagsoup:tagsoup:jar:1.2.1:compile
[INFO] |  +- io.rest-assured:json-path:jar:5.3.0:compile
[INFO] |  |  +- org.apache.groovy:groovy-json:jar:4.0.6:compile
[INFO] |  |  \- io.rest-assured:rest-assured-common:jar:5.3.0:compile
[INFO] |  \- io.rest-assured:xml-path:jar:5.3.0:compile
[INFO] +- com.fasterxml.jackson.core:jackson-annotations:jar:2.14.2:compile
[INFO] +- org.assertj:assertj-core:jar:3.24.2:compile
[INFO] |  \- net.bytebuddy:byte-buddy:jar:1.12.21:compile
[INFO] +- org.testng:testng:jar:7.9.0:compile
[INFO] |  +- com.beust:jcommander:jar:1.82:compile
[INFO] |  \- org.webjars:jquery:jar:3.7.1:runtime
[INFO] +- io.github.bonigarcia:webdrivermanager:jar:5.8.0:compile
[INFO] |  +- com.github.docker-java:docker-java:jar:3.3.6:compile
[INFO] |  |  +- com.github.docker-java:docker-java-core:jar:3.3.6:compile
[INFO] |  |  |  +- com.github.docker-java:docker-java-api:jar:3.3.6:compile
[INFO] |  |  |  \- org.bouncycastle:bcpkix-jdk18on:jar:1.76:compile
[INFO] |  |  |     +- org.bouncycastle:bcprov-jdk18on:jar:1.76:compile
[INFO] |  |  |     \- org.bouncycastle:bcutil-jdk18on:jar:1.76:compile
[INFO] |  |  \- org.slf4j:jcl-over-slf4j:jar:1.7.30:compile
[INFO] |  +- com.github.docker-java:docker-java-transport-httpclient5:jar:3.3.6:compile
[INFO] |  |  +- com.github.docker-java:docker-java-transport:jar:3.3.6:compile
[INFO] |  |  \- net.java.dev.jna:jna:jar:5.13.0:compile
[INFO] |  +- org.brotli:dec:jar:0.1.2:compile
[INFO] |  +- org.apache.commons:commons-compress:jar:1.26.1:compile
[INFO] |  \- org.apache.httpcomponents.client5:httpclient5:jar:5.2.1:compile
[INFO] |     +- org.apache.httpcomponents.core5:httpcore5:jar:5.2:compile
[INFO] |     \- org.apache.httpcomponents.core5:httpcore5-h2:jar:5.2:compile
[INFO] +- org.seleniumhq.selenium:selenium-java:jar:4.20.0:compile
[INFO] |  +- org.seleniumhq.selenium:selenium-chrome-driver:jar:4.20.0:compile
[INFO] |  |  \- org.seleniumhq.selenium:selenium-chromium-driver:jar:4.20.0:compile
[INFO] |  +- org.seleniumhq.selenium:selenium-devtools-v122:jar:4.20.0:compile
[INFO] |  +- org.seleniumhq.selenium:selenium-devtools-v123:jar:4.20.0:compile
[INFO] |  +- org.seleniumhq.selenium:selenium-devtools-v124:jar:4.20.0:compile
[INFO] |  +- org.seleniumhq.selenium:selenium-devtools-v85:jar:4.20.0:compile
[INFO] |  +- org.seleniumhq.selenium:selenium-edge-driver:jar:4.20.0:compile
[INFO] |  +- org.seleniumhq.selenium:selenium-firefox-driver:jar:4.20.0:compile
[INFO] |  +- org.seleniumhq.selenium:selenium-ie-driver:jar:4.20.0:compile
[INFO] |  \- org.seleniumhq.selenium:selenium-safari-driver:jar:4.20.0:compile
[INFO] +- org.projectlombok:lombok:jar:1.18.30:provided
[INFO] +- com.github.javafaker:javafaker:jar:1.0.2:compile
[INFO] |  +- org.yaml:snakeyaml:jar:android:1.23:compile
[INFO] |  \- com.github.mifmif:generex:jar:1.0.2:compile
[INFO] |     \- dk.brics.automaton:automaton:jar:1.11-8:compile
[INFO] +- org.awaitility:awaitility:jar:4.2.0:compile
[INFO] +- com.machinezoo.noexception:noexception:jar:1.9.0:compile
[INFO] |  +- com.machinezoo.stagean:stagean:jar:1.3.0:compile
[INFO] |  \- com.machinezoo.closeablescope:closeablescope:jar:1.0.0:compile
[INFO] +- br.com.six2six:fixture-factory:jar:3.1.0:compile
[INFO] |  +- commons-beanutils:commons-beanutils:jar:1.8.3:compile
[INFO] |  +- commons-lang:commons-lang:jar:2.6:compile
[INFO] |  +- br.com.six2six:bfgex:jar:1.1.1:compile
[INFO] |  |  +- log4j:log4j:jar:1.2.14:compile
[INFO] |  |  \- org.apache.commons:commons-math:jar:2.2:compile
[INFO] |  +- com.rubiconproject.oss:jchronic:jar:0.2.6:compile
[INFO] |  |  \- junit:junit:jar:4.8.1:compile
[INFO] |  +- com.thoughtworks.paranamer:paranamer:jar:2.5:compile
[INFO] |  \- net.vidageek:mirror:jar:1.6.1:compile
[INFO] +- org.reflections:reflections:jar:0.10.2:compile
[INFO] |  +- org.javassist:javassist:jar:3.28.0-GA:compile
[INFO] |  \- com.google.code.findbugs:jsr305:jar:3.0.2:compile
[INFO] +- org.aeonbits.owner:owner-java8:jar:1.0.12:compile
[INFO] |  \- org.aeonbits.owner:owner:jar:1.0.12:compile
[INFO] +- io.github.sskorol:test-data-supplier:jar:2.2.0:compile
[INFO] |  +- org.jooq:joor:jar:0.9.14:compile
[INFO] |  +- one.util:streamex:jar:0.8.1:compile
[INFO] |  +- io.vavr:vavr:jar:0.10.4:compile
[INFO] |  |  \- io.vavr:vavr-match:jar:0.10.4:compile
[INFO] |  +- org.aspectj:aspectjrt:jar:1.9.19:compile
[INFO] |  +- org.apache.commons:commons-csv:jar:1.10.0:compile
[INFO] |  +- com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:jar:2.14.2:compile
[INFO] |  |  \- com.fasterxml.jackson.core:jackson-core:jar:2.14.2:compile
[INFO] |  +- com.fasterxml.jackson.core:jackson-databind:jar:2.14.2:compile
[INFO] |  +- org.apache.poi:poi:jar:5.2.3:compile
[INFO] |  |  +- org.apache.commons:commons-collections4:jar:4.4:compile
[INFO] |  |  +- org.apache.commons:commons-math3:jar:3.6.1:compile
[INFO] |  |  \- com.zaxxer:SparseBitSet:jar:1.2:compile
[INFO] |  +- org.apache.poi:poi-ooxml:jar:5.2.3:compile
[INFO] |  |  +- org.apache.poi:poi-ooxml-lite:jar:5.2.3:compile
[INFO] |  |  +- org.apache.xmlbeans:xmlbeans:jar:5.1.1:compile
[INFO] |  |  \- com.github.virtuald:curvesapi:jar:1.07:compile
[INFO] |  \- org.yaml:snakeyaml:jar:2.0:compile
[INFO] \- org.apache.logging.log4j:log4j-core:jar:2.19.0:compile
[INFO]    \- org.apache.logging.log4j:log4j-api:jar:2.19.0:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  3.529 s
[INFO] Finished at: 2024-05-02T13:19:53+05:30
[INFO] ------------------------------------------------------------------------
krmahadevan commented 6 months ago

@rsenthilr - The goals that I shared was supposed to tell you what all versions are being resolved to, in your classpath. You are supposed to go through the output to find out what is wrong and not look for a build success/failure. Your output clearly suggests that there's a discrepancy with respect to selenium-remote-driver. You are resolving to a very old version via your appium dependency, but if you look at what selenium-java needs, you will notice that it needs to be 4.20.0. Please fix your dependencies.

if you are expecting the build to fail when there's a dependency mismatch, then I would suggest that you adopt the Maven enforcer plugin and use its dependencyConvergence rule to enforce this.

Please refer to https://maven.apache.org/enforcer/enforcer-rules/dependencyConvergence.html for more details.

github-actions[bot] commented 6 months ago

💬 Please ask questions at:

rsenthilr commented 6 months ago

@krmahadevan - Thank you so much .. it is resolved after updating the Appium dependency version to latest.

diemol commented 6 months ago

@krmahadevan Seems like it was deprecated. There was a change before in December with the binary path, and they changed it again, so we have to find ways to locate binary AGAIN, which is quite annoying. cf5393b

@acq-filjo everything related to Selenium Manager is still in beta, so breaking changes are expected. In addition, you should not need to invoke those methods yourself as Selenium handles the driver binary for you.

acq-filjo commented 6 months ago

@krmahadevan Seems like it was deprecated. There was a change before in December with the binary path, and they changed it again, so we have to find ways to locate binary AGAIN, which is quite annoying. cf5393b

@acq-filjo everything related to Selenium Manager is still in beta, so breaking changes are expected. In addition, you should not need to invoke those methods yourself as Selenium handles the driver binary for you.

If we use it and need a path, then there's a reason for that and Selenium can't handle it.

diemol commented 6 months ago

OK, just be aware that it is a beta interface and it will probably keep changing.

github-actions[bot] commented 5 months ago

This issue has been automatically locked since there has not been any recent activity since it was closed. Please open a new issue for related bugs.