How to set the path for executable IE drivers in Selenium WebDriver

I am trying to run the following code on my machine (win XP and IE8)

public class bookie { private WebDriver driver; private String baseUrl; private boolean acceptNextAlert = true; private StringBuffer verificationErrors = new StringBuffer(); @Before public void setUp() throws Exception { DesiredCapabilities caps = DesiredCapabilities.internetExplorer(); caps.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,true); driver = new InternetExplorerDriver(caps); baseUrl = "http://book.theautomatedtester.co.uk/"; driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); } @Test public void testbookie() throws Exception { System.setProperty("webdriver.ie.driver", "IEDriverServer.exe"); driver.get(baseUrl + "/"); driver.findElement(By.linkText("Chapter1")).click(); driver.findElement(By.id("radiobutton")).click(); new Select(driver.findElement(By.id("selecttype"))).selectByVisibleText("Selenium Core"); driver.findElement(By.linkText("Home Page")).click(); driver.findElement(By.linkText("Chapter2")).click(); driver.findElement(By.id("but1")).click(); driver.findElement(By.xpath("//input[@value='Sibling Button']")).click(); driver.findElement(By.linkText("Index")).click(); driver.findElement(By.linkText("Chapter1")).click(); new Select(driver.findElement(By.id("selecttype"))).selectByVisibleText("Selenium Grid"); driver.findElement(By.linkText("Home Page")).click(); driver.quit(); } 

But the stack trace I provided is

java.lang.IllegalStateException: the path to the driver executable file must be set using the webdriver.ie.driver property; in org.openqa.selenium.remote.service.DriverService.findExecutable (DriverService.java:105) in org.openqa.selenium.ie.InternetExplorerDriverService.access $ 1 (InternetExplorerDriverService.java:1) in org.openqase. InternetExplorerDriverService $ Builder.build (InternetExplorerDriverService.java:230) at org.openqa.selenium.ie.InternetExplorerDriver.setupService (InternetExplorerDriver.java:263) at org.openqa.selenium.ie.InternetExplorer (InternetExplorerDriver.java:182) at org.openqa.selenium.ie.InternetExplorerDriver. (InternetExplorerDriver.java:159) on bookie.setUp (bookie.java:19) at sun.reflect.NativeMethodAccessorImpl.invoke0 (native method) at sun.reflect.NativeMethodAccessorImpl.invoke (Unknown source) at sun.reflect.DelegatingMethododethethinethplodethethinethethodethethinethethod (Unknown source) in java.lang.reflect.Method.invoke (Unknown source) in org.junit.runners.model.FrameworkMethod $ 1.runReflectiveCall (FrameworkMethod.java:47) in org.junit.internal.runners.model.ReflectiveCallable .run (ReflectiveCallable.java:12) in org.junit.runners.model.FrameworkMethod.invokeExplosively (FrameworkMethod.java:44) in org.junit.internal.runners.statements.RunBefores.evaluate (RunBefores.java:24) in org.junit.internal.runners.statements.RunAfters.evaluate (RunAfters.java:27) at org.junit.runners.ParentRunner.runLeaf (ParentRunner.java:271) at org.junit.runners.BlockJUnit4ClassRunner.ununlunChunner java: 70) in o rg.junit.runners.BlockJUnit4ClassRunner.runChild (BlockJUnit4ClassRunner.java:50) at org.junit.runners.ParentRunner $ 3.run (ParentRunner.java:238) at org.junit.runners.ParentRunnerjava $ 1. 63) at org.junit.runners.ParentRunner.runChildren (ParentRunner.java:236) at org.junit.runners.ParentRunner.access $ 000 (ParentRunner.java:53) at org.junit.runners.ParentRunner $ 2.valuation (ParentRunner .java: 229) in org.junit.runners.ParentRunner.run (ParentRunner.java.309) in org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run (JUnit4TestReference.java:38) in org.eclipse. jdt.internal.junit.runner.TestExecution.run (TestExecution.java:38) in org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests (RemoteTestRunner.java:460) in org.eclipse.jdt.internal. junit.runner.RemoteTestRunner.runTests (RemoteTestRunner.java:673) in org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run (RemoteTestRunner.javahaps86) in org.eclipse.jdt.inrunner. Remot eTestRunner.main (RemoteTestRunner.java:196)

+6
source share
2 answers

Place the driver in some place, for example C: \ Selenium \ iexploredriver.exe

Then

 File file = new File("C:/Selenium/iexploredriver.exe"); System.setProperty("webdriver.ie.driver", file.getAbsolutePath()); WebDriver driver = new InternetExplorerDriver(); 

Below the line should be the first line of the setUp () function

 System.setProperty("webdriver.ie.driver", "IEDriverServer.exe"); 
+2
source

As in the previous solution, but with the desired features

 System.setProperty("webdriver.ie.driver","C:\\IEDriverServer.exe"); DesiredCapabilities dc = DesiredCapabilities.internetExplorer(); dc.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true); //If IE fail to work, please remove this and remove enable protected mode for all the 4 zones from Internet options WebDriver driver = new InternetExplorerDriver(dc); 
+2
source

All Articles