6

I am trying to run the following code on my machine (win XP & 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 which i was provided is

java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.ie.driver system property; 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:159) at bookie.setUp(bookie.java:19) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java: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.evaluate(ParentRunner.java:229) at org.junit.runners.ParentRunner.run(ParentRunner.java:309) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)

Ripon Al Wasim
  • 36,924
  • 42
  • 155
  • 176
LeonarD
  • 159
  • 2
  • 6
  • 10
  • Since you have not specified an *exact* path for the IEDriver, it's going to look in your PATH variable and probably the current working directory. I'd also advise to remove the instability settings you've set. – Arran Jan 24 '14 at 09:26
  • Thankyou so much for your response Arran.. Everything is working fine now.. but still i would like to study/understand things more closely. so.. I understood most of what u said.. except for the "instability settings" part. would u please elaborate.. m a newbie.. – LeonarD Jan 27 '14 at 04:38
  • possible duplicate of [Driver executable must be set by the webdriver.ie.driver system property](http://stackoverflow.com/questions/10995314/driver-executable-must-be-set-by-the-webdriver-ie-driver-system-property) – Sebastian Jul 21 '14 at 10:47

2 Answers2

3

Place the driver in some location like 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 line should be first line of setUp() function

System.setProperty("webdriver.ie.driver", "IEDriverServer.exe");   
A Paul
  • 8,113
  • 3
  • 31
  • 61
  • the driver I have is IEDriverServer.exe so i inserted that but then on executing the code, 2 IE windows are opening, none related to base url. and the console reads : INFO: Retrying request Started InternetExplorerDriver server (32-bit) 2.39.0.0 Listening on port 33671 Jan 24, 2014 12:06:00 PM org.apache.http.impl.client.DefaultRequestDirector tryExecute INFO: I/O exception(org.apache.http.NoHttpResponseException) caught when processing request: The target server failed to respond Jan 24, 2014 12:06:00 PM org.apache.http.impl.client.DefaultRequestDirector tryExecute INFO: Retrying request – LeonarD Jan 24 '14 at 06:39
2

Similar to the above solution but with Desired Capabilities

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);
Andrew Barber
  • 39,603
  • 20
  • 94
  • 123
Prashanth Sams
  • 19,677
  • 20
  • 102
  • 125