# Find elements the way your users do with cy.getByRole()

DevFeed: [Find elements the way your users do with cy.getByRole()](<https://devfeed.tech/articles/find-elements-the-way-your-users-do-with-cy-getbyrole-87070.md>)

Original publisher: [Read original article](<https://www.cypress.io/blog/find-elements-the-way-your-users-do-with-cy-getbyrole/>)

Author: Jennifer Shehane

Published: 2026-10-14T17:54:38Z

Content type: article

Language: en

Sources: [Cypress Blog](<https://devfeed.tech/sources/cypress-blog.md>)

Topics: [ui-testing](<https://devfeed.tech/topics/ui-testing.md>), [Web Accessibility (a11y)](<https://devfeed.tech/topics/web-accessibility.md>), [aria](<https://devfeed.tech/topics/aria.md>), [Test automation](<https://devfeed.tech/topics/test-automation.md>), [axe-core](<https://devfeed.tech/topics/axe-core.md>), [testing-library](<https://devfeed.tech/topics/testing-library.md>)

Tags: [accessibility](<https://devfeed.tech/tags/accessibility.md>), [ai](<https://devfeed.tech/tags/ai.md>), [assistive-technology](<https://devfeed.tech/tags/assistive-technology.md>), [audits](<https://devfeed.tech/tags/audits.md>), [button](<https://devfeed.tech/tags/button.md>), [cypress](<https://devfeed.tech/tags/cypress.md>), [native](<https://devfeed.tech/tags/native.md>), [query](<https://devfeed.tech/tags/query.md>), [testing-library](<https://devfeed.tech/tags/testing-library.md>), [tests](<https://devfeed.tech/tags/tests.md>)

## AI overview

Cypress 16.2.0 adds `cy.getByRole()`, which locates elements by role and optional accessible name, retries like other Cypress queries, and yields all matches. By default, it selects native HTML elements where available, so replacing a `<button>` with `<div role="button">` can make a test fail and expose missing keyboard behavior; `{ native: false }` includes role-attribute elements when needed. Compared with Cypress Testing Library's `findByRole()`, it also uses chained `.filter()` for states such as checked or selected, and multiple matches must be narrowed explicitly. Existing Testing Library tests can migrate gradually, and the plugin can remain for other queries. Cypress Accessibility is a separate Cypress Cloud feature that audits page states reached by recorded tests, including elements not directly asserted; `cy.getByRole()` works without Cloud.

## Source excerpt

Cypress 16.2.0 adds cy.getByRole(), a built-in query that finds elements by role and accessible name. By default, it matches only native elements, so your tests catch a swapped for a . Here's why that matters, and how to move off Cypress Testing Library.