Serenity-core: Exception in thread "main" java.lang.NoClassDefFoundError: org/openqa/selenium/interactions/internal/Locatable

Created on 15 Jan 2018  Â·  15Comments  Â·  Source: serenity-bdd/serenity-core

I have tried using Serenity to create Selenium tests in Gherkin files.
When running my tests, I get a NoClassDefFoundError:

Exception in thread "main" java.lang.NoClassDefFoundError: org/openqa/selenium/interactions/internal/Locatable

My POM has dependencies on _net.serenity-bdd:serenity-core:1.8.21_ and _net.serenity-bdd:serenity-junit:1.8.21_ as well as _net.serenity-bdd:serenity-cucumber:1.6.10_.

The problem seems to be that _net.serenitybdd.core.pages.WebElementFacade_ imports _org.openqa.selenium.interactions.internal.Locatable_ but Locatable is actually in _org.openqa.selenium.internal.Locatable_.

Most helpful comment

Just a quick comment on this one. I encountered this error because I used Spring Boot's parent pom, which fixes the Selenium version to 2.53.1 in its dependencyManagement section. Overriding the selenium.version property to be 3.10.0 (or whichever version is compatible with Serenity) in my own pom fixed the problem for me. Hope this helps.

All 15 comments

That error would be due to a dependency conflict in your project, most likely an older version of Serenity.

As I said, I am using serenity-core and serenity-junit in version 1.8.21 which is the current release. I've also tried version 1.8.20 with the same result.

serenity-cucumber is in version 1.6.10, but its POM shows dependencies to serenity in version 1.8.20 which leads me to believe they should be compatible.

It looks like a selenium library version conflict

I agree. Do you know which version of Selenium is compatible? I have tried to find a version that has the required _org/openqa/selenium/interactions/internal/Locatable_ but to no avail.

I think it is 3.8.1, but the simplest is usually just to let Serenity bring it in

That's what I am doing.

I've executed _mvn dependency:tree_ and interestingly, _selenium-api_ is brought in in version 2.53.1 rather than 3.8.1 which is explicitly asked for in the serenity-core POM. _selenium-api_ is where Locatable lives. The 3.8.1 version has it at the correct location.

I am at a loss why 2.53.1 is brought in. Some dependencies are brought in as 2.53.1, some as 3.8.1.

There is most likely a dependency in your pom that uses selenium 2.53, which is taking precedence.

Closing due to lack of activity.

@wakaleo I am also getting exact same issue. Pl find my pom file. Made sure my Local Repo is Completely Deleted to ensure there is not previous version.


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

<parent>
    <groupId>aa.ct.fly</groupId>
    <artifactId>merchandising-bff</artifactId>
    <version>0.0.1-SNAPSHOT</version>
</parent>

<groupId>com.sample.me</groupId>
<artifactId>service-bff-acceptance-test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <serenity.version>1.8.21</serenity.version>
    <serenity.cucumber.version>1.6.10</serenity.cucumber.version>
    <webdriver.driver>firefox</webdriver.driver>
</properties>

<dependencies>
    <dependency>
        <groupId>net.serenity-bdd</groupId>
        <artifactId>serenity-core</artifactId>
        <version>${serenity.version}</version>
    </dependency>
    <dependency>
        <groupId>net.serenity-bdd</groupId>
        <artifactId>serenity-rest-assured</artifactId>
        <version>${serenity.version}</version>
    </dependency>
    <dependency>
        <groupId>net.serenity-bdd</groupId>
        <artifactId>serenity-cucumber</artifactId>
        <version>${serenity.cucumber.version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-simple</artifactId>
        <version>1.7.7</version>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.12</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.velocity</groupId>
        <artifactId>velocity</artifactId>
        <version>1.7</version>
    </dependency>
    <dependency>
        <groupId>org.apache.velocity</groupId>
        <artifactId>velocity</artifactId>
        <version>1.7</version>
        <scope>test</scope>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.19.1</version>
            <configuration>
                <skip>true</skip>
            </configuration>
        </plugin>
        <plugin>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>2.19.1</version>
            <configuration>
                <includes>
                    <include>**/*.java</include>
                </includes>
                <argLine>-Xmx512m</argLine>
                <systemPropertyVariables>
                    <webdriver.driver>${webdriver.driver}</webdriver.driver>
                </systemPropertyVariables>
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>integration-test</goal>
                        <goal>verify</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.2</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>net.serenity-bdd.maven.plugins</groupId>
            <artifactId>serenity-maven-plugin</artifactId>
            <version>${serenity.version}</version>
            <executions>
                <execution>
                    <id>serenity-reports</id>
                    <phase>post-integration-test</phase>
                    <goals>
                        <goal>aggregate</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

Getting Error:
Running features.offers.BagOffers
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.288 sec <<< FAILURE! - in features.offers.BagOffers
initializationError(features.offers.BagOffers) Time elapsed: 0.005 sec <<< ERROR!
java.lang.NoClassDefFoundError: org/openqa/selenium/interactions/internal/Locatable
Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.interactions.internal.Locatable

As you mentioned, it is picking up Selenium selenium-api-2.53.1 instead of 3.8.1 which is dependency for latest serenity core.

Please advise the fix for this conflict

I explicitly added dependencies for all selenium artifacts wqith version 3.8.1 in my pom, I could see that now the Locatable is referencing the lib 3.8.1 only, but now I am getting following error:
features.eligibility.BagEligibility Time elapsed: 0.032 sec <<< ERROR!
java.lang.NoClassDefFoundError: Could not initialize class net.thucydides.core.webdriver.SupportedWebDriver

Results :

Tests in error:
Could not initialize class net.thucydides.core.webdriver.SupportedWebDriver
Could not initialize class net.thucydides.core.webdriver.SupportedWebDriver
Could not initialize class net.thucydides.core.webdriver.SupportedWebDriver
Could not initialize class net.thucydides.core.webdriver.SupportedWebDriver
Could not initialize class net.thucydides.core.webdriver.SupportedWebDriver
org/openqa/selenium/internal/Killable
BagEligibility.features.eligibility.BagEligibility » NoClassDefFound Could not...
FulfillBagOffers.features.fulfillment.FulfillBagOffers » NoClassDefFound Could...
BagOffers.features.offers.BagOffers » NoClassDefFound Could not initialize cla...

Tests run: 9, Failures: 0, Errors: 9, Skipped: 0

Just an FYI, I am testing my microservice using Serenity BDD with Cucumber. If it has nothing to do with Selenium/ Browser based testing, ideally core libs should have been modularized such a way that it should not have even downloaded anything related to Selenium. Just a thought!!

Do you have a stack trace?

Hi John,

I was trying to reproduce the Error at home so that I could send you. I am unable to reproduce it and everything seems working fine, not sure but it seems as you had indicated in comments, I was getting version conflicts may be because I was in office and the dependency was not downloading properly(may be corporate firewall/ nexus repo) etc was not letting it download all clean.

For now, things look good, I will retry again in office tomorrow. If it had something to do with connectivity in there.

Thank you again for patiently answering all our questions.

try to create project using 3 words on groupId. like
com.exercise.automation. I have issue when creating serenity using 2 words
only when using serenity-jbehave-archetype

On 8 Feb 2018 6:46 am, "John Ferguson Smart" notifications@github.com
wrote:

Do you have a stack trace?

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/serenity-bdd/serenity-core/issues/1080#issuecomment-363951366,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AGWjkmCAKzvgNzaHsaNwQGDI83YjPCRcks5tSjXggaJpZM4ReTDU
.

Just a quick comment on this one. I encountered this error because I used Spring Boot's parent pom, which fixes the Selenium version to 2.53.1 in its dependencyManagement section. Overriding the selenium.version property to be 3.10.0 (or whichever version is compatible with Serenity) in my own pom fixed the problem for me. Hope this helps.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

siva90144 picture siva90144  Â·  3Comments

dgracehmh picture dgracehmh  Â·  8Comments

samangipudi picture samangipudi  Â·  5Comments

vikramvi picture vikramvi  Â·  7Comments

AnnaKlueva picture AnnaKlueva  Â·  7Comments