Back to Daily Feed 
Cypress 16.2.0: Find Elements with `cy.getByRole()` for Better Accessibility
Worth Reading
Originally published on Cypress Blog
View Original Article
Share this article:

Summary & Key Takeaways
- Cypress 16.2.0 adds the new
cy.getByRole()command. - This command finds elements based on their ARIA role and accessible name.
- It helps align tests with how users perceive and interact with the UI.
- By default, it only matches native elements, catching semantic HTML issues.
- The article explains why this approach is beneficial for robust testing.
- It also guides users on migrating from Cypress Testing Library.
Our Commentary
This is a smart move from Cypress. Testing by role and accessible name is just better for catching real-world accessibility regressions. We've seen too many tests pass while the user experience crumbles. This pushes developers towards more semantic HTML, which is always a win.
View Original Article
Share this article: