selenium webdriver在eclips上运行时错误

时间:2017-02-11 21:39:57

标签: java eclipse selenium-webdriver webdriver

Exception in thread "main" java.lang.IllegalStateException: The driver executable does not exist: E:\chromedriver.exe
    at com.google.common.base.Preconditions.checkState(Preconditions.java:199)
    at org.openqa.selenium.remote.service.DriverService.checkExecutable(DriverService.java:121)
    at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:116)
    at org.openqa.selenium.chrome.ChromeDriverService.access$000(ChromeDriverService.java:32)
    at org.openqa.selenium.chrome.ChromeDriverService$Builder.findDefaultExecutable(ChromeDriverService.java:137)
    at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:296)
    at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:88)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:120)
    at MyPackage1.MyClass1.main(MyClass1.java:10)

2 个答案:

答案 0 :(得分:1)

下载并安装Google Chrome(如果您没有安装此浏览器) 下载Chromedriver executable并提取。
在代码中设置系统属性(在使用ChromeDriver之前):

System.setProperty("webdriver.chrome.driver", "path to the ChromeDriver file");

答案 1 :(得分:0)

您为Chrome驱动程序可执行文件添加了错误的路径,或者您没有。从here下载并使用以下代码段运行代码以获取可执行文件的路径。

System.setProperty("webdriver.chrome.driver", "path to the executable driver file");