在 w3c 功能中找到的 Null 值。键是:[browserVersion] - 带有 python 的 Selenium Grid 4

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

提问人:user22437625 提问时间:10/21/2023 最后编辑:user22437625 更新时间:10/21/2023 访问量:32

问:

有谁知道 Selenium 4.14 docker 和 grid 的这个错误?

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

在驱动程序日志中,它确实是空的,我认为它是客户端参数。

----------------------------------------- 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": [ {
      } ]
   }
}

看起来无论我如何设置它,它都不会反映在 InitSession 命令中:

@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)

它在 webdriver 上抛出异常。远程通话。如果未使用 grid 和 webdriver.Chrome 被调用,然后它工作正常。

我尝试了 https://github.com/SeleniumHQ/docker-selenium 的其他版本 4.13 和 4.12,并通过 pip 匹配了 python 库,但遇到了同样的错误。

selenium-grid selenium4 selenium-docker

评论

0赞 user22437625 10/31/2023
更新 - 以防万一这对将来有人有帮助:我们决定与 Playwright 和 k8s 合作。

答: 暂无答案