Adding webdriver cookie commands#44388
Open
Rumyra wants to merge 2 commits into
Open
Conversation
Contributor
dipikabh
requested changes
Jun 8, 2026
| The body is a JSON Object with a single `cookie` field whose value is a **cookie object**: | ||
|
|
||
| - `name` | ||
| - : The name of the cookie. Required. |
Contributor
There was a problem hiding this comment.
"Required." can be removed from everywhere
|
|
||
| ### Payload | ||
|
|
||
| The body is a JSON Object with a single `cookie` field whose value is a **cookie object**: |
Contributor
There was a problem hiding this comment.
- Suggesting "body" -> "input" based on https://developer.mozilla.org/en-US/docs/Web/WebDriver/Reference/Classic/Commands/SetTimeouts#payload
- How about:
Suggested change
| The body is a JSON Object with a single `cookie` field whose value is a **cookie object**: | |
| The input is a JSON object with a single `cookie` key whose value is a cookie object with the following fields: |
| - `httpOnly` {{optional_inline}} | ||
| - : Whether the cookie is an HTTP-only cookie. Defaults to `false`. | ||
| - `expiry` {{optional_inline}} | ||
| - : When the cookie expires, specified in seconds since the Unix epoch. Must be a number in the 0 to 2^53 − 1 range. If omitted, the cookie is a session cookie. |
Contributor
There was a problem hiding this comment.
"is a session cookie" -> "is treated as a session cookie"?
Suggested change
| - : When the cookie expires, specified in seconds since the Unix epoch. Must be a number in the 0 to 2^53 − 1 range. If omitted, the cookie is a session cookie. | |
| - : The cookie's expiry time in seconds since the Unix epoch. This value must be a number in the 0 to 2^53 − 1 range. If omitted, the cookie is treated as a session cookie. |
| - `expiry` {{optional_inline}} | ||
| - : When the cookie expires, specified in seconds since the Unix epoch. Must be a number in the 0 to 2^53 − 1 range. If omitted, the cookie is a session cookie. | ||
| - `sameSite` {{optional_inline}} | ||
| - : The cookie's [same-site policy](/en-US/docs/Web/HTTP/Reference/Headers/Set-Cookie#samesitesamesite-value). One of `"Lax"`, `"Strict"`, or `"None"`. |
Contributor
There was a problem hiding this comment.
- Changes here can also be replicated to getnamedcookie file
- Is there a default value here?
Suggested change
| - : The cookie's [same-site policy](/en-US/docs/Web/HTTP/Reference/Headers/Set-Cookie#samesitesamesite-value). One of `"Lax"`, `"Strict"`, or `"None"`. | |
| - : The cookie's [same-site policy](/en-US/docs/Web/HTTP/Reference/Headers/Set-Cookie#samesitesamesite-value). Possible values include`"Lax"`, `"Strict"`, and `"None"`. |
| ### Errors | ||
|
|
||
| - [`Invalid argument`](/en-US/docs/Web/WebDriver/Reference/Errors/InvalidArgument) | ||
| - : The `cookie` object is missing, is not a JSON Object, is missing a required field, or one of its fields does not meet the type or value constraints. |
Contributor
There was a problem hiding this comment.
Suggested change
| - : The `cookie` object is missing, is not a JSON Object, is missing a required field, or one of its fields does not meet the type or value constraints. | |
| - : The `cookie` object is missing, is not a JSON object, is missing a required field, or one of its fields does not meet the type or value constraints. |
|
|
||
| ### Return value | ||
|
|
||
| A single **cookie object** with the following fields: |
Contributor
There was a problem hiding this comment.
Suggested change
| A single **cookie object** with the following fields: | |
| A single cookie object with the following fields: |
Comment on lines
+41
to
+44
| - `expiry` | ||
| - : When the cookie expires, specified in seconds since the Unix epoch. Omitted for session cookies. | ||
| - `sameSite` | ||
| - : The cookie's [same-site policy](/en-US/docs/Web/HTTP/Reference/Headers/Set-Cookie#samesitesamesite-value). One of `"Lax"`, `"Strict"`, or `"None"`. |
Contributor
There was a problem hiding this comment.
same comment as in addcookie
| - `Unexpected alert open` | ||
| - : A user prompt, such as [`window.alert`](/en-US/docs/Web/API/Window/alert), blocks execution of the command until it is dealt with. | ||
| - [`Invalid session id`](/en-US/docs/Web/WebDriver/Reference/Errors/InvalidSessionID) | ||
| - : Session does not exist. |
Contributor
There was a problem hiding this comment.
Suggested change
| - : Session does not exist. | |
| - : The specified session does not exist. |
Comment on lines
+39
to
+42
| - `expiry` | ||
| - : When the cookie expires, specified in seconds since the Unix epoch. Omitted for session cookies. | ||
| - `sameSite` | ||
| - : The cookie's [same-site policy](/en-US/docs/Web/HTTP/Reference/Headers/Set-Cookie#samesitesamesite-value). One of `"Lax"`, `"Strict"`, or `"None"`. |
| ```bash | ||
| curl -i -H "Content-Type: application/json" \ | ||
| -d '{"cookie": {"name": "session_token", "value": "abc123", "secure": true, "sameSite": "Strict"}}' \ | ||
| http://localhost:4444/session/ID/cookie |
Contributor
There was a problem hiding this comment.
In all such examples, we must replace ID with a realistic ID value.
I notice that I should similarly update the examples in Back and Forward commands!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This pr adds the WebDriver classic cookie related commands
And updates links in
invalidcookiedomainerrorMotivation
Filling the gaps in web driver classic documentation
Additional details
I've not added error pages - we plan to work on those separately
Related issues and pull requests