Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
java.lang.IllegalStateException:驱动程序可执行文件不存在-Selenium Webdriver_Selenium_Selenium Webdriver_Webdriver_Illegalstateexception - Fatal编程技术网

java.lang.IllegalStateException:驱动程序可执行文件不存在-Selenium Webdriver

java.lang.IllegalStateException:驱动程序可执行文件不存在-Selenium Webdriver,selenium,selenium-webdriver,webdriver,illegalstateexception,Selenium,Selenium Webdriver,Webdriver,Illegalstateexception,我在尝试使用SeleniumWebDriver运行基本测试代码时遇到了一个IllegalStateException 这是我用eclipse编写的代码: { ... System.setProperty("webdriver.ie.driver","<Absolutepath>/IEDriverServer.exe"); WebDriver driver=new InternetExplorerDriver(); //This is the line which throws th

我在尝试使用SeleniumWebDriver运行基本测试代码时遇到了一个IllegalStateException

这是我用eclipse编写的代码:

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

WebDriver driver=new InternetExplorerDriver(); //This is the line which throws the exception 
...
}
IEDriverServer.exe已从SeleniumHQ下载页面下载并放置在我的系统(Windows 10)上

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


我浏览了类似的帖子,但没有找到解决问题的方法。

您是否已将绝对路径添加到您的路径中

Windows>系统>高级系统设置>环境变量

在“系统变量”下,编辑路径并添加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>


我在Windows10和IE11中运行SeleniumWebDriver时遇到了很多问题。如果你不需要,我会改用Chrome。更容易。

在path中设置绝对路径没有帮助。chromedriver也有同样的例外。
<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();