How to Resolve SocketException In Selenium for Internet Explorer and Chrome

Many a times we get the below written Socket exception in Selenium. I am giving a sample stack trace.It happens mostly with IE and Chrome.


Listening on port 36550
Nov 22, 2014 5:02:14 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
Nov 22, 2014 5:02:14 PM org.apache.http.impl.client.DefaultRequestDirector tryExecute
INFO: Retrying request
Exception in thread "main" org.openqa.selenium.remote.SessionNotFoundException: Unable to get browser (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 16 milliseconds
Build info: version: '2.41.0', revision: '3192d8a', time: '2014-03-27 17:18:15'
System info: host: 'LQA1008', ip: '192.168.1.104', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.7.0_55'
Session ID: 06ab6b34-1bd4-4ee6-979c-76e4fc741458

The issue is Session could not find the URL triggered using the method driver.get("") due to initial proxy URL (Ex: http://localhost/portNumber).
so we need to use driver.get method in a different manner. How lets see in the below section:
File file =new File("C:\\Users\\Susanth\\lib\\IEDriverServer64.exe");
System.setProperty("webdriver.ie.driver", file.getAbsolutePath());
DesiredCapabilities cap= new DesiredCapabilities();
cap.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
cap.setCapability("initialBrowserUrl", URL);    
cap.setJavascriptEnabled(true);
driver=new InternetExplorerDriver(cap);

Also if you don't want to use INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS , then check this blog-http://jimevansmusic.blogspot.com/2012/08/youre-doing-it-wrong-protected-mode-and.html?m=1
How to Resolve SocketException In Selenium for Internet Explorer and Chrome How to Resolve SocketException In Selenium for Internet Explorer and Chrome Reviewed by Animesh Chatterjee on November 24, 2014 Rating: 5

No comments:

Powered by Blogger.