New Session

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

The New Session command of the WebDriver API creates a new WebDriver session with the browser. The session identifier returned in the response is required for all subsequent commands.

Syntax

Method URI template
POST /session

Payload

capabilities

Used to define the features the driver must satisfy when creating a new session. See Capabilities for available options.

Response

The response payload is a JSON object with:

sessionId

The unique identifier of the session.

capabilities

The negotiated capabilities of the session.

Errors

Session not created

A new session could not be created.

Examples

Starting a new session

With a WebDriver server running on localhost:4444, the following command starts a new WebDriver session requesting Firefox as the browser:

bash
curl -i -H "Content-Type: application/json" -d '{"capabilities": {"alwaysMatch": {"browserName": "firefox"}}}' http://localhost:4444/session

The output will look similar to the following, where 27c8437e-5e42-43f9-a26f-2db0fd509ec1 is the unique identifier of this session:

http
HTTP/1.1 200 OK
content-type: application/json; charset=utf-8

{"value":{"sessionId":"27c8437e-5e42-43f9-a26f-2db0fd509ec1","capabilities":{"acceptInsecureCerts":false,"browserName":"firefox","browserVersion":"147.0.4","pageLoadStrategy":"normal","platformName":"mac","proxy":{},"setWindowRect":true,"strictFileInteractability":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000}}}}

Specifications

Specification
WebDriver
# new-session

Browser compatibility

See also