java 无法使用 Internet Explorer 驱动程序运行 Selenium WebDriver 测试

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26398421/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-02 09:51:57  来源:igfitidea点击:

Unable to run Selenium WebDriver tests with Internet Explorer Driver

javainternet-explorerseleniumselenium-webdriver

提问by Rakesh kumar Swain

I encountered an error like below in the console tab during run my selenium tests using Java.

在使用 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(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)

回答by Sai Ye Yan Naing Aye

You need to setup InternetExplorerDriveron your pc.Download from this placeand unzip IEDriverServer.zip as you like.Place is in your pc PATH.See more detail from here.

你需要设置InternetExplorerDriver您pc.Download从这个地方和解压IEDriverServer.zip你like.Place是在你的电脑PATH。看到从更详细的在这里

If you use selenium web driver with JUnit or some other testing framework, you need to setup InternetExplorerDriver path into your code.See my JUnit sample setup;

如果您将 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);
}

This bloghas some selenium junit tutorials.You can also search many tutorials using google.com :D

这个博客有一些 selenium junit 教程。你也可以使用 google.com 搜索许多教程:D

回答by Bhaba

You have to set the property before hand.

您必须事先设置该属性。

System.setProperty("webdriver.ie.driver", "D:\Eclipse  Workspace\MultiBrowser\IEDriverServer.exe");

WebDriver obj = new InternetExplorerDriver();

obj.get("http://www.google.com/");

obj.close();

回答by Dev Raj

Make sure you set path for the IE driver. Before that you need to download IE Driver from SeleniumHQ website. you can download it from below link Seleniumhq download

确保为 IE 驱动程序设置路径。在此之前,您需要从 SeleniumHQ 网站下载 IE 驱动程序。你可以从下面的链接下载 Seleniumhq 下载

System.setProperty("webdriver.ie.driver","path/chromedriver.exe");
WebDriver driver = new InternetExplorerDriver();