Playwright getByRole() matches accessible descriptions
Introduced 2026-05-11 · score 0.97
HOW TO USE IT
When locating an element by role and accessible description, pass `description` in the `getByRole()` options. Playwright v1.60.0 added this option to page, locator, frame, and frame-locator methods.
await page.getByRole('<role>', { description: '<accessible description>' });await locator.getByRole('<role>', { description: '<accessible description>' });await frame.getByRole('<role>', { description: '<accessible description>' });WHY THIS HELPS
Locate an element by its role and accessible description in a page, locator, frame, or frame locator.
REQUIREMENTS AND LIMITATIONS
- Version: v1.60.0
- role (required): ARIA role to locate.
- description: String or RegExp matching the accessible description. String matching is case-insensitive substring matching by default.
- exact: Match the name and description exactly, case-sensitively and as whole strings; defaults to false. Ignored for RegExp values.
- Prerequisite: Use Playwright v1.60.0 or later for the `description` option.
FIRST-PARTY EVIDENCE
- https://github.com/microsoft/playwright/releases/tag/v1.60.0
- https://playwright.dev/docs/api/class-page#page-get-by-role
- https://playwright.dev/docs/api/class-locator#locator-get-by-role
- https://playwright.dev/docs/api/class-frame#frame-get-by-role
Check the installed version and the source before using it. Entry JSON