Question

While launching IE from Selenium Webdriver following error is shown:

Exception in thread "main" java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.ie.driver system property. 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:263) at org.openqa.selenium.ie.InternetExplorerDriver.(InternetExplorerDriver.java:182) at org.openqa.selenium.ie.InternetExplorerDriver.(InternetExplorerDriver.java:155)

Code used :

  public class Browser {
    public static void main(String[] args) {
    WebDriver obj = new InternetExplorerDriver();
    System.getProperty("webdriver.ie.driver", "D:\\Eclipse Workspace\\Multi Browser\\IEDriverServer.exe");
    obj.get("http://www.google.com/");
    obj.close();
  }
Was it helpful?

Solution

InternetExplorerDriver object should be created after the webdriver.ie.driver property is set. Similarly for chrome.

Also, the referenced code uses getProperty(), whereas you need to use setProperty() to actually set it.

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

WebDriver obj = new InternetExplorerDriver();
obj.get("http://www.google.com/");
obj.close();

OTHER TIPS

You have to use setProperty() function. Basically, you have to set this property before you initialize driver. But you are using getProperty().

Here is the sample Java code:

public class IE {

    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub

            System.setProperty("webdriver.ie.driver", "D:\\SATHISH\\SOFTWARES\\SELENIUM\\IEDriverServer.exe");
            WebDriver driver = new InternetExplorerDriver();
            driver.get("www.google.com");
            driver.findElement(By.id("gbqfq")).sendKeys("abc");
            driver.close();

    }

}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top