0
votes

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();
  }
2
Check your browser version; is that 25+? Also, your driver should be located properly C://chromedriver.exe - Prashanth Sams
Yes its 33.xx. So the resolution is in downgrading chrome ? Chromedriver is added in project folder so no problem there. - Shubham Jaiswal
Yes try to downgrade and check the same - Prashanth Sams
But what about the path mention in code.google.com/p/selenium/wiki/ChromeDriver which says chrome should be in App Data ? - Shubham Jaiswal
I would go with @PrashanthSams suggestion, put the driver in an actual folder and reference it explicitly in the webdriver.chrome.driver property. It's the reason for your error, nothing to do with Chrome's location. - Arran

2 Answers

2
votes

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

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

    }

}