获取“驱动程序可执行文件的路径必须由 webdriver.chrome.driver 系统属性设置",尽管设置正确的路径 [英] Getting "The path to the driver executable must be set by the webdriver.chrome.driver system property"though set correct path

查看:54
本文介绍了获取“驱动程序可执行文件的路径必须由 webdriver.chrome.driver 系统属性设置",尽管设置正确的路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码很简单代码:

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

已下载并添加 jar 为Java-3.4.0";来自硒总部网站.从同一网站下载 Google Chrome Driver-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)

虽然配置正确,但出现版本错误.请帮我解决这个问题.

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

详情:

  • 操作系统:Windows XP.
  • Java:JDK1.8 和 JRE1.8.
  • 硒:3.4 版

推荐答案

应该在浏览器启动之前设置驱动路径,如下所示.

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);"

这篇关于获取“驱动程序可执行文件的路径必须由 webdriver.chrome.driver 系统属性设置",尽管设置正确的路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆