Reputation: 509
My Java web application is upgraded from JDK 1.6
to JDK 1.8
version and I am updating the test environment to use the updated Selenium
components as well.
Below mentioned are the updated Jars which I included in the pom.xml
.
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.0.0</version>
<type>jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server-standalone</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-support</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-leg-rc</artifactId>
<version>3.0.0</version>
</dependency>
When I run a Job in Jenkins
, it is throwing a compilation error as mentioned below.
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] D:\Jenkins\workspace\WIDFLY-trunk\src\test\java\com\company\test\dragon\acceptance\test\shiftscheduling\switchautm\switchtimes\SwitchingTimesAbsTest.java:[3,-1] cannot access org.openqa.selenium.support.PageFactory
bad class file: org\openqa\selenium\support\PageFactory.class(org\openqa\selenium\support:PageFactory.class)
class file has wrong version 52.0, should be 50.0
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 31.294s
[INFO] Finished at: Mon Dec 04 CET 2017
[INFO] Final Memory: 13M/31M
[INFO] ------------------------------------------------------------------------
Waiting for Jenkins to finish collecting data
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:testCompile (default-testCompile) on project test: Compilation failure
[ERROR] D:\Jenkins\workspace\WIDFLY-trunk\src\test\java\com\company\test\dragon\acceptance\test\shiftscheduling\switchautm\switchtimes\SwitchingTimesAbsTest.java:[3,-1] cannot access org.openqa.selenium.support.PageFactory
[ERROR] bad class file: org\openqa\selenium\support\PageFactory.class(org\openqa\selenium\support:PageFactory.class)
[ERROR] class file has wrong version 52.0, should be 50.0
[ERROR] -> [Help 1]
What is that I am missing? I think it has a problem with selenium-support
jar version but I have tried with lower version too and I am getting the same error.
Note: If I execute directly using maven
in CMD prompt I am not getting any errors. Jenkins job execution only throws this error.
Kindly help please.
Upvotes: 2
Views: 3033
Reputation: 193108
The error does gives us a hint with what's going wrong as :
cannot access org.openqa.selenium.support.PageFactory
and
class file has wrong version 52.0, should be 50.0
The most likely solution for you will be to :
JDK
to recent version JDK 8u151
Selenium Maven Dependencies
current being v3.8.1
Try to use selenium-java
dependency only.
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.8.1</version>
</dependency>
If you are using RemoteWebDriver implementation
, you still need to start a Selenium server. The best way is to download the selenium-server-standalone.jar
from the Selenium Downloads page
and just use it. You can also embed the Selenium Server into your own project, if you add the following dependency to your pom.xml
:
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>3.8.1</version>
</dependency>
selenium-support
is no longer a valid dependency so you can remove it.
Do maven clean
and maven install
Re-Run your Test
Upvotes: 1