Skip to content

Commit d27c485

Browse files
authored
chore: roll Playwright to 1.25.0 (microsoft#1494)
Resolves microsoft#1465.
1 parent 1afb553 commit d27c485

File tree

7 files changed

+150
-1
lines changed

7 files changed

+150
-1
lines changed

playwright/_impl/_assertions.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
from playwright._impl._api_structures import ExpectedTextValue, FrameExpectOptions
1919
from playwright._impl._fetch import APIResponse
20+
from playwright._impl._helper import is_textual_mime_type
2021
from playwright._impl._locator import Locator
2122
from playwright._impl._page import Page
2223
from playwright._impl._str_utils import escape_regex_flags
@@ -594,6 +595,13 @@ async def to_be_ok(
594595
log = "\n".join(log_list).strip()
595596
if log:
596597
message += f"\n Call log:\n{log}"
598+
599+
content_type = self._actual.headers.get("content-type")
600+
is_text_encoding = content_type and is_textual_mime_type(content_type)
601+
text = await self._actual.text() if is_text_encoding else None
602+
if text is not None:
603+
message += f"\n Response Text:\n{text[:1000]}"
604+
597605
raise AssertionError(message)
598606

599607
async def not_to_be_ok(self) -> None:

playwright/_impl/_helper.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,3 +362,12 @@ def is_file_payload(value: Optional[Any]) -> bool:
362362
and "mimeType" in value
363363
and "buffer" in value
364364
)
365+
366+
367+
TEXTUAL_MIME_TYPE = re.compile(
368+
r"^(text\/.*?|application\/(json|(x-)?javascript|xml.*?|ecmascript|graphql|x-www-form-urlencoded)|image\/svg(\+xml)?|application\/.*?(\+json|\+xml))(;\s*charset=.*)?$"
369+
)
370+
371+
372+
def is_textual_mime_type(mime_type: str) -> bool:
373+
return bool(TEXTUAL_MIME_TYPE.match(mime_type))

playwright/async_api/_generated.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2791,6 +2791,10 @@ async def snapshot(
27912791
) -> typing.Optional[typing.Dict]:
27922792
"""Accessibility.snapshot
27932793

2794+
**DEPRECATED** This method is deprecated. Please use other libraries such as [Axe](https://www.deque.com/axe/) if you
2795+
need to test page accessibility. See our Node.js [guide](https://playwright.dev/docs/accessibility-testing) for
2796+
integration with Axe.
2797+
27942798
Captures the current state of the accessibility tree. The returned object represents the root accessible node of the
27952799
page.
27962800

@@ -6233,6 +6237,10 @@ def once(
62336237
def accessibility(self) -> "Accessibility":
62346238
"""Page.accessibility
62356239

6240+
**DEPRECATED** This property is deprecated. Please use other libraries such as [Axe](https://www.deque.com/axe/) if you
6241+
need to test page accessibility. See our Node.js [guide](https://playwright.dev/docs/accessibility-testing) for
6242+
integration with Axe.
6243+
62366244
Returns
62376245
-------
62386246
Accessibility

playwright/sync_api/_generated.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2827,6 +2827,10 @@ def snapshot(
28272827
) -> typing.Optional[typing.Dict]:
28282828
"""Accessibility.snapshot
28292829

2830+
**DEPRECATED** This method is deprecated. Please use other libraries such as [Axe](https://www.deque.com/axe/) if you
2831+
need to test page accessibility. See our Node.js [guide](https://playwright.dev/docs/accessibility-testing) for
2832+
integration with Axe.
2833+
28302834
Captures the current state of the accessibility tree. The returned object represents the root accessible node of the
28312835
page.
28322836

@@ -6231,6 +6235,10 @@ def once(self, event: str, f: typing.Callable[..., None]) -> None:
62316235
def accessibility(self) -> "Accessibility":
62326236
"""Page.accessibility
62336237

6238+
**DEPRECATED** This property is deprecated. Please use other libraries such as [Axe](https://www.deque.com/axe/) if you
6239+
need to test page accessibility. See our Node.js [guide](https://playwright.dev/docs/accessibility-testing) for
6240+
integration with Axe.
6241+
62346242
Returns
62356243
-------
62366244
Accessibility

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
InWheel = None
3131
from wheel.bdist_wheel import bdist_wheel as BDistWheelCommand
3232

33-
driver_version = "1.25.0-alpha-1660067092000"
33+
driver_version = "1.25.0"
3434

3535

3636
def extractall(zip: zipfile.ZipFile, path: str) -> None:

tests/async/test_assertions.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,3 +609,61 @@ async def test_assertions_response_is_ok_fail(page: Page, server: Server) -> Non
609609
error_message = str(excinfo.value)
610610
assert ("→ GET " + server.PREFIX + "/unknown") in error_message
611611
assert "← 404 Not Found" in error_message
612+
613+
614+
async def test_should_print_response_with_text_content_type_if_to_be_ok_fails(
615+
page: Page, server: Server
616+
) -> None:
617+
server.set_route(
618+
"/text-content-type",
619+
lambda r: (
620+
r.setResponseCode(404),
621+
r.setHeader("content-type", "text/plain"),
622+
r.write(b"Text error"),
623+
r.finish(),
624+
),
625+
)
626+
server.set_route(
627+
"/no-content-type",
628+
lambda r: (
629+
r.setResponseCode(404),
630+
r.write(b"No content type error"),
631+
r.finish(),
632+
),
633+
)
634+
server.set_route(
635+
"/binary-content-type",
636+
lambda r: (
637+
r.setResponseCode(404),
638+
r.setHeader("content-type", "image/bmp"),
639+
r.write(b"Image content type error"),
640+
r.finish(),
641+
),
642+
)
643+
644+
response = await page.request.get(server.PREFIX + "/text-content-type")
645+
with pytest.raises(AssertionError) as excinfo:
646+
await expect(response).to_be_ok()
647+
error_message = str(excinfo.value)
648+
assert ("→ GET " + server.PREFIX + "/text-content-type") in error_message
649+
assert "← 404 Not Found" in error_message
650+
assert "Response Text:" in error_message
651+
assert "Text error" in error_message
652+
653+
response = await page.request.get(server.PREFIX + "/no-content-type")
654+
with pytest.raises(AssertionError) as excinfo:
655+
await expect(response).to_be_ok()
656+
error_message = str(excinfo.value)
657+
assert ("→ GET " + server.PREFIX + "/no-content-type") in error_message
658+
assert "← 404 Not Found" in error_message
659+
assert "Response Text:" not in error_message
660+
assert "No content type error" not in error_message
661+
662+
response = await page.request.get(server.PREFIX + "/binary-content-type")
663+
with pytest.raises(AssertionError) as excinfo:
664+
await expect(response).to_be_ok()
665+
error_message = str(excinfo.value)
666+
assert ("→ GET " + server.PREFIX + "/binary-content-type") in error_message
667+
assert "← 404 Not Found" in error_message
668+
assert "Response Text:" not in error_message
669+
assert "Image content type error" not in error_message

tests/sync/test_assertions.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,3 +596,61 @@ def test_assertions_response_is_ok_fail(page: Page, server: Server) -> None:
596596
error_message = str(excinfo.value)
597597
assert ("→ GET " + server.PREFIX + "/unknown") in error_message
598598
assert "← 404 Not Found" in error_message
599+
600+
601+
def test_should_print_response_with_text_content_type_if_to_be_ok_fails(
602+
page: Page, server: Server
603+
) -> None:
604+
server.set_route(
605+
"/text-content-type",
606+
lambda r: (
607+
r.setResponseCode(404),
608+
r.setHeader("content-type", "text/plain"),
609+
r.write(b"Text error"),
610+
r.finish(),
611+
),
612+
)
613+
server.set_route(
614+
"/no-content-type",
615+
lambda r: (
616+
r.setResponseCode(404),
617+
r.write(b"No content type error"),
618+
r.finish(),
619+
),
620+
)
621+
server.set_route(
622+
"/binary-content-type",
623+
lambda r: (
624+
r.setResponseCode(404),
625+
r.setHeader("content-type", "image/bmp"),
626+
r.write(b"Image content type error"),
627+
r.finish(),
628+
),
629+
)
630+
631+
response = page.request.get(server.PREFIX + "/text-content-type")
632+
with pytest.raises(AssertionError) as excinfo:
633+
expect(response).to_be_ok()
634+
error_message = str(excinfo.value)
635+
assert ("→ GET " + server.PREFIX + "/text-content-type") in error_message
636+
assert "← 404 Not Found" in error_message
637+
assert "Response Text:" in error_message
638+
assert "Text error" in error_message
639+
640+
response = page.request.get(server.PREFIX + "/no-content-type")
641+
with pytest.raises(AssertionError) as excinfo:
642+
expect(response).to_be_ok()
643+
error_message = str(excinfo.value)
644+
assert ("→ GET " + server.PREFIX + "/no-content-type") in error_message
645+
assert "← 404 Not Found" in error_message
646+
assert "Response Text:" not in error_message
647+
assert "No content type error" not in error_message
648+
649+
response = page.request.get(server.PREFIX + "/binary-content-type")
650+
with pytest.raises(AssertionError) as excinfo:
651+
expect(response).to_be_ok()
652+
error_message = str(excinfo.value)
653+
assert ("→ GET " + server.PREFIX + "/binary-content-type") in error_message
654+
assert "← 404 Not Found" in error_message
655+
assert "Response Text:" not in error_message
656+
assert "Image content type error" not in error_message

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy