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

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
NewSession
Chrome – Full support
Chrome 65 (Release date: 2018-03-06)
footnote
footnote To enable Chromium support, include {"goog:chromeOptions": {"w3c": true}} in the capabilities.
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote
footnote To enable Chromium support, include {"goog:chromeOptions": {"w3c": true}} in the capabilities.
Firefox – Full support
Firefox 55 (Release date: 2017-08-08)
footnote Full support
Opera – No support
Opera
footnote
footnote To enable Chromium support, include {"goog:chromeOptions": {"w3c": true}} in the capabilities.
Safari – No support
Safari
footnote
footnote The vendor-supported implementation for Safari is non spec-conforming and incompatible.
Chrome Android – No support
Chrome Android
footnote
footnote To enable Chromium support, include {"goog:chromeOptions": {"w3c": true}} in the capabilities.
Firefox for Android – No support
Firefox for Android
footnote No support
Opera Android – No support
Opera Android
footnote
footnote To enable Chromium support, include {"goog:chromeOptions": {"w3c": true}} in the capabilities.
Safari on iOS – No support
Safari on iOS
footnote
footnote The vendor-supported implementation for Safari on iOS is non spec-conforming and incompatible.
Samsung Internet – No support
Samsung Internet
footnote
footnote The vendor-supported implementation for Samsung Internet is non-spec-conforming and incompatible.
WebView Android – No support
WebView Android
footnote
footnote To enable Chromium support, include {"goog:chromeOptions": {"w3c": true}} in the capabilities.
WebView on iOS – No support
WebView on iOS
footnote
footnote The vendor-supported implementation for WebView on iOS is non spec-conforming and incompatible.

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
See implementation notes.

See also