Selenium shows java.net.SocketException: Connection reset

I have searched for the solution but I have not found the solution I always get this error

codigo :

public static void main(String [] args) {

          System.setProperty("webdriver.chrome.driver","C:\\Users\\Ofima\\workspace\\OfimaWeb\\chromedriver.exe");  
          WebDriver driver= new ChromeDriver();
          driver.get("http://ofimawebbeta.ofima.com/");
          driver.manage().window().maximize();
          driver.getTitle();
      }

Error :

Starting ChromeDriver (v2.9.248315) on port 41785
ene 19, 2018 9:48:49 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFORMACIÓN: Detected dialect: OSS
Exception in thread "main" org.openqa.selenium.WebDriverException: java.net.SocketException: Connection reset
Build info: version: '3.8.0', revision: '924c4067df', time: '2017-11-30T11:37:19.049Z'
System info: host: 'PCPOF-021', ip: '10.72.4.128', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_151'
Driver info: driver.version: RemoteWebDriver
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:92)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)
    at org.openqa.selenium.remote.RemoteWebDriver.get(RemoteWebDriver.java:325)
    at OfimaWeb.cartera.main(cartera.java:23)
Caused by: java.net.SocketException: Connection reset

Upvotes: 2

Views: 54501

Answers (4)

Krishnendu Das
Krishnendu Das

Reputation: 11

Use driver.quit() method and it will be solved.

Explaination: The rootcasue of this error is that the socket is not closed properly. Websocket is still open so when we are executing this class step definition then it won't get the socket when you are closing it and will throw the error. So, just use driver.quit() method and error will be gone.

enter image description here

Upvotes: 0

Arghya Paul
Arghya Paul

Reputation: 1

Use driver.quit() instead of driver.close()

Upvotes: 0

undetected Selenium
undetected Selenium

Reputation: 193108

The error does gives us some hint as follows :

org.openqa.selenium.WebDriverException: java.net.SocketException: Connection reset

Which essentially implies that ChromeDriver binary is unable to spawn a new Chrome Browser process.

Your main issue is the version compatibility among the binaries you are using as follows:

  • You are using ChromeDriver v2.9 (released 2014-01-31)
  • Release Notes of ChromeDriver v2.9_ clearly mentions the following :

Supports Chrome v31-34

  • You mentioned of using latest Chrome. I suppose it is chrome=65.x
  • You are using Selenium Version 3.8.0 (released 2017-11-30T11:37:19.049Z) [as per the error stack trace within your question]

So there is a clear mismatch between requirement for ChromeDriver v2.9 and the Chrome Browser version you are using. Hence ChromeDriver is unable to spawn the new Chrome Browser process.


Solution

  • Update ChromeDriver to current v2.35 level.
  • Downgrade Chrome to stable Chrome v64.x levels. (as per ChromeDriver v2.35 release notes)
  • Upgrade Selenium to current levels Version 3.8.1.
  • Clean and Re-Build your project through your IDE.
  • Clear the Browser Cache
  • Use CCleaner tool to wipe off all the OS chores.
  • If your Web Browser base version is too old, uninstall the Web Browser through Revo Uninstaller with Moderate Scan and install a recent GA Released version of the Web Browser.

  • Execute your @Test.

Upvotes: 4

hiren
hiren

Reputation: 1105

Download ChromeDriver from

http://chromedriver.storage.googleapis.com/index.html?path=2.33/

This ChromeDriver shall work with your version of Google Chrome.

Upvotes: 0

Related Questions