在使用Java运行我的selenium测试期间,我在控制台选项卡中遇到如下错误。
Exception in thread "main" java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.ie.driver system property; for more information, see http://code.google.com/p/selenium/wiki/InternetExplorerDriver. The latest version can be downloaded from http://selenium-release.storage.googleapis.com/index.html
at com.google.common.base.Preconditions.checkState(Preconditions.java:177)
at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:105)
at org.openqa.selenium.ie.InternetExplorerDriverService.access$1(InternetExplorerDriverService.java:1)
at org.openqa.selenium.ie.InternetExplorerDriverService$Builder.build(InternetExplorerDriverService.java:230)
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 superadminmodule.LoginInPage.main(LoginInPage.java:11)
答案 0 :(得分:3)
您需要在电脑上设置 InternetExplorerDriver 。从此place下载并根据需要解压缩IEDriverServer.zip.Place在您的电脑PATH。查看更多详情来自here。
如果您将selenium Web驱动程序与JUnit或其他测试框架一起使用,则需要在代码中设置InternetExplorerDriver路径。请参阅我的JUnit示例设置;
@Before
public void setUp() throws Exception {
File file = new File("C:\\IEDriverServer\\IEDriverServer.exe");
System.setProperty("webdriver.ie.driver", file.getAbsolutePath());
driver = new InternetExplorerDriver();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
这个blog有一些selenium junit教程。你也可以使用google.com搜索很多教程:D
答案 1 :(得分:0)
确保为IE驱动程序设置路径。在此之前,您需要从SeleniumHQ网站下载IE驱动程序。您可以从以下链接 Seleniumhq download
下载System.setProperty("webdriver.ie.driver","path/chromedriver.exe");
WebDriver driver = new InternetExplorerDriver();
答案 2 :(得分:0)
您必须事先设置属性。
System.setProperty("webdriver.ie.driver", "D:\\Eclipse Workspace\\MultiBrowser\\IEDriverServer.exe");
WebDriver obj = new InternetExplorerDriver();
obj.get("http://www.google.com/");
obj.close();