page.context or browser.contexts[0]. Tabs opened from it share cookies
and storage.
context.pages
The open tabs.
Returns list[Page].
context.new_page()
Open a new tab, on url or blank.
Page.
context.browser
Returns Browser.
context.cookies()
The session’s cookies, in Playwright’s shape. With urls, only the ones the
browser would send to those URLs.
| Parameter | Type | Default | Description |
|---|---|---|---|
urls | str | list[str] | None | None | Limit to cookies sent to these URLs. |
list[dict]. Each cookie has:
| Key | Type | Description |
|---|---|---|
name, value | str | |
domain, path | str | |
expires | float | Epoch seconds; -1 for a session cookie. |
httpOnly, secure | bool | |
sameSite | str | Strict, Lax or None. |
partitionKey | str | Present on a partitioned cookie: its top-level site. |
context.add_cookies()
Set cookies.
name and value, plus url or domain. Optional:
path (default /), expires (epoch seconds), httpOnly, secure (with a
url, defaults to whether it is https), sameSite.
Raises InvalidArgsError for a cookie with no name, value, url or domain.