-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature]: Resolve Elements with aria-owns and aria-controls as Children in getByRole Method #34348
Comments
We discussed this proposal during our team meeting today. While we see the value in enhancing the getByRole method to account for ARIA relationships, we decided that we are not ready to change the current behavior of locators to expand beyond the DOM tree and consider the ARIA tree at this time. That said, we will keep this request open for future consideration as we revisit this area. In the meantime, we recommend exploring the |
@yury-s Thanks for suggesting to use the toHaveAriaSnapshot method. While it’s helpful, we believe it’s better suited for unit testing, which is not our focus here. What we are focus for is to give developers the ability to perform complete end-to-end (E2E) tests. This means they need to interact directly with elements that are considered children in the accessibility tree. The snapshot method does not achieve this goal since it loss the continuity needed for E2E testing. The ariaChildren feature is more recommended for E2E tests and does not break any current behavior. It’s safe because it is only activated when the flag is enabled. Adding this option would improve Playwright by supporting scenarios where developers want to build tests based on the accessibility tree, which aligns with the purpose of the getByRole method. |
🚀 Feature Request
We propose adding a feature to the
getByRole
method in Playwright to include anariaChildren
option. This option would allow developers to locate elements referenced by ARIA attributes likearia-owns
andaria-controls
, even when these elements are not direct children in the DOM.Proposed Solution:
Introduce an
ariaChildren
option to thegetByRole
method. When enabled, this option will include elements referenced by ARIA attributes in the search scope.Example
Consider the following DOM structure:
Using the
ariaChildren
option, developers can locate elements like this:Motivation
Currently, elements referenced by
aria-owns
oraria-controls
attributes are not included in the search scope by default. Without this functionality, it becomes challenging to test and validate these relationships effectively.The text was updated successfully, but these errors were encountered: