How to debug your errors and be self sufficient

Watch this quick video

A project with an output Type of class library cannot be started directly

Error Message

A project with an output Type of class library cannot be started directly. In order to debug this project, add an executable project to this solution which references the library project. Set the executable project as the startup project.

Project with an output type of class library

Project with an output type of class library

The Problem

The problem is that you create a project as a type “Class Library” or “Unit Test Project” and are attempting to execute this project using the key F5, which means “Run”. You cannot run these types of projects in this manner. A unit test project must be executed using the Test Explorer of Visual Studio.

The Solution

Option 1: In your IDE, go to Test > Windows > Test Explorer. This will open up the Test Explorer. Right click the name of your unit test and then select “Run Selected Tests”.

Option 2: Place the cursor inside of your test method. Press Ctrl + R, T. This will run the test that has the cursor.

This free C# course will teach you how to correctly run the different kinds of projects.

 

A exception with a null response was thrown sending an HTTP request…

Error Message

A exception with a null response was thrown sending an HTTP request to the remote WebDriver server for URL http://localhost:19409/session/7114d633a2adbc5105f3f6c7abc7c596/url. The status of the exception was ConnectFailure, and the message was: Unable to connect to the remote server

InnerException

Unable to connect to the remote server

The Problem

You may have noticed that this page has one trend. Compatibility of Selenium WebDriver with a browser. This the largest burden in many of my behind, and has been for years now. This will probably continue until Selenium WebDriver is a W3C standard that is integrated into each browser. Until then, we will keep having these issues.

This error occurred to me with:

  • Chrome 55,56
  • ChromeDriver 2.27
  • Selenium WebDriver 3.0.1

The Solution

  1. Keep your Chrome browser version if it’s one of the above
  2. Downgrade your ChromeDriver to 2.26
    1. You might need to downgrade even more, all the versions are on this url

A exception with a null response was thrown sending an HTTP request to the remote…

Error Message

Similar to the error above, but it’s slightly different in wording and message.

Selenium.WebDriverException: ‘A exception with a null response was thrown sending an HTTP request to the remote WebDriver server for URL http://localhost:25675/session. The status of the exception was ReceiveFailure, and the message was: The underlying connection was closed: An unexpected error occurred on a receive.’

InnerException

Unable to connect to the remote server

The Problem

You may have noticed that this page has one trend. Compatibility of Selenium WebDriver with a browser. This the largest burden in many of my behind, and has been for years now. This will probably continue until Selenium WebDriver is a W3C standard that is integrated into each browser. Until then, we will keep having these issues.

This error occurred to me with:

  • Chrome 56
  • ChromeDriver 2.27
  • Selenium WebDriver 3.0.1.0

The Solution

  • Update your Chrome browser to version 57.0
  • This did the trick for me. Keep in mind that maybe your versions of browser and ChromeDriver may be different. However, if you receive this error, just upgrade your browser until it fits into the support matrix of ChromeDriver release logs.

Cannot find Firefox binary in PATH …

Error Message

OpenQA.Selenium.WebDriverException: Cannot find Firefox binary in PATH or default install locations. Make sure Firefox is installed. OS appears to be: Vista

The Problem

The Selenium Webdriver team is making updates to Selenium to prepare it for Selenium 3.0. Also, the Mozilla team is making changes to the Firefox architecture to support the in built capabilities for Selenium Webdriver. Therefore, working with the latest versions of Selenium Webdriver and Firefox is going to cause you some issues. At least for the next few months. I believe that a stable 3.0 version will be released by Christmas.

The Solution

You can use the versions that I show in the Complete Selenium Webdriver Course:

  • Selenium Webdriver v 2.51.0 – just be sure to select this version in Nuget Package Manager when downloading
  • Firefox v 39.0

Get old Firefox versions

With the above installed, everything in this course for you should work without problems.

If you want the latest and greatest of Selenium and a browser

You need to wait until the GeckoDriver is stable and can completely replace FirefoxDriver. Otherwise, use old version of FirefoxDriver or migrate to a different driver like ChromeDriver, which is most stable.

Conclusions

Until Selenium Webdriver 3.0, which will be part of the W3C standard for browsers, we will probably keep running into this issue. It’s inevitable under the circumstances. In the meantime, just stop updating your browsers, use the stable configuration of Firefox v39.0 with Selenium Webdriver v 2.51.0,  and enjoy the sweet taste of automation.

System.TypeInitializationException

System.TypeInitializationException: System.TypeInitializationException: The type initializer for ‘Framework.Browser’ threw an exception. —> OpenQA.Selenium.WebDriverException: Failed to start up socket within 45000 ms. Attempted to connect to the following addresses: 127.0.0.1:7055.

Or something like this?

 

OpenQA.Selenium.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

Today is your lucky day because I am going to help you resolve these really annoying errors!

The Problem

The problem is a standard compatibility issue between Selenium WebDriver and your version of a browser. As I am writing about this, the latest WebDriver version is 2.53.1. The latest Chrome version is 51.0 and the latest Firefox version is 46.0. Therefore, the Selenium WebDriver API does not get updated as often as Chrome or Firefox.

When different types of browsers such as Chrome or Firefox get updated, there is a chance that this update will break the Selenium API.

In our industry, this is known as a regression. Therefore, when you get the latest version of your browser, you may be using a Selenium WebDriver version that does not support the latest features of that browser. At this point, you will receive an ugly error that looks like this:

System.TypeInitializationException

Now, you will spend the next day wondering how your Selenium code used to work yesterday and today it just stopped working.

The Solution

Downgrade your appropriate browser to the version supported by the latest Selenium Driver. This might be Firefox, ChromeDriver, IEDriver and so on.

In this example I teach you how to downgrade Firefox.

An exception occurred while invoking executor ‘executor://mstestadapter/v2’ …

Error Message

This message is in your Output pane in “Output from Tests”.

An exception occurred while invoking executor ‘executor://mstestadapter/v2’: Constructor on type ‘Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution.UnitTestRunner’ not found.

The Symptoms

You are trying to run your Automation tests using MSTest, but they don’t run. They start going, but then Visual Studio just stops. When you check the Output pane, you see the message described above.

MSTest has a bug and needs an update. I had version 1.1.11 installed and it caused me this issue.

The Solution

  1. Using NuGet Package manager, update your MSTest.TestAdapter and MSTest.TestFramework NuGet packages to the latest version. I updated to 1.1.18.
  2. Restart Visual Studio
  3. Re-run your automation tests

System.InvalidOperationException : unknown error: Chrome version must be…

Error Message

System.InvalidOperationException : unknown error: Chrome version must be >= 54.0.2840.0

The Problem

Another issue with compatibility of ChromeDriver with Chrome Browser. In this case it was Chrome version 48.0 not working with ChromeDriver version 2.27

The Solution

Upgrade your Chrome browser to the version supported by ChromeDriver. For example, ChromeDriver 2.27 supports Chrome 54 – 56 according to their release notes.

Issues with Firefox and Selenium 3.0 Compatibility

Error Message

Nothing specific, if you see weirdness with Firefox and Selenium 3.0, this solution will probably work for you

The Problem

The #1 problem that people complain about is that their Firefox Driver doesn’t work with Selenium 3.0. I get this question about 72 times per day. Let me help.

The Selenium Webdriver team released Selenium 3.0. However, the Mozilla team is making changes to the Firefox architecture to support the in built capabilities for Selenium Webdriver. Therefore, working with the latest versions of Selenium Webdriver and Firefox is going to cause you some issues until the Firefox team finishes implementing Gecko Driver. By the way, you won’t be using Firefox driver any more.

The Solution

If you are starting to use Selenium Webdriver, your easiest route is to start by using Chrome Driver. You can use the latest version of Selenium and the latest version of Chrome Driver.

Don’t touch Gecko Driver (replacement of FirefoxDriver) until it is more mature. Otherwise, you’re bound to cause yourself problems.

Pin It on Pinterest

Shares
Share This