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.
| Method | URI template |
|---|---|
POST | /session |
capabilitiesUsed to define the features the driver must satisfy when creating a new session. See Capabilities for available options.
The response payload is a JSON object with:
sessionIdThe unique identifier of the session.
capabilitiesThe negotiated capabilities of the session.
session not createdA new session could not be created.
With a WebDriver server running on localhost:4444, the following command starts a new WebDriver session requesting Firefox as the browser:
curl -i -H "Content-Type: application/json" -d '{"capabilities": {"alwaysMatch": {"browserName": "firefox"}}}' http://localhost:4444/sessionThe output will look similar to the following, where 27c8437e-5e42-43f9-a26f-2db0fd509ec1 is the unique identifier of this session:
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}}}}