Dinu
Dinu

Reputation: 933

I/O Exception and Unable to find element In IE using Selenium Webdriver

The below code works fine with Firefox and chrome but shows errors when executed in 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");

The error displayed is 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:

Upvotes: 2

Views: 9306

Answers (4)

Gio
Gio

Reputation: 9

Configuring enable protected mode (Internet, Local Intranet, Trusted sites, Restricted sites), in the four options was enough for me.

Upvotes: 0

Dinu
Dinu

Reputation: 933

The problem was with my IE settings. The problem was resolved when the security settings in IE was changed to "Enable Protected Mode" for "Internet", "Local Intranet", "Trusted Sites" and "Restricted Sites". You can change it by going to Internet Options security tab and enable check box "Enable Protected Mode" for all the zones. I was able to get these information from the link http://jimevansmusic.blogspot.in/2012/08/youre-doing-it-wrong-protected-mode-and.html

Upvotes: 8

barak manos
barak manos

Reputation: 30136

Please review the following Python code (should by similar for Java):

from selenium import webdriver

def findElement(browser):
    browser.get("https://www.google.co.in/?gws_rd=cr&ei=ZDziUrLDEuLpiAeD44H4BA")
    element = browser.find_element_by_name("q")
    return element.get_attribute("outerHTML")

ieBrowser = webdriver.Ie()
print "IE: "+findElement(ieBrowser)

ffBrowser = webdriver.Firefox(firefox_profile=webdriver.FirefoxProfile())
print "FF: "+findElement(ffBrowser)

The output of the code above is:

IE: <input id="lst-ib" class="lst lst-tbb" title="חיפוש" name="q" maxLength="2048" value="" size="41" type="text" autocomplete="off">

FF: <input spellcheck="false" dir="ltr" style="border: medium none; padding: 0px; margin: 0px; height: auto; width: 100%; background: url(&quot;data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw%3D%3D&quot;) repeat scroll 0% 0% transparent; position: absolute; z-index: 6; left: 0px; outline: medium none;" id="gbqfq" class="gbqfif" name="q" autocomplete="off" value="" type="text">

So I am able to find the element you're looking for in both browsers (using Selenium v2.39.00).

Upvotes: 0

Amith
Amith

Reputation: 7008

you can try waiting for the element to be visible with Explicit wait,

new WebDriverWait(driver,60).until(ExpectedConditions.visibilityOfElementLocated(By.id("gbqfq"))).sendKeys("Selenium");

Upvotes: 0

Related Questions