简体   繁体   中英

Unable to run Selenium WebDriver tests with Internet Explorer Driver

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

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)

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

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;

@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 blog has some selenium junit tutorials.You can also search many tutorials using google.com :D

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

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

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();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM