Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting "The path to the driver executable must be set by the webdriver.chrome.driver system property"though set correct path

My code is very simple code:

WebDriver wd =new ChromeDriver();
  System.setProperty("webdriver.chrome.driver",
                     "D:\\List_of_Jar\\chromedriver.exe");    
       String baseUrl = "https://www.google.com";wd.get(baseUrl);

have downloaded and added jar as "Java-3.4.0" from selenium hq site. Download Google Chrome Driver-2.29 from the same website and located it in "D:\List_of_Jar" path.

When I run the above code I getting an error as

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:738)

Getting version error though did proper configuration. so kindly help me for fixing the issue.

Details:

  • OS: Windows XP.
  • Java : JDK1.8 and JRE1.8.
  • Selenium : version 3.4
like image 640
sathish kumar Avatar asked Jun 10 '17 18:06

sathish kumar


People also ask

How do I fix Chromedriver executable in path?

Conclusion # To solve the Selenium error "WebDriverException: Message: 'chromedriver' executable needs to be in PATH", install and import the webdriver-manager module by running pip install webdriver-manager . The module simplifies management of binary drivers for different browsers.

How do we set the path of driver executable?

getting java lang IllegalStateException The path to the driver executable must be set by the webdriver chrome driver system property. WebDriver driver = new ChromeDriver(); System. setProperty("webdriver.


2 Answers

Driver path should be set before browser launch as given below.

System.setProperty("webdriver.chrome.driver","D:\List_of_Jar\chromedriver.exe");
WebDriver wd =new ChromeDriver();
String baseUrl = "https://www.google.com";
wd.get(baseUrl);"
like image 122
Murthi Avatar answered Sep 18 '22 09:09

Murthi


You are setting chrome driver path incorrectly. Property must be set before WebDriver initialization.

Set property like this -

System.setProperty("webdriver.chrome.driver","D:\\List_of_Jar\\chromedriver.exe")
WebDriver wd =new ChromeDriver();
String baseUrl = "https://www.google.com";
wd.get(baseUrl);" 
like image 24
Ankur Avatar answered Sep 18 '22 09:09

Ankur