Selenium WebDriver tests fail with System.Net.WebException Unable to connect Selenium WebDriver tests fail with System.Net.WebException Unable to connect selenium selenium

Selenium WebDriver tests fail with System.Net.WebException Unable to connect


The issue here was that in trying to implement some more robust error handling during startup I place a call to the Teardown code in the finally block of a try/catch wrapped around the login code, so as soon as the test harness was done logging in I was closing and cleanin up the WebDriver instance, so when the test ran there wasn't a WebDriver there to communicate with.

I suspect when I as looking at the "same" code on my dev machine the libraries that were actually running didn't have that block in them.


When you run an application from Visual Studio it fires up a server listening on a certain port. In your case 59982.

You need to actually have your web application running on its own on the test environments before running your test against it.

On your dev machine your application is running on that port. I'm guessing on your remote machines that is not the case.