phone.accessibility reads the raw accessibility tree and turns it on or off
mid-session. Locators don’t need it: they use the tree on their own whenever the
phone has one.
UnsupportedError. Roles, property names,
actions and window types are platform-scoped: "android.button",
"android.focusable", "android.application".
accessibility.state()
Ask the phone whether the tree is on, and whether this session can turn it on and off.
Returns AccessibilityState.
accessibility.enable() and accessibility.disable()
Turn the tree on or off. Each returns once the phone confirms. With the tree
off, locators resolve by vision.
accessibility.enabled_at_allocation
Whether the tree was on when the phone was allocated, or None when unknown (a
sandbox). It doesn’t follow later enable() or disable() calls; state()
asks the phone.
accessibility.snapshot()
The tree of every window, or one window, in document order.
| Parameter | Type | Default | Description |
|---|---|---|---|
interesting_only | bool | True | False keeps the layout-only nodes the default drops. |
window_id | str | None | None | Only this window. |
depth | int | None | None | How far below each window root to go; 0 is the roots only. |
AXTree.
Raises UnsupportedError while the tree is off; TreeUnavailableError when
there is no app window to read (a system dialog is up).
accessibility.query()
Every visible node matching all the given criteria, in reading order. Never waits.
| Parameter | Type | Default | Description |
|---|---|---|---|
role | str | None | None | The role. |
name | str | None | None | The exact accessible name. |
selector | Locator | None | None | A phone locator’s selector fields. Its query and nth aren’t accepted, and its strategy options don’t apply. |
list[AXNode].
accessibility.partial()
One node, plus its ancestors, siblings and children unless fetch_relatives=False.
list[AXNode]. Raises StaleNodeError once the node is gone.
accessibility.children()
A node’s children.
list[AXNode]. Raises StaleNodeError once the node is gone.
Types
All are frozen dataclasses, importable fromhalyard.phone.
AXTree
AXNode
One node: the Chrome DevTools Protocol’sAXNode shape, plus bounds, window,
actions and native Android fields.
| Field | Type | Description |
|---|---|---|
node_id | str | Stable while the element lives. Pins a locator (phone.locator(node_id=...)) or seeds partial() and children(). |
ignored | bool | Whether the node is ignored for accessibility. |
role | AXValue | The role, such as android.button. |
child_ids | list[str] | The children’s ids. |
bounds | BBox | Screen pixels: the space phone.tap() uses. |
window_id | str | The window it is in. |
actions | list[str] | The actions it supports. |
name | AXValue | None | The accessible name. |
description | AXValue | None | The accessible description. |
value | AXValue | None | The current value. |
properties | list[AXProperty] | None | Named properties, such as android.checked. |
parent_id | str | None | The parent’s id. |
android | AXAndroidNode | None | Native Android fields. |
AXValue
| Field | Type | Description |
|---|---|---|
type | str | The value type, such as "role", "computedString" or "boolean". |
value | Any | A string, boolean or number. |
AXProperty
| Field | Type | Description |
|---|---|---|
name | str | The property name, such as android.focusable. |
value | AXValue | Its value. |
AXAndroidNode
The node’s native Android fields. Not portable to other platforms.| Field | Type |
|---|---|
class_name | str | None |
view_id_resource_name | str | None |
package_name | str | None |
text | str | None |
content_description | str | None |
hint_text | str | None |
AXWindow
| Field | Type | Description |
|---|---|---|
window_id | str | The window’s id. |
type | str | Platform-scoped, such as android.application, android.inputMethod or android.system. |
focused | bool | Whether it has focus. |
bounds | BBox | Screen pixels. |
title | str | None | The window title. |
app | str | None | The owning app’s package, when known. |
root_id | str | None | The root node’s id. |
AccessibilityState
| Field | Type | Description |
|---|---|---|
enabled | bool | Whether the tree is on. |
toggleable | bool | Whether this session can turn it on and off. |