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
feat(accessibility): snapshot the accessibility tree #3470
feat(accessibility): snapshot the accessibility tree #3470
Conversation
* @return {boolean} | ||
*/ | ||
_isPlainTextField() { | ||
if (this._richlyEditable) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we get a test for this? a
lib/Accessibility.js
Outdated
*/ | ||
_hasFocusableChild() { | ||
for (const child of this._children) { | ||
if (child._focusable || child._hasFocusableChild()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
O(n^2)!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cached
test/accessibility.spec.js
Outdated
const {it, fit, xit} = testRunner; | ||
const {beforeAll, beforeEach, afterAll, afterEach} = testRunner; | ||
|
||
fdescribe('Accessibility', function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it'll probably won't happy...
docs/api.md
Outdated
@@ -3431,3 +3502,5 @@ TimeoutError is emitted whenever certain operations are terminated due to timeou | |||
[UnixTime]: https://en.wikipedia.org/wiki/Unix_time "Unix Time" | |||
[SecurityDetails]: #class-securitydetails "SecurityDetails" | |||
[Worker]: #class-worker "Worker" | |||
[Accessibility]: #class-accessibility "Accessibility" | |||
[AXNode]: #accessibilitysnapshotoptions "Accessibility" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AXNode
docs/api.md
Outdated
An example of logging the focused node's name: | ||
```js | ||
const snapshot = await page.accessibility.snapshot(); | ||
const node = findNode(snapshot, node => node.focused); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
findFocusedNode?
The heuristics don't seem very accurate, especially with regards to editable nodes. I'm going to write some more tests and compare against NVDA on windows. |
@@ -1982,6 +1988,71 @@ Shortcut for [(await worker.executionContext()).evaluateHandle(pageFunction, ... | |||
#### worker.url() | |||
- returns: <[string]> | |||
|
|||
### class: Accessibility |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Accessibility is a very platform-specific thing. On different platforms, there are different screen readers that might have wildly different output.
Blink - Chrome's rendering engine - has a concept of "accessibility tree", which is than translated into different platform-specific APIs. Accessibility namespace gives users
access to the Blink Accessibility Tree.
Most of the accessibility tree gets filtered out when converting from Blink AX Tree to Platform-specific AX-Tree or by screen readers themselves. By default, Puppeteer tries to approximate this filtering, exposing only the "interesting" nodes of the tree.
lib/Accessibility.js
Outdated
break; | ||
} | ||
|
||
if (this._role === 'combobox' && !this._expanded) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Here and below: android heuristics
This adds
page.accessibility.snapshot()
. It serializes and returns the accessibility tree for the page. By default, uninteresting nodes are filtered out of the snapshot.fixes #2033