Skip to content

Commit 7e5f197

Browse files
authored
feat(roll): roll Playwright to 1.43.0-beta-1711484700000 (#2381)
1 parent 6a84c65 commit 7e5f197

16 files changed

+470
-37
lines changed

README.md

Lines changed: 2 additions & 2 deletions
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 -->123.0.6312.4<!-- GEN:stop --> ||||
7+
| Chromium <!-- GEN:chromium-version -->124.0.6367.8<!-- GEN:stop --> ||||
88
| WebKit <!-- GEN:webkit-version -->17.4<!-- GEN:stop --> ||||
9-
| Firefox <!-- GEN:firefox-version -->123.0<!-- GEN:stop --> ||||
9+
| Firefox <!-- GEN:firefox-version -->124.0<!-- GEN:stop --> ||||
1010

1111
## Documentation
1212

playwright/_impl/_browser_context.py

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
)
7171
from playwright._impl._network import Request, Response, Route, serialize_headers
7272
from playwright._impl._page import BindingCall, Page, Worker
73+
from playwright._impl._str_utils import escape_regex_flags
7374
from playwright._impl._tracing import Tracing
7475
from playwright._impl._waiter import Waiter
7576
from playwright._impl._web_error import WebError
@@ -302,8 +303,34 @@ async def cookies(self, urls: Union[str, Sequence[str]] = None) -> List[Cookie]:
302303
async def add_cookies(self, cookies: Sequence[SetCookieParam]) -> None:
303304
await self._channel.send("addCookies", dict(cookies=cookies))
304305

305-
async def clear_cookies(self) -> None:
306-
await self._channel.send("clearCookies")
306+
async def clear_cookies(
307+
self,
308+
name: Union[str, Pattern[str]] = None,
309+
domain: Union[str, Pattern[str]] = None,
310+
path: Union[str, Pattern[str]] = None,
311+
) -> None:
312+
await self._channel.send(
313+
"clearCookies",
314+
{
315+
"name": name if isinstance(name, str) else None,
316+
"nameRegexSource": name.pattern if isinstance(name, Pattern) else None,
317+
"nameRegexFlags": escape_regex_flags(name)
318+
if isinstance(name, Pattern)
319+
else None,
320+
"domain": domain if isinstance(domain, str) else None,
321+
"domainRegexSource": domain.pattern
322+
if isinstance(domain, Pattern)
323+
else None,
324+
"domainRegexFlags": escape_regex_flags(domain)
325+
if isinstance(domain, Pattern)
326+
else None,
327+
"path": path if isinstance(path, str) else None,
328+
"pathRegexSource": path.pattern if isinstance(path, Pattern) else None,
329+
"pathRegexFlags": escape_regex_flags(path)
330+
if isinstance(path, Pattern)
331+
else None,
332+
},
333+
)
307334

308335
async def grant_permissions(
309336
self, permissions: Sequence[str], origin: str = None

playwright/_impl/_js_handle.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from urllib.parse import ParseResult, urlparse, urlunparse
2121

2222
from playwright._impl._connection import Channel, ChannelOwner, from_channel
23+
from playwright._impl._errors import is_target_closed_error
2324
from playwright._impl._map import Map
2425

2526
if TYPE_CHECKING: # pragma: no cover
@@ -102,7 +103,11 @@ def as_element(self) -> Optional["ElementHandle"]:
102103
return None
103104

104105
async def dispose(self) -> None:
105-
await self._channel.send("dispose")
106+
try:
107+
await self._channel.send("dispose")
108+
except Exception as e:
109+
if not is_target_closed_error(e):
110+
raise e
106111

107112
async def json_value(self) -> Any:
108113
return parse_result(await self._channel.send("jsonValue"))

playwright/_impl/_locator.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,10 @@ def last(self) -> "Locator":
325325
def nth(self, index: int) -> "Locator":
326326
return Locator(self._frame, f"{self._selector} >> nth={index}")
327327

328+
@property
329+
def content_frame(self) -> "FrameLocator":
330+
return FrameLocator(self._frame, self._selector)
331+
328332
def filter(
329333
self,
330334
hasText: Union[str, Pattern[str]] = None,
@@ -817,6 +821,10 @@ def first(self) -> "FrameLocator":
817821
def last(self) -> "FrameLocator":
818822
return FrameLocator(self._frame, f"{self._frame_selector} >> nth=-1")
819823

824+
@property
825+
def owner(self) -> "Locator":
826+
return Locator(self._frame, self._frame_selector)
827+
820828
def nth(self, index: int) -> "FrameLocator":
821829
return FrameLocator(self._frame, f"{self._frame_selector} >> nth={index}")
822830

playwright/_impl/_network.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ def post_data_json(self) -> Optional[Any]:
169169
if not post_data:
170170
return None
171171
content_type = self.headers["content-type"]
172-
if content_type == "application/x-www-form-urlencoded":
172+
if "application/x-www-form-urlencoded" in content_type:
173173
return dict(parse.parse_qsl(post_data))
174174
try:
175175
return json.loads(post_data)

playwright/async_api/_generated.py

Lines changed: 95 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5862,6 +5862,32 @@ def last(self) -> "FrameLocator":
58625862
"""
58635863
return mapping.from_impl(self._impl_obj.last)
58645864

5865+
@property
5866+
def owner(self) -> "Locator":
5867+
"""FrameLocator.owner
5868+
5869+
Returns a `Locator` object pointing to the same `iframe` as this frame locator.
5870+
5871+
Useful when you have a `FrameLocator` object obtained somewhere, and later on would like to interact with the
5872+
`iframe` element.
5873+
5874+
For a reverse operation, use `locator.content_frame()`.
5875+
5876+
**Usage**
5877+
5878+
```py
5879+
frame_locator = page.frame_locator(\"iframe[name=\\\"embedded\\\"]\")
5880+
# ...
5881+
locator = frame_locator.owner
5882+
await expect(locator).to_be_visible()
5883+
```
5884+
5885+
Returns
5886+
-------
5887+
Locator
5888+
"""
5889+
return mapping.from_impl(self._impl_obj.owner)
5890+
58655891
def locator(
58665892
self,
58675893
selector_or_locator: typing.Union["Locator", str],
@@ -11669,9 +11695,11 @@ async def add_locator_handler(
1166911695
) -> None:
1167011696
"""Page.add_locator_handler
1167111697

11672-
When testing a web page, sometimes unexpected overlays like a coookie consent dialog appear and block actions you
11673-
want to automate, e.g. clicking a button. These overlays don't always show up in the same way or at the same time,
11674-
making them tricky to handle in automated tests.
11698+
**NOTE** This method is experimental and its behavior may change in the upcoming releases.
11699+
11700+
When testing a web page, sometimes unexpected overlays like a \"Sign up\" dialog appear and block actions you want to
11701+
automate, e.g. clicking a button. These overlays don't always show up in the same way or at the same time, making
11702+
them tricky to handle in automated tests.
1167511703

1167611704
This method lets you set up a special function, called a handler, that activates when it detects that overlay is
1167711705
visible. The handler's job is to remove the overlay, allowing your test to continue as if the overlay wasn't there.
@@ -11681,7 +11709,9 @@ async def add_locator_handler(
1168111709
a part of your normal test flow, instead of using `page.add_locator_handler()`.
1168211710
- Playwright checks for the overlay every time before executing or retrying an action that requires an
1168311711
[actionability check](https://playwright.dev/python/docs/actionability), or before performing an auto-waiting assertion check. When overlay
11684-
is visible, Playwright calls the handler first, and then proceeds with the action/assertion.
11712+
is visible, Playwright calls the handler first, and then proceeds with the action/assertion. Note that the
11713+
handler is only called when you perform an action/assertion - if the overlay becomes visible but you don't
11714+
perform any actions, the handler will not be triggered.
1168511715
- The execution time of the handler counts towards the timeout of the action/assertion that executed the handler.
1168611716
If your handler takes too long, it might cause timeouts.
1168711717
- You can register multiple handlers. However, only a single handler will be running at a time. Make sure the
@@ -11699,13 +11729,13 @@ async def add_locator_handler(
1169911729

1170011730
**Usage**
1170111731

11702-
An example that closes a cookie consent dialog when it appears:
11732+
An example that closes a \"Sign up to the newsletter\" dialog when it appears:
1170311733

1170411734
```py
1170511735
# Setup the handler.
1170611736
def handler():
11707-
page.get_by_role(\"button\", name=\"Reject all cookies\").click()
11708-
page.add_locator_handler(page.get_by_role(\"button\", name=\"Accept all cookies\"), handler)
11737+
page.get_by_role(\"button\", name=\"No thanks\").click()
11738+
page.add_locator_handler(page.get_by_text(\"Sign up to the newsletter\"), handler)
1170911739

1171011740
# Write the test as usual.
1171111741
page.goto(\"https://example.com\")
@@ -12319,13 +12349,40 @@ async def add_cookies(self, cookies: typing.Sequence[SetCookieParam]) -> None:
1231912349
await self._impl_obj.add_cookies(cookies=mapping.to_impl(cookies))
1232012350
)
1232112351

12322-
async def clear_cookies(self) -> None:
12352+
async def clear_cookies(
12353+
self,
12354+
*,
12355+
name: typing.Optional[typing.Union[str, typing.Pattern[str]]] = None,
12356+
domain: typing.Optional[typing.Union[str, typing.Pattern[str]]] = None,
12357+
path: typing.Optional[typing.Union[str, typing.Pattern[str]]] = None
12358+
) -> None:
1232312359
"""BrowserContext.clear_cookies
1232412360

12325-
Clears context cookies.
12361+
Removes cookies from context. Accepts optional filter.
12362+
12363+
**Usage**
12364+
12365+
```py
12366+
await context.clear_cookies()
12367+
await context.clear_cookies(name=\"session-id\")
12368+
await context.clear_cookies(domain=\"my-origin.com\")
12369+
await context.clear_cookies(path=\"/api/v1\")
12370+
await context.clear_cookies(name=\"session-id\", domain=\"my-origin.com\")
12371+
```
12372+
12373+
Parameters
12374+
----------
12375+
name : Union[Pattern[str], str, None]
12376+
Only removes cookies with the given name.
12377+
domain : Union[Pattern[str], str, None]
12378+
Only removes cookies with the given domain.
12379+
path : Union[Pattern[str], str, None]
12380+
Only removes cookies with the given path.
1232612381
"""
1232712382

12328-
return mapping.from_maybe_impl(await self._impl_obj.clear_cookies())
12383+
return mapping.from_maybe_impl(
12384+
await self._impl_obj.clear_cookies(name=name, domain=domain, path=path)
12385+
)
1232912386

1233012387
async def grant_permissions(
1233112388
self, permissions: typing.Sequence[str], *, origin: typing.Optional[str] = None
@@ -13798,6 +13855,7 @@ async def launch(
1379813855
devtools : Union[bool, None]
1379913856
**Chromium-only** Whether to auto-open a Developer Tools panel for each tab. If this option is `true`, the
1380013857
`headless` option will be set `false`.
13858+
Deprecated: Use [debugging tools](../debug.md) instead.
1380113859
proxy : Union[{server: str, bypass: Union[str, None], username: Union[str, None], password: Union[str, None]}, None]
1380213860
Network proxy settings.
1380313861
downloads_path : Union[pathlib.Path, str, None]
@@ -13955,6 +14013,7 @@ async def launch_persistent_context(
1395514013
devtools : Union[bool, None]
1395614014
**Chromium-only** Whether to auto-open a Developer Tools panel for each tab. If this option is `true`, the
1395714015
`headless` option will be set `false`.
14016+
Deprecated: Use [debugging tools](../debug.md) instead.
1395814017
proxy : Union[{server: str, bypass: Union[str, None], username: Union[str, None], password: Union[str, None]}, None]
1395914018
Network proxy settings.
1396014019
downloads_path : Union[pathlib.Path, str, None]
@@ -14538,6 +14597,32 @@ def last(self) -> "Locator":
1453814597
"""
1453914598
return mapping.from_impl(self._impl_obj.last)
1454014599

14600+
@property
14601+
def content_frame(self) -> "FrameLocator":
14602+
"""Locator.content_frame
14603+
14604+
Returns a `FrameLocator` object pointing to the same `iframe` as this locator.
14605+
14606+
Useful when you have a `Locator` object obtained somewhere, and later on would like to interact with the content
14607+
inside the frame.
14608+
14609+
For a reverse operation, use `frame_locator.owner()`.
14610+
14611+
**Usage**
14612+
14613+
```py
14614+
locator = page.locator(\"iframe[name=\\\"embedded\\\"]\")
14615+
# ...
14616+
frame_locator = locator.content_frame
14617+
await frame_locator.get_by_role(\"button\").click()
14618+
```
14619+
14620+
Returns
14621+
-------
14622+
FrameLocator
14623+
"""
14624+
return mapping.from_impl(self._impl_obj.content_frame)
14625+
1454114626
async def bounding_box(
1454214627
self, *, timeout: typing.Optional[float] = None
1454314628
) -> typing.Optional[FloatRect]:

0 commit comments

Comments
 (0)