Skip to content

Commit 241e06a

Browse files
chore: add repr for FrameLocator (microsoft#1018)
1 parent cd14696 commit 241e06a

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

playwright/_impl/_locator.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,3 +503,6 @@ def last(self) -> "FrameLocator":
503503

504504
def nth(self, index: int) -> "FrameLocator":
505505
return FrameLocator(self._frame, f"{self._frame_selector} >> nth={index}")
506+
507+
def __repr__(self) -> str:
508+
return f"<FrameLocator frame={self._frame!r} selector={self._frame_selector!r}>"

tests/sync/test_locators.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,10 @@ def test_locators_frame_should_work_with_iframe(page: Page, server: Server) -> N
496496
button.wait_for()
497497
assert button.inner_text() == "Hello iframe"
498498
button.click()
499+
assert (
500+
repr(page.frame_locator("iframe"))
501+
== f"<FrameLocator frame=<Frame name= url='{server.PREFIX}/empty.html'> selector='iframe'>"
502+
)
499503

500504

501505
def test_locators_frame_should_work_for_nested_iframe(

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