Reputation: 13
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
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.
@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");
You can find a couple of relevant discussions in:
Upvotes: 1