0

when I run the below simple @Test selenium code with WebDriver Manager setup, I am facing the following error

"java: cannot access io.github.bonigarcia.wdm.WebDriverManager bad class file class file has wrong version 55.0, should be 52.0

Code Snippet:

 @Test
public void driverSetUp(){
    WebDriverManager.chromedriver().setup();
    WebDriver driver = new ChromeDriver();
    driver.get("https://www.google.com");
    driver.close();
    driver.quit();
}

pom.xml content,

 <dependencies>
    <!-- https://mvnrepository.com/artifact/org.testng/testng -->
    <dependency>
      <groupId>org.testng</groupId>
      <artifactId>testng</artifactId>
      <version>7.4.0</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
    <dependency>
      <groupId>org.seleniumhq.selenium</groupId>
      <artifactId>selenium-java</artifactId>
      <version>4.10.0</version>
    </dependency>
    <dependency>
      <groupId>io.github.bonigarcia</groupId>
      <artifactId>webdrivermanager</artifactId>
      <version>5.3.2</version> <!-- Use the appropriate version -->
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
    </dependency>
  </dependencies>
Boni García
  • 4,618
  • 5
  • 28
  • 44
Jack Vicky
  • 81
  • 1
  • 5

2 Answers2

2

You need to use Java 11 (or above) with WebDriverManager 5.4.0 (or above).

UPDATE: To provide a solution to those that cannot bump to Java 11, I released WebDriverManager 5.5.3, compiled with Java 8.

In any case, my personal opinion is that Java 8 is already an ancient version, and I recommend using at least Java 11+ as soon as possible.

Boni García
  • 4,618
  • 5
  • 28
  • 44
0

The Error means that the dependency class may not compiled/downloaded correctly. To fix this issue you need to re-compile the maven file

if using IntelliJ IDEA, go to maven and run "clean" command and run "install" command this will clean and re-download the dependency class files correctly. if required adjusts the TestNG maven dependency version to a stable version

Jack Vicky
  • 81
  • 1
  • 5