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.
SubscribeRelated
LocatorPage.getByLabelPage.getByTextPage.getByPlaceholderPage.getByAltTextPage.getByTitlePage.getByTestIdLocator.filter