Skip to content
masterclass Buddy

Playwright · Method

page.getByRole

Page.getByRole creates a locator using an element's ARIA role and accessible name. Use it to find user-facing controls in a way that is less dependent on CSS classes or DOM structure.

Last updated

Since
v1.27

Syntax

page.getByRole(role, options)

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

Subscribe
  • Locator
  • Page.getByLabel
  • Page.getByText
  • Page.getByPlaceholder
  • Page.getByAltText
  • Page.getByTitle
  • Page.getByTestId
  • Locator.filter

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