Skip to content
masterclass Buddy

Playwright · Method

locator.first

locator.first returns a locator for the first element matched by another locator. It is useful when one element must be chosen from several matches, but a unique locator is usually safer.

Last updated

Since
v1.14

Syntax

locator.first()

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

Subscribe
  • locator.last
  • locator.nth
  • locator.filter
  • page.getByRole

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