Skip to content
masterclass Buddy

Playwright · Method

page.getByTestId

page.getByTestId locates an element by its test ID and returns a Locator. It uses data-testid by default, but the test ID attribute can be configured.

Last updated

Since
v1.27

Syntax

page.getByTestId(testId)

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

Subscribe
  • locator
  • getByRole
  • getByText
  • getByLabel
  • getByPlaceholder
  • getByAltText
  • getByTitle
  • selectors.setTestIdAttribute

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