2

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.

DeeJay007
  • 469
  • 4
  • 30
  • Check you local maven repo.I think the selenium support jar in you local doesnt have `org.openqa.selenium.support.PageFactory` class i guess. – Sudha Velan Dec 04 '17 at 07:21
  • @SudhaVelan, the class is available alright. The problem is with version. – DeeJay007 Dec 04 '17 at 07:23
  • 1
    @DeeJay007 https://stackoverflow.com/questions/29906659/java-compiling-error-in-command-prompt-class-file-has-wrong-version-52-0-shoul – Grasshopper Dec 04 '17 at 07:36
  • It turned out to be that Configure System in Jenkins needs to updated with the JDK 1.8 version too. This was the reason for the issue. – DeeJay007 Dec 04 '17 at 09:39

1 Answers1

1

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 :

  • Upgrade JDK to recent version JDK 8u151
  • Use recent version of 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

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • Thanks a lot @DebanjanB, I removed selenium-support and included selenium-server jars in the pom. – DeeJay007 Dec 04 '17 at 09:41
  • the real issue is JDK 1.8 is not included in the Jenkins Configuration. This is the reason why it worked with maven CMD and not in Jenkins. – DeeJay007 Dec 04 '17 at 10:15