How to specify DevTools protocol version in Selenium?

32 views Asked by At

I'm using this Chrome option in my project:

            var options = new ChromeOptions();
            
            // Runs Chrome in headless mode, which is very useful for running automated tests.
            options.AddArgument("--headless");
            
            // Sets the initial window size. In this case, the browser will start with 1920x1080 pixels.
            options.AddArgument("--window-size=1920,1080");
            
            // Bypass OS security model. It's a quick-and-dirty workaround for running as root.
            options.AddArgument("--no-sandbox");
            
            // Overcomes limited resource problems. When running in a Docker container, you might get an error like 
            // 'session deleted because of page crash', which is related to Chrome running out of memory.
            options.AddArgument("--disable-dev-shm-usage");
            
            // Automatically opens Developer Tools when a new page is opened.
            options.AddArgument("--auto-open-devtools-for-tabs");

I'm using Selenium.WebDriver v4.17.0 but I'm getting this error message when I run the application:

A WebSocket address for DevTools protocol has been detected, but the protocol version cannot be automatically detected. You must specify a protocol version.

I wonder, how can I specify the protocol version here and how to find the correct version?

0

There are 0 answers