java 使用 Selenium Webdriver 的 IE 浏览器:“驱动程序可执行文件是一个目录”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28824540/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
IE Browser using Selenium Webdriver: "The driver executable is a directory"
提问by Bhavesh
I am getting the following error while trying to launch an IE browser using Selenium Webdriver. What seems to be the problem?
尝试使用Selenium Webdriver启动 IE 浏览器时出现以下错误。似乎是什么问题?
Exception in thread "main" java.lang.IllegalStateException: The driver executable is a directory: D:\Bhavesh\Bhavesh_Data\Study\Selenium\IEDriverServer_x64_2.45.0
at com.google.common.base.Preconditions.checkState(Preconditions.java:197)
at org.openqa.selenium.remote.service.DriverService.checkExecutable(DriverService.java:119)
at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:112)
at org.openqa.selenium.ie.InternetExplorerDriverService.access(InternetExplorerDriverService.java:1)
at org.openqa.selenium.ie.InternetExplorerDriverService$Builder.build(InternetExplorerDriverService.java:247)
at org.openqa.selenium.ie.InternetExplorerDriver.setupService(InternetExplorerDriver.java:251)
at org.openqa.selenium.ie.InternetExplorerDriver.<init>(InternetExplorerDriver.java:172)
at org.openqa.selenium.ie.InternetExplorerDriver.<init>(InternetExplorerDriver.java:146)
at first.IEDriver.main(IEDriver.java:11)
回答by Vikram
As per my understanding, when you set property for IEDriver location, you did not mentioned the full path (full directory path including iedriver exe)
根据我的理解,当您为 IEDriver 位置设置属性时,您没有提到完整路径(包括 iedriver exe 的完整目录路径)
For example.. Consider the following..
例如..考虑以下..
if you placed your IEDriverServer.exe in "D:/IEdriver" , then you have to set the property as follows:-
如果您将 IEDriverServer.exe 放在 "D:/IEdriver" 中,则必须按如下方式设置该属性:-
Right Approach:-System.setProperty("webdriver.ie.driver", "D:/IEdriver/IEDriverServer.exe");
正确的方法:- System.setProperty("webdriver.ie.driver", "D:/IEdriver/IEDriverServer.exe");
Wrong approach :-System.setProperty("webdriver.ie.driver", "D:/IEdriver");
错误的方法:- System.setProperty("webdriver.ie.driver", "D:/IEdriver");
Let me know if it helps
让我知道它是否有帮助
回答by Vicky
I think there might be an issue in setting up the executable property..
我认为设置可执行属性可能存在问题..
Set the executable property as below
设置可执行属性如下
File file = new File("C:/Seleniumjars/IEDriverServer.exe");
System.setProperty("webdriver.ie.driver", file.getAbsolutePath());
driver = new InternetExplorerDriver();
}
回答by abrakadabrda
- Check path to driver, click on driver by right button in IDE and copy path to folder
Try to change path to something like this (with backslashes):
System.setProperty("webdriver.chrome.driver", new File("C:\\QA\\neoAutomation\\src\\main\\resources\\drivers\\chromedriver.exe") .getAbsolutePath()); return new ChromeDriver(getCapabilities(browser));
- 检查驱动程序的路径,在IDE中右键单击驱动程序并将路径复制到文件夹
尝试将路径更改为这样的(带反斜杠):
System.setProperty("webdriver.chrome.driver", new File("C:\\QA\\neoAutomation\\src\\main\\resources\\drivers\\chromedriver.exe") .getAbsolutePath()); return new ChromeDriver(getCapabilities(browser));