Error in Chromedriver | Selenium Forum
M
Posted on 14/11/2015
Exception in thread "main" java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://chromedriver.storage.googleapis.com/index.html
at com.google.common.base.Preconditions.checkState(Preconditions.java:197)




My code:

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



public class Driver {
public static void main(String[] args) {

ChromeDriver cd= new ChromeDriver();
System.setProperty("webdriver.chrome.driver", "F:\\chromedriver.exe");
cd.get("http://google.com");

}
}


Steps:

As per video , I downloaded chrome driver exe file from selenium org site and kept at above folder.

But I am getting error.


Please find screenshots

M
Replied on 14/11/2015

You need to set property first and then need to create the instance of ChromeDriver.

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



public class Driver {
public static void main(String[] args) {

[b:2neqn5oq]System.setProperty("webdriver.chrome.driver", "F:\\chromedriver.exe");[/b:2neqn5oq]

[color=#008080:2neqn5oq]ChromeDriver cd= new ChromeDriver();
[/color:2neqn5oq]
cd.get("http://google.com");

}
}