diff --git a/playwright/_impl/_locator.py b/playwright/_impl/_locator.py
index 2c973eba8..b8a0d78da 100644
--- a/playwright/_impl/_locator.py
+++ b/playwright/_impl/_locator.py
@@ -588,6 +588,7 @@ async def screenshot(
lambda h, timeout: h.screenshot(
**{**params, "timeout": timeout},
),
+ timeout,
)
async def aria_snapshot(
diff --git a/tests/async/test_locators.py b/tests/async/test_locators.py
index 45293e5e6..60a3a2402 100644
--- a/tests/async/test_locators.py
+++ b/tests/async/test_locators.py
@@ -411,6 +411,13 @@ async def test_locators_should_screenshot(
)
+async def test_locators_screenshot_should_respect_timeout(page: Page) -> None:
+ page.set_default_timeout(5_000)
+ await page.set_content("
hello
")
+ with pytest.raises(Error, match="Locator.screenshot: Timeout 500ms exceeded."):
+ await page.locator("#missing").screenshot(timeout=500)
+
+
async def test_locators_should_return_bounding_box(page: Page, server: Server) -> None:
await page.set_viewport_size(
{
diff --git a/tests/sync/test_locators.py b/tests/sync/test_locators.py
index 1c191f826..fbcfc55c9 100644
--- a/tests/sync/test_locators.py
+++ b/tests/sync/test_locators.py
@@ -394,6 +394,13 @@ def test_locators_should_screenshot(
)
+def test_locators_screenshot_should_respect_timeout(page: Page) -> None:
+ page.set_default_timeout(5_000)
+ page.set_content("hello
")
+ with pytest.raises(Error, match="Locator.screenshot: Timeout 500ms exceeded."):
+ page.locator("#missing").screenshot(timeout=500)
+
+
def test_locators_should_return_bounding_box(page: Page, server: Server) -> None:
page.set_viewport_size(
{