SeleniumHQ/selenium · critical · Error::WebDriverError

no sessionId in returned payload

Error message

no sessionId in returned payload

What it means

Raised by Remote::Bridge#create_session (Error::WebDriverError) when the new_session response payload contains no 'sessionId' key. Per the WebDriver spec a successful session creation must return a sessionId; its absence means the remote end returned a malformed or non-conformant response.

Source

Thrown at rb/lib/selenium/webdriver/remote/bridge.rb:74

        #

        def initialize(http_client:)
          @http = http_client
          @file_detector = nil
          @locator_converter = self.class.locator_converter
        end

        #
        # Creates session.
        #

        def create_session(capabilities)
          response = execute(:new_session, {}, prepare_capabilities_payload(capabilities))

          @session_id = response['sessionId']
          capabilities = response['capabilities']

          raise Error::WebDriverError, 'no sessionId in returned payload' unless @session_id

          @capabilities = Capabilities.json_create(capabilities)

          case @capabilities[:browser_name]
          when 'chrome', 'chrome-headless-shell'
            extend(WebDriver::Chrome::Features)
          when 'firefox'
            extend(WebDriver::Firefox::Features)
          when 'msedge', 'MicrosoftEdge'
            extend(WebDriver::Edge::Features)
          when 'Safari', 'Safari Technology Preview'
            extend(WebDriver::Safari::Features)
          when 'internet explorer'
            extend(WebDriver::IE::Features)
          end
        end

        #

View on GitHub (pinned to aa36b38e69)

Solutions

  1. Verify the remote URL points to a compliant WebDriver endpoint (e.g. http://host:4444 for a Selenium 4 Grid/Server).
  2. Upgrade the remote end (Grid/Server/driver) to a WebDriver-compliant version.
  3. Inspect the raw HTTP response from the new_session call to confirm the payload shape and adjust the endpoint/proxy accordingly.

Example fix

// before
driver = Selenium::WebDriver.for(:remote, url: 'http://hub:4444/wd/hub', capabilities: caps)
# legacy endpoint returns no sessionId

// after
# use the Selenium 4 Grid root endpoint
driver = Selenium::WebDriver.for(:remote, url: 'http://hub:4444', capabilities: caps)
Defensive patterns

Strategy: validation

Validate before calling

# Confirm the endpoint is a compliant WebDriver server before session creation
require 'net/http'
uri = URI(grid_url + '/status')
resp = Net::HTTP.get_response(uri)
raise 'Endpoint is not a WebDriver server' unless resp.is_a?(Net::HTTPSuccess)

Try / catch

begin
  driver = Selenium::WebDriver.for(:remote, url: url, capabilities: caps)
rescue Selenium::WebDriver::Error::WebDriverError => e
  raise unless e.message.include?('sessionId')
  raise "Remote end returned no sessionId; verify URL/version: #{e.message}"
end

Prevention

When it happens

Trigger: Connecting to a server/endpoint that is not a compliant WebDriver implementation (e.g. a plain HTTP server, a proxy, or a legacy Selenium 2 protocol endpoint) that returns a body without sessionId; an intermediary mangling the JSON response.

Common situations: Wrong URL (e.g. pointing at a web UI or status endpoint instead of the WebDriver session endpoint); an old Grid/hub version; a mock or recording returning a partial payload; a reverse proxy stripping fields.

Related errors


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