Skip to content

Commit a626c55

Browse files
committed
Switch to 2025-06-07 and fix cookies
1 parent a78c02e commit a626c55

File tree

9 files changed

+55
-21
lines changed

9 files changed

+55
-21
lines changed

playwright/_impl/_api_structures.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ class Cookie(TypedDict, total=False):
3434
sameSite: Literal["Lax", "None", "Strict"]
3535

3636

37+
class PartitionedCookie(Cookie):
38+
partitionKey: Optional[str]
39+
40+
3741
# TODO: We are waiting for PEP705 so SetCookieParam can be readonly and matches Cookie.
3842
class SetCookieParam(TypedDict, total=False):
3943
name: str
@@ -45,6 +49,7 @@ class SetCookieParam(TypedDict, total=False):
4549
httpOnly: Optional[bool]
4650
secure: Optional[bool]
4751
sameSite: Optional[Literal["Lax", "None", "Strict"]]
52+
partitionKey: Optional[str]
4853

4954

5055
class FloatRect(TypedDict):
@@ -101,6 +106,11 @@ class StorageState(TypedDict, total=False):
101106
origins: List[OriginState]
102107

103108

109+
class PartitionedStorageState(TypedDict, total=False):
110+
cookies: List[PartitionedCookie]
111+
origins: List[OriginState]
112+
113+
104114
class ClientCertificate(TypedDict, total=False):
105115
origin: str
106116
certPath: Optional[Union[str, Path]]

playwright/_impl/_browser_context.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@
3232
)
3333

3434
from playwright._impl._api_structures import (
35-
Cookie,
3635
Geolocation,
36+
PartitionedCookie,
37+
PartitionedStorageState,
3738
SetCookieParam,
38-
StorageState,
3939
)
4040
from playwright._impl._artifact import Artifact
4141
from playwright._impl._cdp_session import CDPSession
@@ -317,7 +317,9 @@ async def new_page(self) -> Page:
317317
raise Error("Please use browser.new_context()")
318318
return from_channel(await self._channel.send("newPage"))
319319

320-
async def cookies(self, urls: Union[str, Sequence[str]] = None) -> List[Cookie]:
320+
async def cookies(
321+
self, urls: Union[str, Sequence[str]] = None
322+
) -> List[PartitionedCookie]:
321323
if urls is None:
322324
urls = []
323325
if isinstance(urls, str):
@@ -594,7 +596,7 @@ async def _inner_close() -> None:
594596

595597
async def storage_state(
596598
self, path: Union[str, Path] = None, indexedDB: bool = None
597-
) -> StorageState:
599+
) -> PartitionedStorageState:
598600
result = await self._channel.send_return_as_dict(
599601
"storageState", {"indexedDB": indexedDB}
600602
)

playwright/async_api/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
ChromiumBrowserContext = BrowserContext
7070

7171
Cookie = playwright._impl._api_structures.Cookie
72+
PartitionedCookie = playwright._impl._api_structures.PartitionedCookie
7273
FilePayload = playwright._impl._api_structures.FilePayload
7374
FloatRect = playwright._impl._api_structures.FloatRect
7475
Geolocation = playwright._impl._api_structures.Geolocation

playwright/async_api/_generated.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,13 @@
2121
from playwright._impl._accessibility import Accessibility as AccessibilityImpl
2222
from playwright._impl._api_structures import (
2323
ClientCertificate,
24-
Cookie,
2524
FilePayload,
2625
FloatRect,
2726
Geolocation,
2827
HttpCredentials,
2928
NameValue,
29+
PartitionedCookie,
30+
PartitionedStorageState,
3031
PdfMargins,
3132
Position,
3233
ProxySettings,
@@ -12649,7 +12650,8 @@ def pages(self) -> typing.List["Page"]:
1264912650
def browser(self) -> typing.Optional["Browser"]:
1265012651
"""BrowserContext.browser
1265112652

12652-
Returns the browser instance of the context. If it was launched as a persistent context null gets returned.
12653+
Gets the browser instance that owns the context. Returns `null` if the context is created outside of normal
12654+
browser, e.g. Android or Electron.
1265312655

1265412656
Returns
1265512657
-------
@@ -12776,7 +12778,7 @@ async def new_page(self) -> "Page":
1277612778

1277712779
async def cookies(
1277812780
self, urls: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None
12779-
) -> typing.List[Cookie]:
12781+
) -> typing.List[PartitionedCookie]:
1278012782
"""BrowserContext.cookies
1278112783

1278212784
If no URLs are specified, this method returns all cookies. If URLs are specified, only cookies that affect those
@@ -12789,7 +12791,7 @@ async def cookies(
1278912791

1279012792
Returns
1279112793
-------
12792-
List[{name: str, value: str, domain: str, path: str, expires: float, httpOnly: bool, secure: bool, sameSite: Union["Lax", "None", "Strict"]}]
12794+
List[{name: str, value: str, domain: str, path: str, expires: float, httpOnly: bool, secure: bool, sameSite: Union["Lax", "None", "Strict"], partitionKey: Union[str, None]}]
1279312795
"""
1279412796

1279512797
return mapping.from_impl_list(
@@ -12810,7 +12812,7 @@ async def add_cookies(self, cookies: typing.Sequence[SetCookieParam]) -> None:
1281012812

1281112813
Parameters
1281212814
----------
12813-
cookies : Sequence[{name: str, value: str, url: Union[str, None], domain: Union[str, None], path: Union[str, None], expires: Union[float, None], httpOnly: Union[bool, None], secure: Union[bool, None], sameSite: Union["Lax", "None", "Strict", None]}]
12815+
cookies : Sequence[{name: str, value: str, url: Union[str, None], domain: Union[str, None], path: Union[str, None], expires: Union[float, None], httpOnly: Union[bool, None], secure: Union[bool, None], sameSite: Union["Lax", "None", "Strict", None], partitionKey: Union[str, None]}]
1281412816
"""
1281512817

1281612818
return mapping.from_maybe_impl(
@@ -13436,7 +13438,7 @@ async def storage_state(
1343613438
*,
1343713439
path: typing.Optional[typing.Union[str, pathlib.Path]] = None,
1343813440
indexed_db: typing.Optional[bool] = None,
13439-
) -> StorageState:
13441+
) -> PartitionedStorageState:
1344013442
"""BrowserContext.storage_state
1344113443

1344213444
Returns storage state for this browser context, contains current cookies, local storage snapshot and IndexedDB
@@ -13454,7 +13456,7 @@ async def storage_state(
1345413456

1345513457
Returns
1345613458
-------
13457-
{cookies: List[{name: str, value: str, domain: str, path: str, expires: float, httpOnly: bool, secure: bool, sameSite: Union["Lax", "None", "Strict"]}], origins: List[{origin: str, localStorage: List[{name: str, value: str}]}]}
13459+
{cookies: List[{name: str, value: str, domain: str, path: str, expires: float, httpOnly: bool, secure: bool, sameSite: Union["Lax", "None", "Strict"], partitionKey: Union[str, None]}], origins: List[{origin: str, localStorage: List[{name: str, value: str}]}]}
1345813460
"""
1345913461

1346013462
return mapping.from_impl(
@@ -16445,6 +16447,13 @@ def describe(self, description: str) -> "Locator":
1644516447
Describes the locator, description is used in the trace viewer and reports. Returns the locator pointing to the
1644616448
same element.
1644716449

16450+
**Usage**
16451+
16452+
```py
16453+
button = page.get_by_test_id(\"btn-sub\").describe(\"Subscribe button\")
16454+
await button.click()
16455+
```
16456+
1644816457
Parameters
1644916458
----------
1645016459
description : str

playwright/sync_api/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
ChromiumBrowserContext = BrowserContext
7070

7171
Cookie = playwright._impl._api_structures.Cookie
72+
PartitionedCookie = playwright._impl._api_structures.PartitionedCookie
7273
FilePayload = playwright._impl._api_structures.FilePayload
7374
FloatRect = playwright._impl._api_structures.FloatRect
7475
Geolocation = playwright._impl._api_structures.Geolocation
@@ -175,6 +176,7 @@ def __call__(
175176
"Locator",
176177
"Mouse",
177178
"Page",
179+
"PartitionedCookie",
178180
"PdfMargins",
179181
"Position",
180182
"Playwright",

playwright/sync_api/_generated.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,13 @@
2121
from playwright._impl._accessibility import Accessibility as AccessibilityImpl
2222
from playwright._impl._api_structures import (
2323
ClientCertificate,
24-
Cookie,
2524
FilePayload,
2625
FloatRect,
2726
Geolocation,
2827
HttpCredentials,
2928
NameValue,
29+
PartitionedCookie,
30+
PartitionedStorageState,
3031
PdfMargins,
3132
Position,
3233
ProxySettings,
@@ -12671,7 +12672,8 @@ def pages(self) -> typing.List["Page"]:
1267112672
def browser(self) -> typing.Optional["Browser"]:
1267212673
"""BrowserContext.browser
1267312674

12674-
Returns the browser instance of the context. If it was launched as a persistent context null gets returned.
12675+
Gets the browser instance that owns the context. Returns `null` if the context is created outside of normal
12676+
browser, e.g. Android or Electron.
1267512677

1267612678
Returns
1267712679
-------
@@ -12798,7 +12800,7 @@ def new_page(self) -> "Page":
1279812800

1279912801
def cookies(
1280012802
self, urls: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None
12801-
) -> typing.List[Cookie]:
12803+
) -> typing.List[PartitionedCookie]:
1280212804
"""BrowserContext.cookies
1280312805

1280412806
If no URLs are specified, this method returns all cookies. If URLs are specified, only cookies that affect those
@@ -12811,7 +12813,7 @@ def cookies(
1281112813

1281212814
Returns
1281312815
-------
12814-
List[{name: str, value: str, domain: str, path: str, expires: float, httpOnly: bool, secure: bool, sameSite: Union["Lax", "None", "Strict"]}]
12816+
List[{name: str, value: str, domain: str, path: str, expires: float, httpOnly: bool, secure: bool, sameSite: Union["Lax", "None", "Strict"], partitionKey: Union[str, None]}]
1281512817
"""
1281612818

1281712819
return mapping.from_impl_list(
@@ -12832,7 +12834,7 @@ def add_cookies(self, cookies: typing.Sequence[SetCookieParam]) -> None:
1283212834

1283312835
Parameters
1283412836
----------
12835-
cookies : Sequence[{name: str, value: str, url: Union[str, None], domain: Union[str, None], path: Union[str, None], expires: Union[float, None], httpOnly: Union[bool, None], secure: Union[bool, None], sameSite: Union["Lax", "None", "Strict", None]}]
12837+
cookies : Sequence[{name: str, value: str, url: Union[str, None], domain: Union[str, None], path: Union[str, None], expires: Union[float, None], httpOnly: Union[bool, None], secure: Union[bool, None], sameSite: Union["Lax", "None", "Strict", None], partitionKey: Union[str, None]}]
1283612838
"""
1283712839

1283812840
return mapping.from_maybe_impl(
@@ -13467,7 +13469,7 @@ def storage_state(
1346713469
*,
1346813470
path: typing.Optional[typing.Union[str, pathlib.Path]] = None,
1346913471
indexed_db: typing.Optional[bool] = None,
13470-
) -> StorageState:
13472+
) -> PartitionedStorageState:
1347113473
"""BrowserContext.storage_state
1347213474

1347313475
Returns storage state for this browser context, contains current cookies, local storage snapshot and IndexedDB
@@ -13485,7 +13487,7 @@ def storage_state(
1348513487

1348613488
Returns
1348713489
-------
13488-
{cookies: List[{name: str, value: str, domain: str, path: str, expires: float, httpOnly: bool, secure: bool, sameSite: Union["Lax", "None", "Strict"]}], origins: List[{origin: str, localStorage: List[{name: str, value: str}]}]}
13490+
{cookies: List[{name: str, value: str, domain: str, path: str, expires: float, httpOnly: bool, secure: bool, sameSite: Union["Lax", "None", "Strict"], partitionKey: Union[str, None]}], origins: List[{origin: str, localStorage: List[{name: str, value: str}]}]}
1348913491
"""
1349013492

1349113493
return mapping.from_impl(
@@ -16509,6 +16511,13 @@ def describe(self, description: str) -> "Locator":
1650916511
Describes the locator, description is used in the trace viewer and reports. Returns the locator pointing to the
1651016512
same element.
1651116513

16514+
**Usage**
16515+
16516+
```py
16517+
button = page.get_by_test_id(\"btn-sub\").describe(\"Subscribe button\")
16518+
button.click()
16519+
```
16520+
1651216521
Parameters
1651316522
----------
1651416523
description : str

scripts/generate_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ def return_value(value: Any) -> List[str]:
225225
226226
227227
from playwright._impl._accessibility import Accessibility as AccessibilityImpl
228-
from playwright._impl._api_structures import Cookie, SetCookieParam, FloatRect, FilePayload, Geolocation, HttpCredentials, PdfMargins, Position, ProxySettings, ResourceTiming, SourceLocation, StorageState, ClientCertificate, ViewportSize, RemoteAddr, SecurityDetails, RequestSizes, NameValue, TracingGroupLocation
228+
from playwright._impl._api_structures import PartitionedCookie, SetCookieParam, FloatRect, FilePayload, Geolocation, HttpCredentials, PdfMargins, Position, ProxySettings, ResourceTiming, SourceLocation, PartitionedStorageState, StorageState, ClientCertificate, ViewportSize, RemoteAddr, SecurityDetails, RequestSizes, NameValue, TracingGroupLocation
229229
from playwright._impl._browser import Browser as BrowserImpl
230230
from playwright._impl._browser_context import BrowserContext as BrowserContextImpl
231231
from playwright._impl._browser_type import BrowserType as BrowserTypeImpl

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import zipfile
2222
from typing import Dict
2323

24-
driver_version = "1.53.0-alpha-2025-05-21"
24+
driver_version = "1.54.0-alpha-2025-06-07"
2525

2626
base_wheel_bundles = [
2727
{

tests/async/test_defaultbrowsercontext.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
List,
2525
Literal,
2626
Optional,
27+
Sequence,
2728
Tuple,
2829
)
2930

@@ -124,7 +125,7 @@ async def test_context_add_cookies_should_work(
124125
]
125126

126127

127-
def _filter_cookies(cookies: List[Cookie]) -> List[Cookie]:
128+
def _filter_cookies(cookies: Sequence[Cookie]) -> List[Cookie]:
128129
return list(
129130
filter(lambda cookie: cookie["domain"] != "copilot.microsoft.com", cookies)
130131
)

0 commit comments

Comments
 (0)