Accessing the Accessibility tree with code

TLDR: How can I programmatically access the accessibility tree of a given web page? Is there any internal API that I can call via JavaScript to view the accessibility tree?

I am building a testing suite to check the correctness of accessibility within a web page. Currently we do this by comparing the DOM, and checking that certain attributes are present and correct. I would like to move away from using the DOM because that comes with a lot of extra data that needs to be traversed, and instead check only the a11y tree for correctness. This tree is found within the dev tools/inspector of most modern day web browsers, but I can not figure out how to check it with code. Thru my research, I have found that there is a new AOM (Accessibility Object Model) that is being suggested, but is not yet implemented. I have also found that the package ‘puppeteer’ has the ability to access it. Is there any way for me to access it directly?

60 thoughts on “Accessing the Accessibility tree with code”

Leave a Comment