Reputation: 984
I have a spring boot application, that I want to test with Selenium. I'm using WebDriverManager v5.0.3
When settin up the WebDriver WebDriverManager.chromedriver().setup();
I get an exception:
java.lang.NoClassDefFoundError: org/openqa/selenium/internal/Require
or
java.lang.ClassNotFoundException: org.openqa.selenium.internal.FindsById
My pom.xml contains this:
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>5.0.3</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.1.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-api</artifactId>
<version>4.1.0</version>
</dependency>
Upvotes: 4
Views: 24181
Reputation: 1
Latest selenium 4.6.0 is not compatible with web driver manager 5. So you need to downgrade web driver manager to 4.4.3. It is last stable version before 5.0. Downgrade it and it will work fine
Upvotes: 0
Reputation: 984
There is an incompatibility between WebDriverManager v5.0.3 and Selenium v4. After Downgrading Selenium to the latest v3 subversion, everything works.
Update: As of the comment below it works with WebDriverManager >=v5.1.0
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>5.0.3</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-api</artifactId>
<version>3.141.59</version>
</dependency>
Upvotes: 8
Reputation: 63
You can check your libraries with your project.
I face this problem too, finally I found in my maven project the dependencies libraries of selenium doesn't have same version.
I create a new project use Gradle other than Maven with selenium 4.0.0 and it works fine.
so I check the incorrect libraries and manually adjust to same version with selenium-java library in my pom.xml. finally it works.
BTW: mvn clean install doesn't work for me.
<!-- only this origin -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.0.0</version>
</dependency>
<!-- add belows for these dependencies version is not 4.0.0 when automatically generated -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-chrome-driver</artifactId>
<version>4.0.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-api</artifactId>
<version>4.0.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-remote-driver</artifactId>
<version>4.0.0</version>
</dependency>
Upvotes: 5
Reputation: 1
You need to execute mvn clean compile
command on the same directory where the pom.xml
file is after you change version to 4** or adding this dependency to pom file.
Upvotes: 0