以下代码适用于Firefox和Chrome,但在IE中执行时显示错误.
System.setProperty("webdriver.ie.driver", "G:\\Selenium\\IEDriver\\IEDriverServer.exe");
WebDriver driver=new InternetExplorerDriver();
driver.get("https://www.google.co.in/?gws_rd=cr&ei=ZDziUrLDEuLpiAeD44H4BA");
driver.findElement(By.name("q")).sendKeys("Selenium");
Run Code Online (Sandbox Code Playgroud)
显示的错误是 I/O exception (java.net.SocketException) caught when processing request: Software caused connection abort: recv failed
Jan 24, 2014 3:44:04 PM org.apache.http.impl.client.DefaultRequestDirector tryExecute
INFO: Retrying request
Exception in thread "main" org.openqa.selenium.NoSuchElementException: