8000 fix(api): ignore deprecated timeout arg provided to is_visible/hidden… · microsoft/playwright-python@b7882d9 · GitHub
[go: up one dir, main page]

Skip to content

Commit b7882d9

Browse files
authored
fix(api): ignore deprecated timeout arg provided to is_visible/hidden (#2905)
1 parent 3713a32 commit b7882d9

File tree

6 files changed

+40
-6
lines changed

6 files changed

+40
-6
lines changed

playwright/_impl/_locator.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -501,19 +501,17 @@ async def is_enabled(self, timeout: float = None) -> bool:
501501
)
502502

503503
async def is_hidden(self, timeout: float = None) -> bool:
504-
params = locals_to_params(locals())
504+
# timeout is deprecated and does nothing
505505
return await self._frame.is_hidden(
506506
self._selector,
507507
strict=True,
508-
**params,
509508
)
510509

511510
async def is_visible(self, timeout: float = None) -> bool:
512-
params = locals_to_params(locals())
511+
# timeout is deprecated and does nothing
513512
return await self._frame.is_visible(
514513
self._selector,
515514
strict=True,
516-
**params,
517515
)
518516

519517
async def press(

playwright/_impl/_page.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -447,12 +447,14 @@ async def is_enabled(
447447
async def is_hidden(
448448
self, selector: str, strict: bool = None, timeout: float = None
449449
) -> bool:
450-
return await self._main_frame.is_hidden(**locals_to_params(locals()))
450+
# timeout is deprecated and does nothing
451+
return await self._main_frame.is_hidden(selector=selector, strict=strict)
451452

452453
async def is_visible(
453454
self, selector: str, strict: bool = None, timeout: float = None
454455
) -> bool:
455-
return await self._main_frame.is_visible(**locals_to_params(locals()))
456+
# timeout is deprecated and does nothing
457+
return await self._main_frame.is_visible(selector=selector, strict=strict)
456458

457459
async def dispatch_event(
458460
self,

tests/async/test_locators.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,3 +1143,12 @@ async def test_locator_click_timeout_error_should_contain_call_log(page: Page) -
11431143
"During handling of the above exception, another exception occurred"
11441144
not in formatted_exception
11451145
)
1146+
1147+
1148+
async def test_locator_should_ignore_deprecated_is_hidden_and_visible_timeout(
1149+
page: Page,
1150+
) -> None:
1151+
await page.set_content("<div>foo</div>")
1152+
div = page.locator("div")
1153+
assert await div.is_hidden(timeout=10) is False
1154+
assert await div.is_visible(timeout=10) is True

tests/async/test_page.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1451,3 +1451,11 @@ async def test_page_pause_should_reset_custom_timeouts(
14511451
server.set_route("/empty.html", lambda route: None)
14521452
with pytest.raises(Error, match="Timeout 456ms exceeded."):
14531453
await page.goto(server.EMPTY_PAGE)
1454+
1455+
1456+
async def test_page_should_ignore_deprecated_is_hidden_and_visible_timeout(
1457+
page: Page,
1458+
) -> None:
1459+
await page.set_content("<div>foo</div>")
1460+
assert await page.is_hidden("div", timeout=10) is False
1461+
assert await page.is_visible("div", timeout=10) is True

tests/sync/test_locators.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -997,3 +997,12 @@ def test_locator_click_timeout_error_should_contain_call_log(page: Page) -> None
997997
"During handling of the above exception, another exception occurred"
998998
not in formatted_exception
999999
)
1000+
1001+
1002+
def test_locator_should_ignore_deprecated_is_hidden_and_visible_timeout(
1003+
page: Page,
1004+
) -> None:
1005+
page.set_content("<div>foo</div>")
1006+
div = page.locator("div")
1007+
assert div.is_hidden(timeout=10) is False
1008+
assert div.is_visible(timeout=10) is True

tests/sync/test_page.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,11 @@ def test_page_pause_should_reset_custom_timeouts(
114114
server.set_route("/empty.html", lambda route: None)
115115
with pytest.raises(Error, match="Timeout 456ms exceeded."):
116116
page.goto(server.EMPTY_PAGE)
117+
118+
119+
def test_page_should_ignore_deprecated_is_hidden_and_visible_timeout(
120+
page: Page,
121+
) -> None:
122+
page.set_content("<div>foo</div>")
123+
assert page.is_hidden("div", timeout=10) is False
124+
assert page.is_visible("div", timeout=10) is True

0 commit comments

Comments
 (0)
0