Skip to content

Commit 2df246a

Browse files
fix(locator): pass the timeout through in screenshot (#3232)
1 parent 693c92c commit 2df246a

3 files changed

Lines changed: 15 additions & 0 deletions

File tree

‎playwright/_impl/_locator.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,7 @@ async def screenshot(
588588
lambda h, timeout: h.screenshot(
589589
**{**params, "timeout": timeout},
590590
),
591+
timeout,
591592
)
592593

593594
async def aria_snapshot(

‎tests/async/test_locators.py‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,13 @@ async def test_locators_should_screenshot(
411411
)
412412

413413

414+
async def test_locators_screenshot_should_respect_timeout(page: Page) -> None:
415+
page.set_default_timeout(5_000)
416+
await page.set_content("<div>hello</div>")
417+
with pytest.raises(Error, match="Locator.screenshot: Timeout 500ms exceeded."):
418+
await page.locator("#missing").screenshot(timeout=500)
419+
420+
414421
async def test_locators_should_return_bounding_box(page: Page, server: Server) -> None:
415422
await page.set_viewport_size(
416423
{

‎tests/sync/test_locators.py‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,13 @@ def test_locators_should_screenshot(
394394
)
395395

396396

397+
def test_locators_screenshot_should_respect_timeout(page: Page) -> None:
398+
page.set_default_timeout(5_000)
399+
page.set_content("<div>hello</div>")
400+
with pytest.raises(Error, match="Locator.screenshot: Timeout 500ms exceeded."):
401+
page.locator("#missing").screenshot(timeout=500)
402+
403+
397404
def test_locators_should_return_bounding_box(page: Page, server: Server) -> None:
398405
page.set_viewport_size(
399406
{

0 commit comments

Comments
 (0)