Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
471 views
in Technique[技术] by (71.8m points)

java - Driver executable must be set by the webdriver.ie.driver system property

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
  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:Seleniumiexploredriver.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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...