MCPcopy Create free account
hub / github.com/microsoft/playwright-python / test_locators_should_respect_nth

Function test_locators_should_respect_nth

tests/sync/test_locators.py:430–441  ·  view source on GitHub ↗
(page: Page)

Source from the content-addressed store, hash-verified

428
429
430def test_locators_should_respect_nth(page: Page) -> None:
431 page.set_content(
432 """
433 <section>
434 <div><p>A</p></div>
435 <div><p>A</p><p>A</p></div>
436 <div><p>A</p><p>A</p><p>A</p></div>
437 </section>"""
438 )
439 assert page.locator("div >> p").nth(0).count() == 1
440 assert page.locator("div").nth(1).locator("p").count() == 2
441 assert page.locator("div").nth(2).locator("p").count() == 3
442
443
444def test_locators_should_throw_on_capture_without_nth(page: Page) -> None:

Callers

nothing calls this directly

Calls 4

set_contentMethod · 0.45
countMethod · 0.45
nthMethod · 0.45
locatorMethod · 0.45

Tested by

no test coverage detected