Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

selenium - 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
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...