Skip to content

Support querying by whether an element is hidden in the ARIA tree - #34

Open
hovinen wants to merge 2 commits into
add-having-levelfrom
add-by_role-hidden
Open

hovinen wants to merge 2 commits into
add-having-levelfrom
add-by_role-hidden

Conversation

@hovinen

@hovinen hovinen commented Oct 2, 2026 •

Copy link
Copy Markdown
Collaborator

This uses the aria-hidden attribute which determines whether the node is hidden from assistive technology.

Items which are hidden from the ARIA altogether by virtue of the HTML hidden attribute or the CSS properties display: none or visibility: hidden still cannot be queried with by_role, since they do not appear in the ARIA tree at all as per specification.

Following Playwright, the default is now to exclude hidden elements, but one can include them (or restrict to match them only) via methods on QueryByRole.

@hovinen
hovinen added this pull request to stack #28 October 2, 2026 13:23
@hovinen
hovinen force-pushed the add-by_role-hidden branch from 805d6f1 to 8415e17 Compare October 2, 2026 13:33
@hovinen hovinen self-assigned this Oct 3, 2026
@hovinen
hovinen requested a review from ealmloff October 3, 2026 11:46
@hovinen
hovinen force-pushed the add-by_role-hidden branch from 6a7f952 to b4a4283 Compare October 16, 2026 19:03
This uses the `aria-hidden` attribute which determines whether the node
is hidden from assistive technology.

Items which are hidden from the ARIA altogether by virtue of the HTML
`hidden` attribute or the CSS properties `display: none` or
`visibility: hidden` still cannot be queried with `by_role`, since they
do not appear in the ARIA tree at all as per specification.
@hovinen
hovinen force-pushed the add-by_role-hidden branch from b4a4283 to 07f7a76 Compare October 23, 2026 07:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants