Skip to content
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

Ability to locate elements using accessibility values #9918

Closed
codeslord opened this issue Oct 14, 2021 · 4 comments
Closed

Ability to locate elements using accessibility values #9918

codeslord opened this issue Oct 14, 2021 · 4 comments
Labels
C-py G-w3c Requires change to W3C Spec

Comments

@codeslord
Copy link

🚀 Feature Proposal

With selenium 4, we should be able to locate elements using their accessibiliy attributes(ARIA) https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA mainly accessibility NAME

Motivation

I was trying to find the search box with the keyword search in google. After trying it in multiple ways, with relative locators etc I was not able to figure out a way to locate it using the keyword search eventhough it is available (refer to the below screenshot)

google_accessibility

Example

Something like this

from selenium import webdriver
from selenium.webdriver.support.relative_locator import locate_with
search_element = driver.find_elements(locate_with(By.ACCESSIBILITY, 'Search'))
@ghost ghost added the needs-triaging label Oct 14, 2021
@AutomatedTester
Copy link
Member

I agree that this is a great feature to have unfortunately it requires the 2 features below to be implemented by browser vendors as they would turn on the accessibility tree in the browser. Another way that we could do it when implemented is when the W3C WICG AOM spec has been shipped a bit more.

https://wpt.fyi/results/webdriver/tests/get_computed_label
https://wpt.fyi/results/webdriver/tests/get_computed_role

@AutomatedTester AutomatedTester added C-py G-w3c Requires change to W3C Spec and removed needs-triaging labels Oct 14, 2021
@crunchy-vonage
Copy link

Window.getComputedAccessibleNode(element) is now experimental in chrome, requires passing CLI flags.
See https://wicg.github.io/aom/caniuse.html for details

ChromeDevTools protocol also has direct support in format aria\role[name].
Note they ran benchmarks and decided doing this client side is too slow. So you might need more than get_computed_role as you would need to iterate though every element.
See: https://developer.chrome.com/blog/puppetaria/

I'd be interested in getting some Hacks/POC's running though, it's obviously going to take a long time to get browser support standardised so it would be able to experiment with proposed syntax and APIs.

@titusfortner
Copy link
Member

I'm going to close this in Selenium tracker. Essentially once it gets added to the spec, we'll implement it in Selenium, and the spec is tracking it here: w3c/webdriver#1441

Like David mentioned, it's all held up by the browser vendors not yet having provided access to the tree in the first place.

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked and limited conversation to collaborators Jan 26, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
C-py G-w3c Requires change to W3C Spec
Projects
None yet
Development

No branches or pull requests

4 participants