From e793058ffa7f9f072a9dbaa32a4bc253511615cb Mon Sep 17 00:00:00 2001 From: Adam Gastineau Date: Thu, 26 Jun 2025 06:13:24 -0700 Subject: [PATCH] fix(api): ignore deprecated timeout arg provided to is_visible/hidden --- playwright/_impl/_locator.py | 6 ++---- playwright/_impl/_page.py | 6 ++++-- tests/async/test_locators.py | 9 +++++++++ tests/async/test_page.py | 8 ++++++++ tests/sync/test_locators.py | 9 +++++++++ tests/sync/test_page.py | 8 ++++++++ 6 files changed, 40 insertions(+), 6 deletions(-) diff --git a/playwright/_impl/_locator.py b/playwright/_impl/_locator.py index 6fe075130..a1ea180ed 100644 --- a/playwright/_impl/_locator.py +++ b/playwright/_impl/_locator.py @@ -501,19 +501,17 @@ async def is_enabled(self, timeout: float = None) -> bool: ) async def is_hidden(self, timeout: float = None) -> bool: - params = locals_to_params(locals()) + # timeout is deprecated and does nothing return await self._frame.is_hidden( self._selector, strict=True, - **params, ) async def is_visible(self, timeout: float = None) -> bool: - params = locals_to_params(locals()) + # timeout is deprecated and does nothing return await self._frame.is_visible( self._selector, strict=True, - **params, ) async def press( diff --git a/playwright/_impl/_page.py b/playwright/_impl/_page.py index 20bba35db..55ee44df2 100644 --- a/playwright/_impl/_page.py +++ b/playwright/_impl/_page.py @@ -447,12 +447,14 @@ async def is_enabled( async def is_hidden( self, selector: str, strict: bool = None, timeout: float = None ) -> bool: - return await self._main_frame.is_hidden(**locals_to_params(locals())) + # timeout is deprecated and does nothing + return await self._main_frame.is_hidden(selector=selector, strict=strict) async def is_visible( self, selector: str, strict: bool = None, timeout: float = None ) -> bool: - return await self._main_frame.is_visible(**locals_to_params(locals())) + # timeout is deprecated and does nothing + return await self._main_frame.is_visible(selector=selector, strict=strict) async def dispatch_event( self, diff --git a/tests/async/test_locators.py b/tests/async/test_locators.py index a5891f558..980de041f 100644 --- a/tests/async/test_locators.py +++ b/tests/async/test_locators.py @@ -1143,3 +1143,12 @@ async def test_locator_click_timeout_error_should_contain_call_log(page: Page) - "During handling of the above exception, another exception occurred" not in formatted_exception ) + + +async def test_locator_should_ignore_deprecated_is_hidden_and_visible_timeout( + page: Page, +) -> None: + await page.set_content("
foo
") + div = page.locator("div") + assert await div.is_hidden(timeout=10) is False + assert await div.is_visible(timeout=10) is True diff --git a/tests/async/test_page.py b/tests/async/test_page.py index 962a11e59..03907c4b9 100644 --- a/tests/async/test_page.py +++ b/tests/async/test_page.py @@ -1451,3 +1451,11 @@ async def test_page_pause_should_reset_custom_timeouts( server.set_route("/empty.html", lambda route: None) with pytest.raises(Error, match="Timeout 456ms exceeded."): await page.goto(server.EMPTY_PAGE) + + +async def test_page_should_ignore_deprecated_is_hidden_and_visible_timeout( + page: Page, +) -> None: + await page.set_content("
foo
") + assert await page.is_hidden("div", timeout=10) is False + assert await page.is_visible("div", timeout=10) is True diff --git a/tests/sync/test_locators.py b/tests/sync/test_locators.py index 31d7b174b..b554f0544 100644 --- a/tests/sync/test_locators.py +++ b/tests/sync/test_locators.py @@ -997,3 +997,12 @@ def test_locator_click_timeout_error_should_contain_call_log(page: Page) -> None "During handling of the above exception, another exception occurred" not in formatted_exception ) + + +def test_locator_should_ignore_deprecated_is_hidden_and_visible_timeout( + page: Page, +) -> None: + page.set_content("
foo
") + div = page.locator("div") + assert div.is_hidden(timeout=10) is False + assert div.is_visible(timeout=10) is True diff --git a/tests/sync/test_page.py b/tests/sync/test_page.py index 7550a80d1..e29c7cabc 100644 --- a/tests/sync/test_page.py +++ b/tests/sync/test_page.py @@ -114,3 +114,11 @@ def test_page_pause_should_reset_custom_timeouts( server.set_route("/empty.html", lambda route: None) with pytest.raises(Error, match="Timeout 456ms exceeded."): page.goto(server.EMPTY_PAGE) + + +def test_page_should_ignore_deprecated_is_hidden_and_visible_timeout( + page: Page, +) -> None: + page.set_content("
foo
") + assert page.is_hidden("div", timeout=10) is False + assert page.is_visible("div", timeout=10) is True