Skip to content
masterclass Buddy

Playwright · Method

locator.within

locator.within() returns a locator scoped inside each element matched by a parent locator. Relative locators such as nth() are resolved separately inside every parent.

Last updated

Since
v1.64

Syntax

locator.within(locator)

In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.

Subscribe
  • locator.nth
  • locator.first
  • get_by_role
  • expect(locator).to_have_text

Source: Locator | Playwright. Checked 2026-11-03.