2

I am using selenium "4.1.2" with chrome 97. While selecting value from drop down using select class, getting exception:

java.lang.NoSuchMethodError: org.openqa.selenium.WebElement.getDomAttribute(Ljava/lang/String;)Ljava/lang/String;

Below are dependencies in my project:

                    ext {
                selenium = '4.1.2'
                webdrivermanager = '5.0.3'
            }
            dependencies {
                compile("org.seleniumhq.selenium:selenium-java:${selenium}")
            //    compile("io.github.bonigarcia:webdrivermanager:${webdrivermanager}")
                testImplementation "org.seleniumhq.selenium:selenium-chrome-driver:${selenium}"
                testImplementation "org.seleniumhq.selenium:selenium-firefox-driver:${selenium}"
                testImplementation "org.seleniumhq.selenium:selenium-ie-driver:${selenium}"
                testImplementation "org.seleniumhq.selenium:selenium-edge-driver:${selenium}"
                testImplementation "org.seleniumhq.selenium:selenium-safari-driver:${selenium}"
                testImplementation "org.seleniumhq.selenium:selenium-remote-driver:${selenium}"
                testImplementation "org.seleniumhq.selenium:selenium-support:${selenium}"
                testImplementation('org.junit.jupiter:junit-jupiter:5.5.1')
                testImplementation 'org.hamcrest:hamcrest:2.1'
                testImplementation 'org.hamcrest:hamcrest-library:2.1'
                testCompile("org.junit.jupiter:junit-jupiter-api:5.7.2")
                testRuntime 'org.junit.jupiter:junit-jupiter-engine:5.7.2'
                testRuntime("org.junit.platform:junit-platform-launcher:1.7.2")
                testCompile('io.github.bonigarcia:selenium-jupiter:3.3.4')
                compile group: 'io.qameta.allure', name: 'allure-junit5', version: '2.11.0'
                compile group: 'org.apache.pdfbox', name: 'pdfbox', version: '2.0.16'
                implementation group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.17.1'
                implementation group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.17.1'
                compile group: 'io.qameta.allure', name: 'allure-gradle', version: '2.7.0'
                compile 'org.apache.maven.plugins:maven-surefire-plugin:2.21.0'
                compile('com.assertthat:selenium-shutterbug:1.5')
                compile 'org.slf4j:slf4j-nop:1.7.25'
                implementation group: 'javax.mail', name: 'mail', version: '1.4.7'
                implementation group: 'javax.mail', name: 'javax.mail-api', version: '1.6.2'
                runtimeClasspath group: 'javax.mail', name: 'javax.mail-api', version: '1.6.2'
                compile group: 'net.lightbody.bmp', name: 'browsermob-core', version: '2.1.4'
                compile group: 'org.postgresql', name: 'postgresql', version: '42.2.14'
                compile group: 'org.mongodb', name: 'mongo-java-driver', version: '3.12.4'
                compile group: 'ru.yandex.qatools.ashot', name: 'ashot', version: '1.5.4'
                implementation group: 'org.json', name: 'json', version: '20201115'
                implementation group: 'com.googlecode.json-simple', name: 'json-simple', version: '1.1.1'
                testImplementation group: 'org.junit.platform', name: 'junit-platform-launcher', version: '1.7.2'
                testImplementation group: 'org.junit.platform', name: 'junit-platform-runner', version: '1.7.2'
                testImplementation group: 'org.junit.platform', name: 'junit-platform-surefire-provider', version: '1.3.2'

            }

Any help in resolving this issue is highly appreciated.

1
  • 1
    please update pdfbox to 2.0.25 (unrelated to your problem) Commented Feb 4, 2022 at 19:39

2 Answers 2

3

This error message...

java.lang.NoSuchMethodError: org.openqa.selenium.WebElement.getDomAttribute(Ljava/lang/String;)Ljava/lang/String;

...is the result of dependency version conflict.


Deep Dive

As per @titusfortner comment in the discussion you need to crosscheck that everything related to Selenium is set to 4.x and that nothing that requires Selenium 3.x (e.g., Appium 7) is included in your dependencies as @asolntsev in the comment mentions:

All implementations of WebElement do override method getDomAttribute(). It never throws UnsupportedOperationException in real life.


Solution

You need to execute mvn dependency:tree or gradle dependencies and you will be able to trace the problem as described in this example.

Sign up to request clarification or add additional context in comments.

Comments

0

I would try forcing below dependency in build.gradle

implementation (group: 'org.seleniumhq.selenium', name: 'selenium-api', version: '4.1.2') { force = true }

NoSuchMethod error occurs when dependency version conflict happens. If you are using lower version Appium, upgrading to following version,

implementation 'io.appium:java-client:8.0.0'

may resolve errors.

1 Comment

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.