Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Principle:SeleniumHQ Selenium WebDriver Session Creation

From Leeroopedia
Knowledge Sources
Domains Browser_Automation, WebDriver, Session_Management
Last Updated 2026-02-11 00:00 GMT

Overview

Protocol-defined procedure for establishing a new browser automation session via the W3C WebDriver HTTP POST /session endpoint.

Description

WebDriver Session Creation is the central handshake between a WebDriver client and a browser driver server. The client sends an HTTP POST request to /session with a JSON body containing desired capabilities. The server attempts to create a new browser process matching those capabilities, returns a unique session ID, and reports the actual (matched) capabilities. This session ID is then used as a path parameter in all subsequent commands. The session creation process involves driver service startup, binary resolution, capability negotiation, and browser process initialization.

Usage

This principle is applied every time a new browser automation session begins. Understanding it is critical for debugging session creation failures, capability mismatches, and performance optimization (e.g., reusing services across sessions).

Theoretical Basis

# Pseudocode: W3C Session Creation
1. Client sends POST /session { capabilities: { alwaysMatch: {...}, firstMatch: [...] } }
2. Server validates capabilities against W3C spec
3. Server starts browser process with matched capabilities
4. Server returns { sessionId: "abc123", capabilities: { ...matched... } }
5. All subsequent requests include sessionId in URL path:
   POST /session/abc123/url  (navigate)
   POST /session/abc123/element (find element)
6. DELETE /session/abc123  (end session)

Related Pages

Implemented By

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment