selenium: [🐛 Bug]: Unexpected error creating WebSocket DevTools session calling GetDevToolsSession with v4.0.0 C# bindings and Selenium Server

What happened?

When I execute a new RemoteWebDriver in C# against a Selenium 4.0.0 server running locally on the same computer and Chrome v94 the call to GetDevToolsSession() throws an unexpected exception as follows …

{"Unexpected error creating WebSocket DevTools session."}

How can we reproduce the issue?

Within a project in Visual Studio Professional 2015 (other versions untested) ensure the NuGet package Selenium.WebDriver v4.0.0 is installed and the Target framework of the project is .NET Framework 4.7.

Create a program with the following code …

using OpenQA.Selenium.Chrome;
using OpenQA.Selenium;

ChromeOptions options = new ChromeOptions();
IWebDriver driver = new RemoteWebDriver(new Uri("http://localhost:4444"), options.ToCapabilities());
var devTools = driver.GetDevToolsSession();

Ensure the Selenium server selenium-server-4.0.0.jar exists on the computer. Ensure java is installed (version 1.8.0_231 tested).

Start the Selenium server with the following command in a CLI …

"<path to java>\java.exe" -Xmx128m -jar <path to selenium server>\selenium-server-4.0.0.jar standalone

Run the program above in Debug mode in Visual Studio. Execution of the GetDevToolsSession call above will trigger the exception … mentioned above.

Expected behavior

It is expected that the call to GetDevToolsSession is successful (no exception).

Have tested this call (using the code above) with the Selenium.WebDriver v4.0.0 NuGet package in combination with Selenium Server v4.0.0 Release Candidate 3 and is successful.

Selenium.WebDriver v4.0.0 NuGet package in combination with Selenium Server v4.0.0 (not Release Candidate 3) is however unsuccessful (as per bug report above).

I have also tried the Selenium 4.0.0 server and RemoteWebDriver with Chrome 93 and experience a different exception.

Have also tried to use Chrome 95 though this was in beta at the time and I could not understand how to configure the “binary” attribute of the “stereotype” parameter in the Selenium Grid (TOML) config file to successfully point to the local path for Chrome Beta on my PC.

Operating System

Windows 10

Selenium version

4.0.0

What are the browser(s) and version(s) where you see this issue?

Chrome 94.0.4606.61

What are the browser driver(s) and version(s) where you see this issue?

ChromeDriver 94.0.4606.61

Are you using Selenium Grid?

4.0.0

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15 (3 by maintainers)

Most upvoted comments

We are using .Net core 5.0. All test run fine locally. We are running all test via remote Jenkins and they are failing the last 2 days. All tests ran without issue prior to 5/5/2022

OpenQA.Selenium.WebDriverException : Unexpected error creating WebSocket DevTools session. ----> System.NullReferenceException : Object reference not set to an instance of an object.

What is the solution or workaround for this issue?

We are facing the same issue (running .NET core 6) All the tests run fine on our local machine, but once running in an Azure Devops VM, the are failing (they were running fine until a couple of days ago)

Is there any workaround to solve this issue ?

Initialization method WebTests.ChromeDriverInitialize threw exception. OpenQA.Selenium.WebDriverException: Unexpected error creating WebSocket DevTools session. —> System.NullReferenceException: Object reference not set to an instance of an object…