Skip to content

Commit db390c6

Browse files
authored
chore: roll to 1.56.0 (#2986)
1 parent 6fa9500 commit db390c6

18 files changed

+286
-77
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 -->140.0.7339.16<!-- GEN:stop --> ||||
7+
| Chromium <!-- GEN:chromium-version -->141.0.7390.37<!-- GEN:stop --> ||||
88
| WebKit <!-- GEN:webkit-version -->26.0<!-- GEN:stop --> ||||
9-
| Firefox <!-- GEN:firefox-version -->141.0<!-- GEN:stop --> ||||
9+
| Firefox <!-- GEN:firefox-version -->142.0.1<!-- GEN:stop --> ||||
1010

1111
## Documentation
1212

playwright/_impl/_api_structures.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ class FrameExpectResult(TypedDict):
218218
matches: bool
219219
received: Any
220220
log: List[str]
221+
errorMessage: Optional[str]
221222

222223

223224
AriaRole = Literal[

playwright/_impl/_assertions.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,10 @@ async def _expect_impl(
8080
out_message = (
8181
f"{message} '{expected}'" if expected is not None else f"{message}"
8282
)
83+
error_message = result.get("errorMessage")
84+
error_message = f"\n{error_message}" if error_message else ""
8385
raise AssertionError(
84-
f"{out_message}\nActual value: {actual} {format_call_log(result.get('log'))}"
86+
f"{out_message}\nActual value: {actual}{error_message} {format_call_log(result.get('log'))}"
8587
)
8688

8789

playwright/_impl/_browser_context.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888

8989
class BrowserContext(ChannelOwner):
9090
Events = SimpleNamespace(
91+
# Deprecated in v1.56, never emitted anymore.
9192
BackgroundPage="backgroundpage",
9293
Close="close",
9394
Console="console",
@@ -117,7 +118,6 @@ def __init__(
117118
self._timeout_settings = TimeoutSettings(None)
118119
self._owner_page: Optional[Page] = None
119120
self._options: Dict[str, Any] = initializer["options"]
120-
self._background_pages: Set[Page] = set()
121121
self._service_workers: Set[Worker] = set()
122122
self._base_url: Optional[str] = self._options.get("baseURL")
123123
self._videos_dir: Optional[str] = self._options.get("recordVideo")
@@ -149,10 +149,6 @@ def __init__(
149149
)
150150
),
151151
)
152-
self._channel.on(
153-
"backgroundPage",
154-
lambda params: self._on_background_page(from_channel(params["page"])),
155-
)
156152

157153
self._channel.on(
158154
"serviceWorker",
@@ -658,10 +654,6 @@ def expect_page(
658654
) -> EventContextManagerImpl[Page]:
659655
return self.expect_event(BrowserContext.Events.Page, predicate, timeout)
660656

661-
def _on_background_page(self, page: Page) -> None:
662-
self._background_pages.add(page)
663-
self.emit(BrowserContext.Events.BackgroundPage, page)
664-
665657
def _on_service_worker(self, worker: Worker) -> None:
666658
worker._context = self
667659
self._service_workers.add(worker)
@@ -736,7 +728,7 @@ def _on_response(self, response: Response, page: Optional[Page]) -> None:
736728

737729
@property
738730
def background_pages(self) -> List[Page]:
739-
return list(self._background_pages)
731+
return []
740732

741733
@property
742734
def service_workers(self) -> List[Worker]:

playwright/_impl/_glob.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,12 @@ def glob_to_regex_pattern(glob: str) -> str:
2828
tokens.append("\\" + char if char in escaped_chars else char)
2929
i += 1
3030
elif c == "*":
31-
before_deep = glob[i - 1] if i > 0 else None
3231
star_count = 1
3332
while i + 1 < len(glob) and glob[i + 1] == "*":
3433
star_count += 1
3534
i += 1
36-
after_deep = glob[i + 1] if i + 1 < len(glob) else None
37-
is_deep = (
38-
star_count > 1
39-
and (before_deep == "/" or before_deep is None)
40-
and (after_deep == "/" or after_deep is None)
41-
)
42-
if is_deep:
43-
tokens.append("((?:[^/]*(?:/|$))*)")
44-
i += 1
35+
if star_count > 1:
36+
tokens.append("(.*)")
4537
else:
4638
tokens.append("([^/]*)")
4739
else:

playwright/_impl/_page.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
async_writefile,
8080
locals_to_params,
8181
make_dirs_for_file,
82+
parse_error,
8283
serialize_error,
8384
url_matches,
8485
)
@@ -344,8 +345,6 @@ def _on_close(self) -> None:
344345
self._is_closed = True
345346
if self in self._browser_context._pages:
346347
self._browser_context._pages.remove(self)
347-
if self in self._browser_context._background_pages:
348-
self._browser_context._background_pages.remove(self)
349348
self._dispose_har_routers()
350349
self.emit(Page.Events.Close, self)
351350

@@ -1434,6 +1433,23 @@ async def remove_locator_handler(self, locator: "Locator") -> None:
14341433
{"uid": uid},
14351434
)
14361435

1436+
async def requests(self) -> List[Request]:
1437+
request_objects = await self._channel.send("requests", None)
1438+
return [from_channel(r) for r in request_objects]
1439+
1440+
async def console_messages(self) -> List[ConsoleMessage]:
1441+
message_dicts = await self._channel.send("consoleMessages", None)
1442+
return [
1443+
ConsoleMessage(
1444+
{**event, "page": self._channel}, self._loop, self._dispatcher_fiber
1445+
)
1446+
for event in message_dicts
1447+
]
1448+
1449+
async def page_errors(self) -> List[Error]:
1450+
error_objects = await self._channel.send("pageErrors", None)
1451+
return [parse_error(error["error"]) for error in error_objects]
1452+
14371453

14381454
class Worker(ChannelOwner):
14391455
Events = SimpleNamespace(Close="close")

playwright/async_api/_generated.py

Lines changed: 47 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12254,6 +12254,49 @@ async def remove_locator_handler(self, locator: "Locator") -> None:
1225412254
await self._impl_obj.remove_locator_handler(locator=locator._impl_obj)
1225512255
)
1225612256

12257+
async def requests(self) -> typing.List["Request"]:
12258+
"""Page.requests
12259+
12260+
Returns up to (currently) 100 last network request from this page. See `page.on('request')` for more details.
12261+
12262+
Returned requests should be accessed immediately, otherwise they might be collected to prevent unbounded memory
12263+
growth as new requests come in. Once collected, retrieving most information about the request is impossible.
12264+
12265+
Note that requests reported through the `page.on('request')` request are not collected, so there is a trade off
12266+
between efficient memory usage with `page.requests()` and the amount of available information reported
12267+
through `page.on('request')`.
12268+
12269+
Returns
12270+
-------
12271+
List[Request]
12272+
"""
12273+
12274+
return mapping.from_impl_list(await self._impl_obj.requests())
12275+
12276+
async def console_messages(self) -> typing.List["ConsoleMessage"]:
12277+
"""Page.console_messages
12278+
12279+
Returns up to (currently) 200 last console messages from this page. See `page.on('console')` for more details.
12280+
12281+
Returns
12282+
-------
12283+
List[ConsoleMessage]
12284+
"""
12285+
12286+
return mapping.from_impl_list(await self._impl_obj.console_messages())
12287+
12288+
async def page_errors(self) -> typing.List["Error"]:
12289+
"""Page.page_errors
12290+
12291+
Returns up to (currently) 200 last page errors from this page. See `page.on('page_error')` for more details.
12292+
12293+
Returns
12294+
-------
12295+
List[Error]
12296+
"""
12297+
12298+
return mapping.from_impl_list(await self._impl_obj.page_errors())
12299+
1225712300

1225812301
mapping.register(PageImpl, Page)
1225912302

@@ -12297,13 +12340,7 @@ def on(
1229712340
f: typing.Callable[["Page"], "typing.Union[typing.Awaitable[None], None]"],
1229812341
) -> None:
1229912342
"""
12300-
**NOTE** Only works with Chromium browser's persistent context.
12301-
12302-
Emitted when new background page is created in the context.
12303-
12304-
```py
12305-
background_page = await context.wait_for_event(\"backgroundpage\")
12306-
```"""
12343+
This event is not emitted."""
1230712344

1230812345
@typing.overload
1230912346
def on(
@@ -12477,13 +12514,7 @@ def once(
1247712514
f: typing.Callable[["Page"], "typing.Union[typing.Awaitable[None], None]"],
1247812515
) -> None:
1247912516
"""
12480-
**NOTE** Only works with Chromium browser's persistent context.
12481-
12482-
Emitted when new background page is created in the context.
12483-
12484-
```py
12485-
background_page = await context.wait_for_event(\"backgroundpage\")
12486-
```"""
12517+
This event is not emitted."""
1248712518

1248812519
@typing.overload
1248912520
def once(
@@ -12679,9 +12710,7 @@ def browser(self) -> typing.Optional["Browser"]:
1267912710
def background_pages(self) -> typing.List["Page"]:
1268012711
"""BrowserContext.background_pages
1268112712

12682-
**NOTE** Background pages are only supported on Chromium-based browsers.
12683-
12684-
All existing background pages in the context.
12713+
Returns an empty list.
1268512714

1268612715
Returns
1268712716
-------
@@ -16617,7 +16646,7 @@ def and_(self, locator: "Locator") -> "Locator":
1661716646
The following example finds a button with a specific title.
1661816647

1661916648
```py
16620-
button = page.get_by_role(\"button\").and_(page.getByTitle(\"Subscribe\"))
16649+
button = page.get_by_role(\"button\").and_(page.get_by_title(\"Subscribe\"))
1662116650
```
1662216651

1662316652
Parameters

playwright/sync_api/_generated.py

Lines changed: 47 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12342,6 +12342,49 @@ def remove_locator_handler(self, locator: "Locator") -> None:
1234212342
self._sync(self._impl_obj.remove_locator_handler(locator=locator._impl_obj))
1234312343
)
1234412344

12345+
def requests(self) -> typing.List["Request"]:
12346+
"""Page.requests
12347+
12348+
Returns up to (currently) 100 last network request from this page. See `page.on('request')` for more details.
12349+
12350+
Returned requests should be accessed immediately, otherwise they might be collected to prevent unbounded memory
12351+
growth as new requests come in. Once collected, retrieving most information about the request is impossible.
12352+
12353+
Note that requests reported through the `page.on('request')` request are not collected, so there is a trade off
12354+
between efficient memory usage with `page.requests()` and the amount of available information reported
12355+
through `page.on('request')`.
12356+
12357+
Returns
12358+
-------
12359+
List[Request]
12360+
"""
12361+
12362+
return mapping.from_impl_list(self._sync(self._impl_obj.requests()))
12363+
12364+
def console_messages(self) -> typing.List["ConsoleMessage"]:
12365+
"""Page.console_messages
12366+
12367+
Returns up to (currently) 200 last console messages from this page. See `page.on('console')` for more details.
12368+
12369+
Returns
12370+
-------
12371+
List[ConsoleMessage]
12372+
"""
12373+
12374+
return mapping.from_impl_list(self._sync(self._impl_obj.console_messages()))
12375+
12376+
def page_errors(self) -> typing.List["Error"]:
12377+
"""Page.page_errors
12378+
12379+
Returns up to (currently) 200 last page errors from this page. See `page.on('page_error')` for more details.
12380+
12381+
Returns
12382+
-------
12383+
List[Error]
12384+
"""
12385+
12386+
return mapping.from_impl_list(self._sync(self._impl_obj.page_errors()))
12387+
1234512388

1234612389
mapping.register(PageImpl, Page)
1234712390

@@ -12383,13 +12426,7 @@ def on(
1238312426
self, event: Literal["backgroundpage"], f: typing.Callable[["Page"], "None"]
1238412427
) -> None:
1238512428
"""
12386-
**NOTE** Only works with Chromium browser's persistent context.
12387-
12388-
Emitted when new background page is created in the context.
12389-
12390-
```py
12391-
background_page = context.wait_for_event(\"backgroundpage\")
12392-
```"""
12429+
This event is not emitted."""
1239312430

1239412431
@typing.overload
1239512432
def on(
@@ -12529,13 +12566,7 @@ def once(
1252912566
self, event: Literal["backgroundpage"], f: typing.Callable[["Page"], "None"]
1253012567
) -> None:
1253112568
"""
12532-
**NOTE** Only works with Chromium browser's persistent context.
12533-
12534-
Emitted when new background page is created in the context.
12535-
12536-
```py
12537-
background_page = context.wait_for_event(\"backgroundpage\")
12538-
```"""
12569+
This event is not emitted."""
1253912570

1254012571
@typing.overload
1254112572
def once(
@@ -12701,9 +12732,7 @@ def browser(self) -> typing.Optional["Browser"]:
1270112732
def background_pages(self) -> typing.List["Page"]:
1270212733
"""BrowserContext.background_pages
1270312734

12704-
**NOTE** Background pages are only supported on Chromium-based browsers.
12705-
12706-
All existing background pages in the context.
12735+
Returns an empty list.
1270712736

1270812737
Returns
1270912738
-------
@@ -16680,7 +16709,7 @@ def and_(self, locator: "Locator") -> "Locator":
1668016709
The following example finds a button with a specific title.
1668116710

1668216711
```py
16683-
button = page.get_by_role(\"button\").and_(page.getByTitle(\"Subscribe\"))
16712+
button = page.get_by_role(\"button\").and_(page.get_by_title(\"Subscribe\"))
1668416713
```
1668516714

1668616715
Parameters

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.55.0-beta-1756314050000"
24+
driver_version = "1.56.0-beta-1759412259000"
2525

2626
base_wheel_bundles = [
2727
{

tests/async/test_assertions.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ async def test_to_have_values_fails_when_multiple_not_specified(
516516
)
517517
locator = page.locator("select")
518518
await locator.select_option(["B"])
519-
with pytest.raises(Error) as excinfo:
519+
with pytest.raises(AssertionError) as excinfo:
520520
await expect(locator).to_have_values(["R", "G"], timeout=500)
521521
assert "Error: Not a select element with a multiple attribute" in str(excinfo.value)
522522

@@ -530,7 +530,7 @@ async def test_to_have_values_fails_when_not_a_select_element(
530530
"""
531531
)
532532
locator = page.locator("input")
533-
with pytest.raises(Error) as excinfo:
533+
with pytest.raises(AssertionError) as excinfo:
534534
await expect(locator).to_have_values(["R", "G"], timeout=500)
535535
assert "Error: Not a select element with a multiple attribute" in str(excinfo.value)
536536

@@ -564,7 +564,7 @@ async def test_assertions_boolean_checked_with_intermediate_true_and_checked(
564564
await page.set_content("<input type=checkbox></input>")
565565
await page.locator("input").evaluate("e => e.indeterminate = true")
566566
with pytest.raises(
567-
Error, match="Can't assert indeterminate and checked at the same time"
567+
AssertionError, match="Can't assert indeterminate and checked at the same time"
568568
):
569569
await expect(page.locator("input")).to_be_checked(
570570
checked=False, indeterminate=True
@@ -658,7 +658,7 @@ async def test_assertions_locator_to_be_editable_throws(
658658
await page.goto(server.EMPTY_PAGE)
659659
await page.set_content("<button disabled>Text</button>")
660660
with pytest.raises(
661-
Error,
661+
AssertionError,
662662
match=r"Element is not an <input>, <textarea>, <select> or \[contenteditable\] and does not have a role allowing \[aria-readonly\]",
663663
):
664664
await expect(page.locator("button")).not_to_be_editable()

0 commit comments

Comments
 (0)