Getting “The path to the driver executable must be

2020-02-06 05:52发布

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

8条回答
走好不送
2楼-- · 2020-02-06 06:16

You should use Chocolatey as the Selenium wiki dictates. It will work straight away.

Windows users with Chocolatey installed: choco install chromedriver

https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver

查看更多
Melony?
3楼-- · 2020-02-06 06:19

You are setting chrome driver path incorrectly. And property must be set before WebDriver initialisation.

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);" 
查看更多
登录 后发表回答