Null values found in w3c capabilities. Keys are: [browserVersion] - Selenium Grid 4 with python

95 views Asked by At

Does anyone know about this error with Selenium 4.14 docker and grid?

selenium.common.exceptions.WebDriverException: Message: Null values found in w3c capabilities. Keys are: [browserVersion]

In driver log, it is indeed null, and I figure it's client side parameter.

----------------------------------------- Captured stdout setup ------------------------------------------
Starting ChromeDriver 118.0.5993.70 (e52f33f30b91b4ddfad649acddc39ab570473b86-refs/branch-heads/5993@{#1216}) on port 43413
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
----------------------------------------- Captured stderr setup ------------------------------------------
[1697822699.688][INFO]: [bacdb36ce6ac50b52a5aa4d7f88b6f2a] COMMAND InitSession {
   "capabilities": {
      "alwaysMatch": {
         "browserName": "chrome",
         "browserVersion": null,
         "goog:chromeOptions": {
            "args": [ "--headless=new", "ignore-certificate-errors", "auto-open-devtools-for-tabs" ],
            "binary": "/opt/google/chrome/google-chrome",
            "extensions": [  ]
         },
         "pageLoadStrategy": "normal"
      },
      "firstMatch": [ {
      } ]
   }
}

It looks like no matter how I set it, it's not reflected in the InitSession command:

@pytest.fixture(scope='session')
def common_driver(request):
    """
    Creating selenium session and launching the browser specified by '--browser' option
    """
    browser = request.config.getoption('--browser')
    use_grid = request.config.getoption('--use-grid')
    driver = None
    options = None

    match browser:
        case 'chrome':
            options = webdriver.ChromeOptions()
            options.platformName = 'linux'
            options.browserVersion = '118'
            options.add_argument('--headless=new')
            options.add_argument('ignore-certificate-errors')
            options.add_argument('auto-open-devtools-for-tabs')
            # Configure driver log
            service = webdriver.ChromeService(service_args=['--log-level=ALL'],
                                              log_output=subprocess.STDOUT)
            driver = webdriver.Chrome(options=options, service=service)

(snip)

    if use_grid:
        remote_url = request.config.getoption('--remote-url')
        if not remote_url:
            # Just in case there is no default value.
            logger.error(f"--remote-url is empty, but --use-grid is specified.")
            return None
        driver = webdriver.Remote(command_executor=remote_url, options=options)

It throws the exception at webdriver.Remote call. If grid is not used and webdriver.Chrome is called, then it works fine.

I tried other versions 4.13 and 4.12 from https://github.com/SeleniumHQ/docker-selenium, and matched the python library by pip, but got the same error.

0

There are 0 answers