cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.
https://cypress.io
MIT License
46.72k stars 3.16k forks source link

Update actionability checks to require an accessible name and role #19139

Open junyper opened 2 years ago

junyper commented 2 years ago

What would you like?

Along the same lines of this feature request recently opened for Playwright, I'd like to propose extending the actionability checks for Cypress to include (optionally) checking for an accessible name and role.

Relevant details from the Playwright issue:

Accessible name and role are synthesized by the browser into an accessibility tree, and normally (with the exception of experimental AOM in Chrome) aren't available to JS. However, there's work to recreate the browser accessible name and role computation in JS, e.g. https://github.com/eps1lon/dom-accessibility-api, that could be used here.

Why is this needed?

By adding this capability to the built-in actionability checks in Cypress, users could enable this for their test suite and find accessibility issues without needing to rewrite their existing tests to use better element selectors (via testing-library or similar) or run axe-core validations.

With this feature enabled, my existing test suite will automatically time out if the application is not accessible to screen readers or other assistive tech due to missing accessible names and role for actionable elements.

Other

Ideally this would be configurable via the global actionability config, via actionability options passed to cy.visit, and also at the individual selector level, but the existing force: true might be an acceptable solution.

chbdetta commented 2 years ago

could we have custom actionability check too?

787681277 commented 1 year ago

Is there any way to get element's accessible name and role?