MCPcopy Index your code
hub / github.com/microsoft/playwright-python / test_locators_should_screenshot

Function test_locators_should_screenshot

tests/sync/test_locators.py:379–394  ·  view source on GitHub ↗
(
    page: Page, server: Server, assert_to_be_golden: Callable[[bytes, str], None]
)

Source from the content-addressed store, hash-verified

377
378
379def test_locators_should_screenshot(
380 page: Page, server: Server, assert_to_be_golden: Callable[[bytes, str], None]
381) -> None:
382 page.set_viewport_size(
383 {
384 "width": 500,
385 "height": 500,
386 }
387 )
388 page.goto(server.PREFIX + "/grid.html")
389 page.evaluate("window.scrollBy(50, 100)")
390 element = page.locator(".box:nth-of-type(3)")
391 assert_to_be_golden(element.screenshot(), "screenshot-element-bounding-box.png")
392 assert_to_be_golden(
393 element.screenshot(timeout=1_000), "screenshot-element-bounding-box.png"
394 )
395
396
397def test_locators_should_return_bounding_box(page: Page, server: Server) -> None:

Callers

nothing calls this directly

Calls 6

assert_to_be_goldenFunction · 0.85
set_viewport_sizeMethod · 0.45
gotoMethod · 0.45
evaluateMethod · 0.45
locatorMethod · 0.45
screenshotMethod · 0.45

Tested by

no test coverage detected