question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
lcopecommented, May 6, 2022

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?

1reaction
bartdk-becommented, May 6, 2022

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…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Change log - GitHub
NET bindings. By casting a driver instance to IDevTools, users can now create sessions to use CDP calls for Chromium-based browsers. The DevTools...
Read more >
Using DevTools features with Selenium Grid on Docker
In order to investigate it, I installed a local grid with one Chrome node using docker-compose and I got the same error: OpenQA.Selenium....
Read more >
Eclipse Jetty: Programming Guide
The Eclipse Jetty libraries provide the client-side and server-side APIs to work with various web protocols such as HTTP/1.1, HTTP/2, HTTP/3, ...
Read more >
WebSocket close event (onclose) not fired until timeout if ...
close() so Chrome sends a WS CLOSE Frame. 4. The server replies with its own WS CLOSE Frame but it does NOT send...
Read more >
python-websockets(1) - Arch manual pages
You cannot test the WebSocket server with a web browser like you tested the HTTP server. However, you can test it with websockets'...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found