-1

尝试使用Selenium Webdriver运行基本测试代码时,出现IllegalStateException。java.lang.IllegalStateException:驱动程序可执行文件不存在 - Selenium Webdriver

这是我写的代码在Eclipse:

{ 
... 
System.setProperty("webdriver.ie.driver","<Absolutepath>/IEDriverServer.exe"); 

WebDriver driver=new InternetExplorerDriver(); //This is the line which throws the exception 
... 
} 

异常跟踪:

java.lang.IllegalStateException: The driver executable does not exist. 

at com.google.common.base.Preconditions.checkState(Preconditions.java:518) 
    at org.openqa.selenium.remote.service.DriverService.checkExecutable(DriverService.java:123) 

的IEDriverServer.exe已从SeleniumHQ下载页面下载并把我的系统(Windows 10)上。

当我尝试Chrome驱动程序时也发生同样的异常。

我已经通过类似的帖子,但找不到解决问题的东西。

回答

0

你有没有添加PATH的绝对路径?

窗口>系统>高级系统设置>环境变量

在系统变量编辑路径,添加文件夹,您WebDriver.exe是

如果你正在寻找一个很好的跨浏览器插件添加下面依赖关系你的pom.xml,它会照顾一切为您:

<dependency> 
      <groupId>io.github.bonigarcia</groupId> 
      <artifactId>webdrivermanager</artifactId> 
      <version>1.6.0</version> 
      <exclusions> 
       <exclusion> 
        <groupId>com.google.guava</groupId> 
        <artifactId>guava</artifactId> 
       </exclusion> 
      </exclusions> 
     </dependency> 

然后使用:

ChromeDriverManager.getInstance().setup(); 
WebDriver driver = new ChromeDriver(); 

InternetExplorerDriverManager.getInstance().setup(); 
WebDriver driver = new InternetExplorerDriver(); 

Ive有在Windows 10和IE11运行硒的webdriver不少问题。如果你不需要我会切换到Chrome。更容易。

+0

在PATH中设置绝对路径没有帮助。对于镀铬汽油也同样例外。 – Elma

相关问题