58

I am using Selenium for automating the tests. My application exclusively uses IE, it will not work on other Browsers.

Code:

import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

public class Test {
    public static void main(String[] args) {
        final String sUrl = "http://www.google.co.in/";                             
        System.setProperty("webdriver.chrome.driver","C:\\Users\\vthaduri\\workspace\\LDCSuite\\IEDriverServer.exe");
        WebDriver oWebDriver = new InternetExplorerDriver();
        oWebDriver.get(sUrl);
        WebElement oSearchInputElem = oWebDriver.findElement(By.name("q")); // Use name locator to identify the search input field.
        oSearchInputElem.sendKeys("Selenium 2");
        WebElement oGoogleSearchBtn = oWebDriver.findElement(By.xpath("//input[@name='btnG']"));  
        oGoogleSearchBtn.click();

        try {
            Thread.sleep(5000);
        } catch(InterruptedException ex) {
            System.out.println(ex.getMessage());
        }
        oWebDriver.close();
    }    
}

And here is the error I am getting

The path to the driver executable must be set by the webdriver.ie.driver system property; for more information, see https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver. The latest version can be downloaded from http://www.seleniumhq.org/download/ Jun 12, 2012 4:18:42 PM org.apache.http.impl.client.DefaultRequestDirector tryExecute INFO: I/O exception (java.net.SocketException) caught when processing request: Software caused connection abort: recv failed Jun 12, 2012 4:18:42 PM org.apache.http.impl.client.DefaultRequestDirector tryExecute

Can someone help me on this?

Ringil
  • 5,517
  • 2
  • 21
  • 32
vkrams
  • 6,227
  • 17
  • 67
  • 113
  • 2
    Not sure why I can't post an answer for this, but you can also get around this by specifying the folder location within the PATH Environment value on the machine in question. This is handy should you want to or have to have the files stored in different places on different machines in different environments – MorkPork Apr 08 '14 at 14:14
  • Replace the line System.setProperty("webdriver.chrome.driver","C:\\Users\\vthaduri\\workspace\\LDCSuite\\IEDriverServer.exe"); by System.setProperty("webdriver.ie.driver","C:\\Users\\vthaduri\\workspace\\LDCSuite\\IEDriverServer.exe"); – Ripon Al Wasim Apr 28 '16 at 11:40
  • You have set property for chrome instead of IE. this is only the problem – Ripon Al Wasim Apr 28 '16 at 11:41

5 Answers5

73
  1. You will need InternetExplorer driver executable on your system. So download it from the hinted source (http://www.seleniumhq.org/download/) unpack it and place somewhere you can find it. In my example, I will assume you will place it to C:\Selenium\iexploredriver.exe

  2. Then you have to set it up in the system. Here is the Java code pasted from my Selenium project:

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

Basically, you have to set this property before you initialize driver

Ringil
  • 5,517
  • 2
  • 21
  • 32
Pavel Janicek
  • 12,577
  • 12
  • 47
  • 76
  • Side note - I am using Chrome, so the code will probably need some tweaks to it. Especially the init part of IE – Pavel Janicek Jun 12 '12 at 12:09
  • I have already added the code in my program. Look at my code in the question. But I am not sure how to get rid of System.setProperty("webdriver.chrome.driver","C:\\Users\\vthaduri\\workspace\\LDCSuite\\IEDriverServer.exe"); WebDriver oWebDriver = new InternetExplorerDriver(); – vkrams Jun 12 '12 at 12:26
  • 1
    just replace the `webdriver.chrome.driver` with `webdriver.ie.driver`and it should work – Pavel Janicek Jun 12 '12 at 12:39
  • My code: File file = new File("F:\\SoftwareDownload_Ripon\\WebDriver\\IEDriverServer_Win32_2.24.2\\IEDriverServer.exe"); System.setProperty("webdriver.ie.driver", file.getAbsolutePath()); WebDriver driver = new InternetExplorerDriver(); It works but the error is: INFO: I/O exception (org.apache.http.NoHttpResponseException) caught when processing request: The target server failed to respond org.openqa.selenium.remote.UnreachableBrowserException: Error communicating with the remote browser. It may have died. What’s the way to solve the problem? – Ripon Al Wasim Jul 03 '12 at 10:50
  • Ripon - maybe write another question. Its hard to read from comment what you wanted to do – Pavel Janicek Jul 09 '12 at 06:58
  • On my machine I had to start the IE driver server on a port and register it to Remoteweb Driver, then it worked. Merely setting the web driver path was not helping me. – Khushboo May 20 '15 at 13:08
13

The error message says

"The path to the driver executable must be set by the webdriver.ie.driver system property;"

You are setting the path for the Chrome Driver with "webdriver.chrome.driver" property. You are not setting the file location when for InternetExplorerDriver, to do that you must set "webdriver.ie.driver" property.

You can set these properties in your shell, via maven, or your IDE with the -DpropertyName=Value

-Dwebdriver.ie.driver="C:/.../IEDriverServer.exe" 

You need to use quotes because of spaces or slashes in your path on windows machines, or alternatively reverse the slashes other wise they are the string string escape prefix.

You could also use

System.setProperty("webdriver.ie.driver","C:/.../IEDriverServer.exe"); 

inside your code.

Martin Spamer
  • 5,180
  • 26
  • 44
  • 1
    Yes, this is the wrong. You have written the code as: System.setProperty("webdriver.chrome.driver","C:\\Users\\vthaduri\\workspace\\LDCSuite\\IEDriverServer.exe"); Please use "webdriver.chrome.driver" instead of "webdriver.chrome.driver" – Ripon Al Wasim Jul 11 '12 at 10:44
2

I just put the driver files directly into my project to not get any dependency to my local machine.

final File file = new File("driver/chromedriver_2_22_mac");
System.setProperty("webdriver.chrome.driver", file.getAbsolutePath());

driver = new ChromeDriver();
feed.me
  • 343
  • 2
  • 11
1

For spring :

File inputFile = new ClassPathResource("\\chrome\\chromedriver.exe").getFile();
System.setProperty("webdriver.chrome.driver",inputFile.getCanonicalPath());
xyz
  • 21,367
  • 33
  • 107
  • 150
Ran Adler
  • 3,083
  • 25
  • 26
0

You will need have to download InternetExplorer driver executable on your system, download it from the source (http://code.google.com/p/selenium/downloads/list) after download unzip it and put on the place of somewhere in your computer. In my example, I will place it to D:\iexploredriver.exe

Then you have write below code in your eclipse main class

   System.setProperty("webdriver.ie.driver", "D:/iexploredriver.exe");
   WebDriver driver = new InternetExplorerDriver();
alex
  • 438,662
  • 188
  • 837
  • 957
Ankit jain
  • 3,918
  • 3
  • 17
  • 24