set cookie
Set a browser cookie scoped to the current page URL
Set a cookie on the browser context, scoped to the URL of the current page. Navigate first so the cookie has a page URL to attach to.
Syntax
When I set cookie "<name>" to "<value>"Qualifiers
| Qualifier | Role | Example |
|---|---|---|
to | Cookie value | set cookie "session" to "abc" |
Requirements
| Item | Contract |
|---|---|
| Element / control shape | None — browser cookie on current page URL scope |
| How the label binds | Name + value payloads |
| Qualifiers that change resolve | to |
| Platform | Web only (requires a loaded page) |
| Wrong shape → use instead | localStorage → set local storage |
See also UI contracts.
Examples
Given I navigate to "https://example.com"
When I set cookie "session" to "abc123"Notes
- Quoted values resolve like every other step (
$ENV,@/@@,{{faker}}). Reports keep the raw.stkquote. - Useful to skip login flows when you already have a session cookie.
- Web only. Appium /
Platform: apireturn unsupported.