Cypress adds the cy.getByRole() query
Introduced 2026-10-13 · score 0.99
HOW TO USE IT
When a Cypress test needs an element by ARIA role, optionally narrowed by accessible name, use `cy.getByRole(role, options)`; it retries until a match and chained assertions pass. By default it skips elements hidden from the accessibility tree and, for roles with native HTML elements, matches native elements only; set `hidden: true` or `native: false` to include those alternatives.
cy.getByRole('tab', { name: 'Billing' })WHY THIS HELPS
In a Cypress test, locate an element by its ARIA role and optionally its accessible name.
REQUIREMENTS AND LIMITATIONS
- Version: 16.2.0
- role (required): Role string to find, such as `button` or `tab`.
- options.name: Match elements whose accessible name matches; accepts a string, number, regular expression, or function.
- options.hidden: Defaults to `false`; set `true` to include elements hidden from the accessibility tree.
- options.native: Defaults to `true` for roles with a corresponding HTML element, otherwise `false`; set `false` to also match elements given the role through a `role` attribute. These options are alternatives for the native matching behavior, not mutually exclusive with `hidden`.
- Elements hidden from the accessibility tree are skipped unless `{ hidden: true }` is passed.
- For a role that HTML has an element for, only that element matches by default; pass `{ native: false }` to also match elements with a `role` attribute.
FIRST-PARTY EVIDENCE
- https://docs.cypress.io/app/references/changelog#16-2-0
- https://docs.cypress.io/api/commands/getbyrole
Check the installed version and the source before using it. Entry JSON