-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Add support for implicit role selectors #6363
Comments
Would like to work on this enhancement Solution planning to implement: [role=button] => button || [role='button'] || input[role='button'] Catch i could foresee : could not find all default/implicit tags list which have mapping to roles (eg: role=button can be ,) Note: if there is any other solution please share that as well |
The difficulty here is how do you find the computed role of that element? I think what @solimant is describing is being able to find an element that has a computed role of <button>Click me</button> if the element already has that role assigned like <button role="button">Click me</button> It would be an easy xpath change. But this way it is much more difficult because getting the accessibility tree is not trivial |
@christian-bromann Able to get implicit role based element detail by using Also i'm able to convert that detail into XPATH locator. will raise PR in a day or two eg:
|
This has been merged and will be released in |
Why can JavaScript locate an element with a role="link" but WebDriver API cannot? A: In JavaScript, it is possible to locate elements with an explicit ARIA role attribute, even if it doesn't exist in the HTML code of the page. This is because modern browsers implement the WAI-ARIA specification, which allows web developers to add roles, states, and properties to HTML elements to improve accessibility. Therefore, if you use JavaScript to locate a link element using the "link" WAI-ARIA role attribute, the browser will be able to find the element even if it doesn't have an explicit role attribute in the HTML code of the page. On the other hand, with the WebDriver API, if the WAI-ARIA role attribute is not explicit, it will not be taken into account when searching for elements on the page, because the search is based on the DOM of the page. If the element doesn't have an explicit WAI-ARIA role attribute, it won't be possible to locate it using WAI-ARIA roles. |
I believe this should be reopened. Reading DOM is not accurate. You actually need to parse the accessibility tree. Web Components that use Similarly, just because something is referenced via The proper way to get the Accessible Role and Accessible Label is either iterate the accessibility tree or use Telling devs |
@clshortfuse you are absolutely right, however we can't call
I am not aware of any JS interface that would allow to return the accessibility tree, even then if the tree returns 1000 elements it would be not feasible to call |
Just fyi: I requested a selector strategy for elements with with accessibility name: w3c/webdriver-bidi#443 |
@christian-bromann Thanks! I didn't really find AXTree being planned so I threw a comment over at web-platform-tests/interop-accessibility#2 (comment) (though I could just be bad at searching.) I've been using playwright to test AX trees on Firefox and Webkit, but found a couple of bugs in their implementation. The playwright team has some custom patches for Webkit which is where their magic is. But they've deprecated AX tree snapshotting, so I'm looking for another viable solution. |
WebdriverIO is based on web standards and doesn't do any monkey patching of browsers to give you the ability to test in a browser that none of your users use. I am working with the WG to get this landed cross browser so keep an eye on the issue I've shared 😉 |
Is your feature request related to a problem? Please describe.
I'm always frustrated when I'm unable to select HTML elements by their implicit/default ARIA roles.
Describe the solution you'd like
Would like to be able to select an element (e.g. a
button
) by its implicit role:Describe alternatives you've considered
No alternatives. Setting the element's implicit role explicitly on the element is not recommended practice.
Additional context
The purpose of this feature is to keep tests agnostic of any implementation, especially if implementation of a certain UI changes over time; e.g. a button implementation changes from being a
button
element to alabel
element with a "button" role. Without the ability to select by role, all tests will have to be changed.The text was updated successfully, but these errors were encountered: