Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions playwright/_impl/_locator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
6 changes: 4 additions & 2 deletions playwright/_impl/_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 9 additions & 0 deletions tests/async/test_locators.py
Original file line number Diff line number Diff line change
Expand Up @@ -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("<div>foo</div>")
div = page.locator("div")
assert await div.is_hidden(timeout=10) is False
assert await div.is_visible(timeout=10) is True
8 changes: 8 additions & 0 deletions tests/async/test_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -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("<div>foo</div>")
assert await page.is_hidden("div", timeout=10) is False
assert await page.is_visible("div", timeout=10) is True
9 changes: 9 additions & 0 deletions tests/sync/test_locators.py
Original file line number Diff line number Diff line change
Expand Up @@ -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("<div>foo</div>")
div = page.locator("div")
assert div.is_hidden(timeout=10) is False
assert div.is_visible(timeout=10) is True
8 changes: 8 additions & 0 deletions tests/sync/test_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -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("<div>foo</div>")
assert page.is_hidden("div", timeout=10) is False
assert page.is_visible("div", timeout=10) is True
Loading