Open OrKoN opened 1 year ago
One could argue that a very popular use case is to fetch an element via a11y name. WebdriverIO currently computes some complex xPath to make a good guess about it according to the spec but it doesn't work all time due to xPath limitations. It the would help a lot if this could be a primitive, e.g. a selector strategy.
I would love for this to be supported. Had a request posted in the interop issue with reasonings for it:
Currently, I would like to ensure a Web Component presents a role at a certain point in the layout tree. For example:
<x-button role=none> #shadowroot <input type=button aria-labelledby=slot> <slot id=slot></slot> </x-button>
And
<x-button role=button> #shadowroot <slot id=slot></slot> </x-button>
<x-button> <!-- role set via ElementInternals --> #shadowroot <slot id=slot></slot> </x-button>
It would make sense that the next "meaningful" ARIA role starting from
<x-button>
isbutton
. But there are multiple ways to achieve this, including hiding the attribute viaElementInternals
. I think I might be able to iterate the DOM and test each element manually, but I'm worried about closed shadowRoots. I have concerns with just iterating the DOM because I'm not really sure what's being exposed by the browsers to screen-readers. There might be groups or hidden nodes. The DOM and AXTree isn't guaranteed to be1:1
.There are many web testing suites that just read the DOM, which isn't accurate. Manually testing in the browser is somewhat tedious, but at this point has helped me recognize some browser bugs with computed labels:
I am also aware of other AXLabel bugs, but haven't had time to file them. But most of them deal in one way or another with complex trees.
- Use of a tree allows expanding testing beyond just
label
androle
.I recently found a mistake on my part where I had a custom element like above, but using
<input type=checkbox>
. I usedaria-checked=mixed
manually, assuming browsers did not apply.indeterminate
asaria-checked=mixed
. I probably had to do this with IE and it's just something I stuck with. When I used a tester (Playwright
) that exposes their own version of an AXTree, I learned of this Chrome bug:So, after having checked the aria tree with its properties, I was able to rewrite some code around make sure all the 3 majors browsers properly show
aria-checked=mixed
Related note (Option 4). I did write something a while ago to emulate a screen reader over a virtual COM port to test JAWS/NVDA, but getting it to work on anything but Windows was too hard of a task for me at the time so I abandoned it. The Webdriver solution seems good enough for me now.
Originally posted by @clshortfuse in https://github.com/web-platform-tests/interop-2023-accessibility-testing/issues/2#issuecomment-1621846981
The Browser Testing and Tools Working Group just discussed Accessibility module for WebDriver BiDi
.
Puppeteer exposes the information about the browser's a11y tree in a couple of ways:
1) via Accessibility.getFullAXTree to generate a snapshot of the a11y tree 2) ~via Accessibility.queryAXTree to query elements by the accessible name and role. This allows Puppeteer to implement element selectors based on the a11y tree data.~ solved via https://w3c.github.io/webdriver-bidi/#collect-nodes-using-accessibility-attributes
Additionally, there were requests recently to include A11y tree information into WebDriver https://goo.gle/chromedriver-a11ytree. I think we should discuss if we want to add these capabilities to WebDriver BiDi.