2

I've been battling the following error over the past few weeks trying to run UI tests with Selenium (Chrome 92):

WebDriverException unknown error: net::ERR_CONNECTION_RESET. (Session info: chrome=92.0.4515.107)

This occurs most often trying to locate HTML elements using XPath.

Originally, I added a retry loop which checks if the WebDriverException is thrown three times, and if so, recycle the IWebDriver and try again (via IWebDriver.Quit() and IWebDriver.Dispose(). This does not fix the problem, nor does having my application restart after exceeding the retry limit. Thus, I'm starting to think this is a problem at the system-level (Windows Server 2016). Even a reboot does not always fix the issue - when it starts to fail, it just totally freezes and I end up having to completely rebuild the environment.

I'm using the Selenium WebDriver NuGet v92.0.4515.4300; I realize this isn't in total parity with the version listed above, but having the exact same versions does not fix the problem.

I know 'unknown error' is vague. Does anyone have suggestions for what could be causing the problem?

Thanks in advance.

EDIT: Posting browser arguments here, rather than cramming them into a comment. I forgot to mention, there is an instance of Fiddler which we run as a proxy on the local system and use in conjunction with some tests. It's started and ended with the testing application.

The following are injected as options when creating the Chrome instance:

  • --user-data-dir=C:\temp\{uniquedir}
  • options.AddUserProfilePreference("credentials_enable_service", false);
  • options.AddUserProfilePreference("profile.password_manager_enabled", false);

And these are added as command-line arguments through Selenium:

  • --lang=en-GB
  • --ignore-certificate-errors
  • --no-experiments
  • --disable-translate
  • --disable-plugins
  • --enable-logging
  • --no-sandbox
  • --dns-prefetch-disable
  • --disable-gpu
  • --disable-field-trial-config

(We are doing some security-related detections, hence the disabling of certificate errors.)

Cory Gehr
  • 105
  • 1
  • 7
  • Can see this if you are using a proxy server, or sometimes if you run the driver headless. Can you post your driver arguments? – K. B. Aug 17 '21 at 19:33
  • @K.B. Thanks for your reply - I added them as an edit to the original post since they're likely going to be relevant and won't fit in this space. And, there is a proxy. – Cory Gehr Aug 17 '21 at 20:01
  • For me most suspicious is Fiddler proxy. Is the error reproducible if Fiddler is stopped? – K. B. Aug 18 '21 at 05:28
  • It's an old code base so it's taking me a bit of time to refactor and replace things which required the proxy to accomplish. I can report back with more as soon as I've finished and tested. I would generally agree with you though, but it's strange that this started acting up as we've moved to newer Chrome versions (v86 had no issues). – Cory Gehr Aug 18 '21 at 15:55

1 Answers1

2
  1. You mentioned that you use Fiddler, if the issue is reproducible only when it is started, you can try to regenerate the HTTPS certificates
  2. The issue can be due to the application itself. If the error is shown when you are not using Selenium/ChromeDriver you can ask your developers/devops to check the IIS settings or follow one of the suggestions below.
  3. Check your Internet options from computer Settings->Network&Internet->Proxy. On my computer "Automatically detect Settings" is enabled.
  4. You can also try to delete the Chrome browser cache.
  5. Flush the DNS (ipconfig /flushdns)
  6. It could be some rule (firewall, internal DNS record) configured for the network where is your Windows Server.
  7. Check if the issue is reproducible in incognito mode (without any browser extensions enabled). You can pass --incognito argument when starting the driver.
  8. Issue could be caused by a certificate or SSL/TLS problem.
K. B.
  • 3,342
  • 3
  • 19
  • 32
  • 1
    Thanks! The good news: it looks like avoiding proxy use has eliminated most occurrences of this error. However, I still get the occasional connection refused error `WebDriverException Unexpected error. System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it.` It's probably not related to the above. I'm seeing significantly less exceptions now so I'm happier with where I'm at. – Cory Gehr Aug 18 '21 at 21:17
  • 1
    "No connection could be made because the target machine actively refused it" - > I have seen this when network rule blocked traffic from one IP/network segment to another IP. But it was reproducible always, not occasionally. – K. B. Aug 19 '21 at 06:21