A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://playwright.dev/python/docs/api/class-accessibility below:

Accessibility | Playwright Python

Accessibility

Deprecated

This class is deprecated. Please use other libraries such as Axe if you need to test page accessibility. See our Node.js guide for integration with Axe.

The Accessibility class provides methods 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.

Deprecated snapshotAdded before v1.9 accessibility.snapshot

Deprecated

This method is deprecated. Please use other libraries such as Axe if you need to test page accessibility. See our Node.js guide for integration with Axe.

Captures the current state of the accessibility tree. The returned object represents the root accessible node of the page.

note

The Chromium accessibility tree contains nodes that go unused on most platforms and by most screen readers. Playwright will discard them as well for an easier to process tree, unless interesting_only is set to false.

Usage

An example of dumping the entire accessibility tree:

snapshot = page.accessibility.snapshot()
print(snapshot)
snapshot = await page.accessibility.snapshot()
print(snapshot)

An example of logging the focused node's name:

def find_focused_node(node):
if node.get("focused"):
return node
for child in (node.get("children") or []):
found_node = find_focused_node(child)
if found_node:
return found_node
return None

snapshot = page.accessibility.snapshot()
node = find_focused_node(snapshot)
if node:
print(node["name"])
def find_focused_node(node):
if node.get("focused"):
return node
for child in (node.get("children") or []):
found_node = find_focused_node(child)
if found_node:
return found_node
return None

snapshot = await page.accessibility.snapshot()
node = find_focused_node(snapshot)
if node:
print(node["name"])

Arguments

Returns


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4