尽管设置了正确的路径,但获取“驱动程序可执行文件的路径必须由webdriver.chrome.driver系统属性设置" [英] 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);
已从selenium hq网站下载并添加了jar作为"Java-3.4.0". 从同一网站下载Google Chrome驱动程序2.29,并将其放在"D:\ List_of_Jar"路径中.
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)
尽管进行了正确的配置,但仍出现版本错误.请帮助我解决此问题. 细节: 操作系统:Windows XP. Java:JDK1.8和JRE1.8. 硒:3.4版
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
推荐答案
驱动器路径应在浏览器启动之前设置,如下所示.
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);"
这篇关于尽管设置了正确的路径,但获取“驱动程序可执行文件的路径必须由webdriver.chrome.driver系统属性设置"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!