Reputation: 7768
I am a newbie to selenium web driver.I have a test written in java which is to be tested using Selenium web driver. I ran the test class as a java application.I wrote the following snippet of code to obtain the instance of the ChromeDriver. I get the following message for the following code snippet.
@Override
public WebDriver get() {
log.info("Creating Chrome driver");
try {
return new ChromeDriver(buildCapabilities());
} catch (IOException e) {
throw new ExceptionInInitializerError(e);
}
}
Also have the path to the ChromeDriver set
private static final String CHROME_DRIVER = "chromedriver.exe"; URL chromeDriverUrl = getClass().getResource("/" + CHROME_DRIVER); String pathToChromeDriver = chromeDriverUrl.getPath(); System.setProperty("webdriver.chrome.driver", pathToChromeDriver);
IMAGE:
Do not understand as to why the following message is displayed on the return new ChromeDriver(buildCapabilities()) line of code.
Upvotes: 0
Views: 369
Reputation: 1
you may also try using bonigarcia
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>5.3.2</version>
</dependency>
private WebDriver webDriver;
public WebDriver getDriver(){
ChromeOptions options = new ChromeOptions();
WebDriverManager.chromedriver().setup();
options.addArguments("--remote-allow-origins=*", "ignore-certificate-errors");
webDriver = new ChromeDriver(options);
return webDriver;
}
Upvotes: 0
Reputation: 7768
Very simple change. Reimporting my project into the IntelliJ evironment fixed the problem.
Upvotes: 0
Reputation: 6617
to use chrome driver you need to download chrome driver from here
and then use the chrome driver by
System.setProperty("webdriver.chrome.driver", "C:/Users/Hussain/Desktop/selenium-2.30.0/chromedriver.exe");
WebDriver driver = new ChromeDriver();
Upvotes: 1
Reputation: 5547
Well, for starters, ChromeDriver (and FireFox driver) are both RemoteWebDrivers, not WebDrivers. Those types are not compatible. As for why you're getting a firefox driver instead of a chrome one, I'm guessing that your either your buildCapabilities() function or your remote grid is returning a firefox driver.
Upvotes: 0