Test started failing with java.lang.NoSuchMethodError

676 views Asked by At

Started getting this error when trying to run the test that was just running fine. No idea what happened!

Step failed
java.lang.NoSuchMethodError: 'void org.openqa.selenium.remote.http.ClientConfig.<init>(java.net.URI, java.time.Duration, java.time.Duration, org.openqa.selenium.remote.http.Filter, java.net.Proxy, org.openqa.selenium.Credentials)'
    at io.appium.java_client.AppiumClientConfig.<init>(AppiumClientConfig.java:62)
    at io.appium.java_client.AppiumClientConfig.defaultConfig(AppiumClientConfig.java:79)
    at io.appium.java_client.remote.AppiumCommandExecutor.<init>(AppiumCommandExecutor.java:109)
    at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:101)
    at io.appium.java_client.android.AndroidDriver.<init>(AndroidDriver.java:113)

POM (had to remove unnecessary code):

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" 4.0.0

<maven.compiler.source>20</maven.compiler.source> <maven.compiler.target>20</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

io.appium java-client 8.5.1
org.junit.jupiter junit-jupiter 5.10.0 test
io.cucumber cucumber-core 7.13.0
io.cucumber cucumber-html 0.2.7
io.github.devopsplugin cobertura 0.0.2
io.cucumber cucumber-java 7.13.0
io.cucumber cucumber-jvm-deps 1.0.6 provided
net.masterthought cucumber-reporting 5.7.6
org.hamcrest hamcrest 2.2 test
io.cucumber gherkin 26.2.0
io.cucumber cucumber-java 7.13.0
org.seleniumhq.selenium selenium-java 4.11.0
io.cucumber cucumber-junit 7.13.0
io.cucumber cucumber-junit 7.13.0
io.cucumber cucumber-junit 7.13.0
io.cucumber cucumber-junit 7.13.0
io.cucumber cucumber-junit 7.13.0
io.cucumber cucumber-junit 7.13.0
io.cucumber cucumber-junit 7.13.0
io.cucumber cucumber-junit 7.13.0
io.cucumber cucumber-junit 7.13.0
io.github.bonigarcia webdrivermanager 5.5.3
org.jetbrains annotations RELEASE compile

2

There are 2 answers

0
Rednaskel On

Signature of constructor of ClientConfig class changed between 4.14.0 and 4.13.0 version. That class is from selenium-http dependency, which is transitive dependency from selenium-remote-driver, on which appium is dependent on.

In their file, they set the dependency to the latest in given range -> build.gradle

So, without any changes to your dependencies, transitive dependency changed and is crashing your run.

Based on: transitive-dependencies-management.md

you can hardcode version to 4.13 which should fix the problem. Example, in your pom.xml:

<dependencies>
    <dependency> <!-- explicitly download correct dependency -->
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-remote-driver</artifactId>
        <version>4.13.0</version>
    </dependency>
    <dependency>
        <groupId>io.appium</groupId>
        <artifactId>java-client</artifactId>
        <version>8.5.1</version>
        <exclusions>
            <exclusion>  <!-- exclude what appium is downloading -->
                <groupId>org.seleniumhq.selenium</groupId>
                <artifactId>selenium-remote-driver</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
</dependencies>
0
Aadhar Dewang On

I updated the appium java-client dependency to the latest and it fixed the issue for me.

 <!-- https://mvnrepository.com/artifact/io.appium/java-client -->
    <dependency>
        <groupId>io.appium</groupId>
        <artifactId>java-client</artifactId>
        <version>8.6.0</version>
    </dependency>