Skip to content

Commit 1b95464

Browse files
authored
chore(roll): roll Playwright to 1.51.0-beta-1741166263000 (#2767)
1 parent 55725d5 commit 1b95464

21 files changed

+531
-77
lines changed

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ Playwright is a Python library to automate [Chromium](https://www.chromium.org/H
44

55
| | Linux | macOS | Windows |
66
| :--- | :---: | :---: | :---: |
7-
| Chromium <!-- GEN:chromium-version -->133.0.6943.16<!-- GEN:stop --> ||||
8-
| WebKit <!-- GEN:webkit-version -->18.2<!-- GEN:stop --> ||||
9-
| Firefox <!-- GEN:firefox-version -->134.0<!-- GEN:stop --> ||||
7+
| Chromium <!-- GEN:chromium-version -->134.0.6998.35<!-- GEN:stop --> ||||
8+
| WebKit <!-- GEN:webkit-version -->18.4<!-- GEN:stop --> ||||
9+
| Firefox <!-- GEN:firefox-version -->135.0<!-- GEN:stop --> ||||
1010

1111
## Documentation
1212

playwright/_impl/_browser.py

+5
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
from playwright._impl._errors import is_target_closed_error
3333
from playwright._impl._helper import (
3434
ColorScheme,
35+
Contrast,
3536
ForcedColors,
3637
HarContentPolicy,
3738
HarMode,
@@ -107,6 +108,7 @@ async def new_context(
107108
colorScheme: ColorScheme = None,
108109
reducedMotion: ReducedMotion = None,
109110
forcedColors: ForcedColors = None,
111+
contrast: Contrast = None,
110112
acceptDownloads: bool = None,
111113
defaultBrowserType: str = None,
112114
proxy: ProxySettings = None,
@@ -152,6 +154,7 @@ async def new_page(
152154
hasTouch: bool = None,
153155
colorScheme: ColorScheme = None,
154156
forcedColors: ForcedColors = None,
157+
contrast: Contrast = None,
155158
reducedMotion: ReducedMotion = None,
156159
acceptDownloads: bool = None,
157160
defaultBrowserType: str = None,
@@ -254,6 +257,8 @@ async def prepare_browser_context_params(params: Dict) -> None:
254257
params["reducedMotion"] = "no-override"
255258
if params.get("forcedColors", None) == "null":
256259
params["forcedColors"] = "no-override"
260+
if params.get("contrast", None) == "null":
261+
params["contrast"] = "no-override"
257262
if "acceptDownloads" in params:
258263
params["acceptDownloads"] = "accept" if params["acceptDownloads"] else "deny"
259264

playwright/_impl/_browser_context.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -599,8 +599,12 @@ async def _inner_close() -> None:
599599
await self._channel.send("close", {"reason": reason})
600600
await self._closed_future
601601

602-
async def storage_state(self, path: Union[str, Path] = None) -> StorageState:
603-
result = await self._channel.send_return_as_dict("storageState")
602+
async def storage_state(
603+
self, path: Union[str, Path] = None, indexedDB: bool = None
604+
) -> StorageState:
605+
result = await self._channel.send_return_as_dict(
606+
"storageState", {"indexedDB": indexedDB}
607+
)
604608
if path:
605609
await async_writefile(path, json.dumps(result))
606610
return result

playwright/_impl/_browser_type.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
from playwright._impl._errors import Error
3636
from playwright._impl._helper import (
3737
ColorScheme,
38+
Contrast,
3839
Env,
3940
ForcedColors,
4041
HarContentPolicy,
@@ -134,6 +135,7 @@ async def launch_persistent_context(
134135
colorScheme: ColorScheme = None,
135136
reducedMotion: ReducedMotion = None,
136137
forcedColors: ForcedColors = None,
138+
contrast: Contrast = None,
137139
acceptDownloads: bool = None,
138140
tracesDir: Union[pathlib.Path, str] = None,
139141
chromiumSandbox: bool = None,
@@ -150,7 +152,7 @@ async def launch_persistent_context(
150152
recordHarContent: HarContentPolicy = None,
151153
clientCertificates: List[ClientCertificate] = None,
152154
) -> BrowserContext:
153-
userDataDir = str(Path(userDataDir)) if userDataDir else ""
155+
userDataDir = self._user_data_dir(userDataDir)
154156
params = locals_to_params(locals())
155157
await prepare_browser_context_params(params)
156158
normalize_launch_params(params)
@@ -161,6 +163,13 @@ async def launch_persistent_context(
161163
self._did_create_context(context, params, params)
162164
return context
163165

166+
def _user_data_dir(self, userDataDir: Optional[Union[str, Path]]) -> str:
167+
if not userDataDir:
168+
return ""
169+
if not Path(userDataDir).is_absolute():
170+
return str(Path(userDataDir).resolve())
171+
return str(Path(userDataDir))
172+
164173
async def connect_over_cdp(
165174
self,
166175
endpointURL: str,

playwright/_impl/_fetch.py

+15-7
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ async def new_context(
7373
timeout: float = None,
7474
storageState: Union[StorageState, str, Path] = None,
7575
clientCertificates: List[ClientCertificate] = None,
76+
failOnStatusCode: bool = None,
7677
) -> "APIRequestContext":
7778
params = locals_to_params(locals())
7879
if "storageState" in params:
@@ -422,9 +423,13 @@ async def _inner_fetch(
422423
return APIResponse(self, response)
423424

424425
async def storage_state(
425-
self, path: Union[pathlib.Path, str] = None
426+
self,
427+
path: Union[pathlib.Path, str] = None,
428+
indexedDB: bool = None,
426429
) -> StorageState:
427-
result = await self._channel.send_return_as_dict("storageState")
430+
result = await self._channel.send_return_as_dict(
431+
"storageState", {"indexedDB": indexedDB}
432+
)
428433
if path:
429434
await async_writefile(path, json.dumps(result))
430435
return result
@@ -475,11 +480,14 @@ def headers_array(self) -> network.HeadersArray:
475480

476481
async def body(self) -> bytes:
477482
try:
478-
result = await self._request._channel.send_return_as_dict(
479-
"fetchResponseBody",
480-
{
481-
"fetchUid": self._fetch_uid,
482-
},
483+
result = await self._request._connection.wrap_api_call(
484+
lambda: self._request._channel.send_return_as_dict(
485+
"fetchResponseBody",
486+
{
487+
"fetchUid": self._fetch_uid,
488+
},
489+
),
490+
True,
483491
)
484492
if result is None:
485493
raise Error("Response has been disposed")

playwright/_impl/_helper.py

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262

6363
ColorScheme = Literal["dark", "light", "no-preference", "null"]
6464
ForcedColors = Literal["active", "none", "null"]
65+
Contrast = Literal["more", "no-preference", "null"]
6566
ReducedMotion = Literal["no-preference", "null", "reduce"]
6667
DocumentLoadState = Literal["commit", "domcontentloaded", "load", "networkidle"]
6768
KeyboardModifier = Literal["Alt", "Control", "ControlOrMeta", "Meta", "Shift"]

playwright/_impl/_locator.py

+6
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ def __init__(
7070
has_not_text: Union[str, Pattern[str]] = None,
7171
has: "Locator" = None,
7272
has_not: "Locator" = None,
73+
visible: bool = None,
7374
) -> None:
7475
self._frame = frame
7576
self._selector = selector
@@ -95,6 +96,9 @@ def __init__(
9596
raise Error('Inner "has_not" locator must belong to the same frame.')
9697
self._selector += " >> internal:has-not=" + json.dumps(locator._selector)
9798

99+
if visible is not None:
100+
self._selector += f" >> visible={bool_to_js_bool(visible)}"
101+
98102
def __repr__(self) -> str:
99103
return f"<Locator frame={self._frame!r} selector={self._selector!r}>"
100104

@@ -338,6 +342,7 @@ def filter(
338342
hasNotText: Union[str, Pattern[str]] = None,
339343
has: "Locator" = None,
340344
hasNot: "Locator" = None,
345+
visible: bool = None,
341346
) -> "Locator":
342347
return Locator(
343348
self._frame,
@@ -346,6 +351,7 @@ def filter(
346351
has_not_text=hasNotText,
347352
has=has,
348353
has_not=hasNot,
354+
visible=visible,
349355
)
350356

351357
def or_(self, locator: "Locator") -> "Locator":

playwright/_impl/_page.py

+6
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
from playwright._impl._har_router import HarRouter
6161
from playwright._impl._helper import (
6262
ColorScheme,
63+
Contrast,
6364
DocumentLoadState,
6465
ForcedColors,
6566
HarMode,
@@ -608,6 +609,7 @@ async def emulate_media(
608609
colorScheme: ColorScheme = None,
609610
reducedMotion: ReducedMotion = None,
610611
forcedColors: ForcedColors = None,
612+
contrast: Contrast = None,
611613
) -> None:
612614
params = locals_to_params(locals())
613615
if "media" in params:
@@ -624,6 +626,10 @@ async def emulate_media(
624626
params["forcedColors"] = (
625627
"no-override" if params["forcedColors"] == "null" else forcedColors
626628
)
629+
if "contrast" in params:
630+
params["contrast"] = (
631+
"no-override" if params["contrast"] == "null" else contrast
632+
)
627633
await self._channel.send("emulateMedia", params)
628634

629635
async def set_viewport_size(self, viewportSize: ViewportSize) -> None:

0 commit comments

Comments
 (0)