From c157e0a0467ebe26dd3b4dcca19aaee4488b4504 Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Wed, 5 Feb 2025 11:38:22 +0100 Subject: [PATCH] fix(locator): fix is_enabled method --- playwright/_impl/_locator.py | 2 +- tests/async/test_fill.py | 9 ++++++++- tests/async/test_locators.py | 18 +++--------------- tests/sync/test_locators.py | 18 +++--------------- 4 files changed, 15 insertions(+), 32 deletions(-) diff --git a/playwright/_impl/_locator.py b/playwright/_impl/_locator.py index 91ea79064..1ad18f999 100644 --- a/playwright/_impl/_locator.py +++ b/playwright/_impl/_locator.py @@ -481,7 +481,7 @@ async def is_editable(self, timeout: float = None) -> bool: async def is_enabled(self, timeout: float = None) -> bool: params = locals_to_params(locals()) - return await self._frame.is_editable( + return await self._frame.is_enabled( self._selector, strict=True, **params, diff --git a/tests/async/test_fill.py b/tests/async/test_fill.py index 4dd6db321..c5f0a55be 100644 --- a/tests/async/test_fill.py +++ b/tests/async/test_fill.py @@ -22,7 +22,14 @@ async def test_fill_textarea(page: Page, server: Server) -> None: assert await page.evaluate("result") == "some value" -# +async def test_is_enabled_for_non_editable_button(page: Page) -> None: + await page.set_content( + """ + + """ + ) + button = page.locator("button") + assert await button.is_enabled() is True async def test_fill_input(page: Page, server: Server) -> None: diff --git a/tests/async/test_locators.py b/tests/async/test_locators.py index 385538461..aceb39991 100644 --- a/tests/async/test_locators.py +++ b/tests/async/test_locators.py @@ -128,27 +128,15 @@ async def test_locators_is_enabled_and_is_disabled_should_work(page: Page) -> No ) div = page.locator("div") - with pytest.raises( - Error, - match=r"Element is not an ,