sincecutoff.com
← all changes

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

Check the installed version and the source before using it. Entry JSON

Report a problem with this card