Dave Faundo
Dave Faundo

Reputation: 13

The type org.openqa.selenium.chrome.ChromeDriver is not accessible with Java 12

I am new to Selenium for the purpose of familiarizing for an internship. Currently, I am having a problem with importing chromedriver jar. I am currently using Java 12. It is weird because the error seems to go away when I switch the compiler to Java 1.8. Can anyone help me with this problem?

package co.edureka.selenium.webdriver.sj;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class launchbrowser {

    public static WebDriver driver = null;

    public static void main(String[] args) {

        System.setProperty("webdriver.chrome.driver",".\\Driver\\chromedriver.exe");

        driver = new ChromeDriver();
        driver.navigate().to("https://amazon.com");
    }

}

"import org.openqa.selenium.chrome.ChromeDriver" displays this error

"The type org.openqa.selenium.chrome.ChromeDriver is not accessible";

"ChromeDriver()" displays this error

"ChromeDriver cannot be resolved to a type"

Upvotes: 0

Views: 16336

Answers (1)

undetected Selenium
undetected Selenium

Reputation: 193298

These error messages...

The type org.openqa.selenium.chrome.ChromeDriver is not accessible

and

ChromeDriver cannot be resolved to a type

...implies that ChromeDriver wasn't resolved at compiletime.


A bit more details about the binaries and your test framework i.e. Selenium jars or maven would have helped us to analyze the issue in a better way. Presumably you have resolved the WebDriver and ChromeDriver from one JAR source (i.e. either selenium-server-standalone-3.141.59 or selenium-java-3.141.59 JARs) but compiletime the Classes are trying to get resolved from the other JAR. Hence you see the error.


Solution

  • Either keep only selenium-server-standalone-3.141.59.jar as an external JAR.
  • Or keep only selenium-java-3.141.59 JARs as an external JARs.
  • Remove all the other Selenium Java Client JARs.
  • Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
  • Take a System Reboot.
  • Execute your @Test.

Additionally, you need to provide the absolute path of the chromedriver.exe as follows:

System.setProperty("webdriver.chrome.driver","C:\\full_path\\Driver\\chromedriver.exe");

References

You can find a couple of relevant discussions in:

Upvotes: 1

Related Questions