下面的代码在 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");
显示的错误是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:
最佳答案
问题出在我的 IE 设置上。当 IE 中的安全设置更改为“Internet”、“本地 Intranet”、“受信任站点”和“受限站点”的“启用保护模式”后,问题得到解决。您可以通过转到“Internet 选项”安全选项卡并为所有区域启用“启用保护模式”复选框来更改它。我能够从链接 http://jimevansmusic.blogspot.in/2012/08/youre-doing-it-wrong-protected-mode-and.html 获取这些信息
关于java - I/O 异常并且无法使用 Selenium Webdriver 在 IE 中找到元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21330079/