Skip to content

[🐛 Bug]: OpenQA.Selenium.WebDriverException : A WebSocket address for DevTools protocol has been detected, but the protocol version cannot be automatically detected. You must specify a protocol version. #13502

Description

@MJB222398

What happened?

I am trying to access the browser console logs across Chrome, Edge, and Firefox using the BiDi implementation. I am using a docker based Selenium Grid running on the WSL2 Ubuntu installation on my Windows PC. The C# code itself is running on this Windows machine and so I am using the RemoteWebDriver. I get this exception below when I use the method IJavaScriptEngine.StartEventMonitoring():

Message: 
OpenQA.Selenium.WebDriverException : Unexpected error creating WebSocket DevTools session.
  ----> OpenQA.Selenium.WebDriverException : A WebSocket address for DevTools protocol has been detected, but the protocol version cannot be automatically detected. You must specify a protocol version.

  Stack Trace: 
RemoteWebDriver.GetDevToolsSession(DevToolsOptions options)
RemoteWebDriver.GetDevToolsSession()
<.ctor>b__0()
Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
Lazy`1.CreateValue()
JavaScriptEngine.StartEventMonitoring()

How can we reproduce the issue?

internal sealed class MyDriver : IMyDriver
    {
        private readonly IList<string> _consoleLogs;
        private readonly RemoteWebDriver _webDriver;
        private readonly IJavaScriptEngine _jsEngine;

        public MyDriver(RemoteWebDriver webDriver)
        {
            _webDriver = webDriver ?? throw new ArgumentNullException(nameof(webDriver));
            _jsEngine = new JavaScriptEngine(webDriver);
            _consoleLogs = new List<string>();
        }

        public async Task Initialize()
        {
            _jsEngine.JavaScriptConsoleApiCalled += (sender, e) => _consoleLogs.Add($"{e.MessageTimeStamp}: {e.MessageType} - {e.MessageContent}");
            await _jsEngine.StartEventMonitoring();
        }
    }


### Relevant log output

```shell
13:01:03.963 INFO [LocalNode.newSession] - Session created by the Node. Id: 286084821c57eed09a05fef9ecd69ac4, Caps: Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 120.0.6099.224, chrome: {chromedriverVersion: 120.0.6099.109 (3419140ab66..., userDataDir: /home/seluser/selenium/profile}, fedcm:accounts: true, goog:chromeOptions: {debuggerAddress: localhost:35435}, goog:loggingPrefs: {browser: ALL, client: ALL, driver: ALL, performance: ALL, profiler: ALL, server: ALL}, networkConnectionEnabled: false, pageLoadStrategy: normal, platformName: linux, proxy: Proxy(), se:bidiEnabled: false, se:cdp: ws://172.20.0.4:4444/sessio..., se:cdpVersion: 120.0.6099.224, se:vnc: ws://172.20.0.4:4444/sessio..., se:vncEnabled: true, se:vncLocalAddress: ws://172.20.0.4:7900, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:credBlob: true, webauthn:extension:largeBlob: true, webauthn:extension:minPinLength: true, webauthn:extension:prf: true, webauthn:virtualAuthenticators: true}

Operating System

Windows 10

Selenium version

.NET Selenium 4.17

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

Chrome: 120.0.6099.224, Edge: 120.0.2210.144

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

Chrome: 120.0.6099.224, Edge: 120.0.2210.144

Are you using Selenium Grid?

Yes 4.17.0-20240123

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-dotnet.NET BindingsI-defectSomething is not working as intended

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions