Playwright.Page.Accessibility (playwright v0.1.16-preview-1) View Source
Playwright.Page.Accessibility
provides functions for inspecting Chromium's accessibility tree.
The accessibility tree is used by assistive technology such as screen readers or switches.
Accessibility is a very platform-specific thing. On different platforms, there are different screen readers that might have wildly different output.
Rendering engines of Chromium, Firefox and WebKit have a concept of "accessibility tree", which is then translated into different platform-specific APIs. Accessibility namespace gives access to this Accessibility Tree.
Most of the accessibility tree gets filtered out when converting from internal browser AX Tree to Platform-specific AX-Tree or by assistive technologies themselves. By default, Playwright tries to approximate this filtering, exposing only the "interesting" nodes of the tree.
Link to this section Summary
Functions
Captures the current state of the accessibility tree.
Link to this section Types
Specs
opts() :: map()
Specs
Link to this section Functions
Specs
Captures the current state of the accessibility tree.
The returned object represents the root accessible node of the page.
Options
:interestingOnly
- Prune uninteresting nodes from the tree (default: true):root
- The root DOM element for the snapshot (default: page)
Examples
Dumping an entire accessibility tree:
iex> page = PlaywrightTest.Page.setup()
...> page
...> |> Playwright.Page.set_content("<p>Hello!</p>")
...> |> Playwright.Page.Accessibility.snapshot()
%{children: [%{name: "Hello!", role: "text"}], name: "", role: "WebArea"}
Retrieving the name of a focused node:
iex> page = PlaywrightTest.Page.setup()
...> body = "<input placeholder='pick me' autofocus /><input placeholder='not me' />"
...> page
...> |> Playwright.Page.set_content(body)
...> |> Playwright.Page.Accessibility.snapshot()
...> |> (&(Enum.find(&1.children, fn e -> e.focused end))).()
...> |> Map.get(:name)
"pick me"