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.
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();
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.
Very simple change. Reimporting my project into the IntelliJ evironment fixed the problem.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.