SeleniumHQ/selenium · error · WebDriverException

CDP version not found in capabilities

Error message

CDP version not found in capabilities

What it means

Raised by start_devtools() when the session capabilities contain a 'se:cdp' endpoint URL but no 'se:cdpVersion' string. Selenium needs the CDP (Chrome DevTools Protocol) major version to load the matching devtools API module, so a missing version makes it impossible to select the right protocol bindings. This path is taken only when se:cdp is present (e.g. when talking to Selenium Grid which injects these caps).

Source

Thrown at py/selenium/webdriver/remote/webdriver.py:1151

            value: Orientation to set it to.

        Example:
            `driver.orientation = "landscape"`
        """
        allowed_values = ["LANDSCAPE", "PORTRAIT"]
        if value.upper() in allowed_values:
            self.execute(Command.SET_SCREEN_ORIENTATION, {"orientation": value})
        else:
            raise WebDriverException("You can only set the orientation to 'LANDSCAPE' and 'PORTRAIT'")

    def start_devtools(self) -> tuple[Any, WebSocketConnection]:
        global cdp
        import_cdp()
        if self.caps.get("se:cdp"):
            ws_url = self.caps.get("se:cdp")
            cdp_version = self.caps.get("se:cdpVersion")
            if cdp_version is None:
                raise WebDriverException("CDP version not found in capabilities")
            version = cdp_version.split(".")[0]
        else:
            version, ws_url = self._get_cdp_details()

        if not ws_url:
            raise WebDriverException("Unable to find url to connect to from capabilities")

        if cdp is None:
            raise WebDriverException("CDP module not loaded")

        self._devtools = cdp.import_devtools(version)
        if self._websocket_connection:
            return self._devtools, self._websocket_connection
        if self.caps["browserName"].lower() == "firefox":
            raise RuntimeError("CDP support for Firefox has been removed. Please switch to WebDriver BiDi.")
        if not isinstance(self.command_executor, RemoteConnection):
            raise WebDriverException("command_executor must be a RemoteConnection instance for CDP support")
        self._websocket_connection = WebSocketConnection(

View on GitHub (pinned to aa36b38e69)

Solutions

  1. Upgrade the Selenium Grid / standalone server to a version that emits both se:cdp and se:cdpVersion.
  2. If you control the remote, ensure it reports the CDP version alongside the endpoint URL.
  3. As a fallback, drop the se:cdp cap so Selenium derives version+url locally via _get_cdp_details() from the debugger address instead.
Defensive patterns

Strategy: validation

Validate before calling

caps = driver.capabilities
if caps.get('se:cdp') and not caps.get('se:cdpVersion'):
    raise RuntimeError('Remote provided se:cdp without se:cdpVersion; upgrade Grid')
driver.start_devtools()

Try / catch

from selenium.common.exceptions import WebDriverException
try:
    driver.start_devtools()
except WebDriverException:
    # fall back: drop se:cdp and derive locally via debugger address
    pass

Prevention

When it happens

Trigger: Connecting to a Selenium Grid or remote that sets caps['se:cdp'] to a websocket URL but omits caps['se:cdpVersion']. Then calling driver.start_devtools() or accessing driver.bidi_connection().

Common situations: An older Grid version, a misconfigured Grid, or a custom remote endpoint that injects se:cdp without the version. Upgrading the Selenium Grid/server usually resolves version-mismatch cap omissions.

Related errors


AI-assisted analysis of SeleniumHQ/selenium@aa36b38e69 (2026-08-14). Data as JSON: /api/errors/6d39a56df5ba2224. Report an issue: GitHub.