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.
tree = phone.accessibility.snapshot()
for node in tree.nodes:
    if node.role.value == "android.button":
        print(node.node_id, node.name.value if node.name else "", node.bounds)
The domain exists only on phones whose handshake advertises it. On any other session every method here raises 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.
accessibility.snapshot(*, interesting_only=True, window_id=None, depth=None)
ParameterTypeDefaultDescription
interesting_onlyboolTrueFalse keeps the layout-only nodes the default drops.
window_idstr | NoneNoneOnly this window.
depthint | NoneNoneHow far below each window root to go; 0 is the roots only.
Returns 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.
accessibility.query(*, role=None, name=None, selector=None)
ParameterTypeDefaultDescription
rolestr | NoneNoneThe role.
namestr | NoneNoneThe exact accessible name.
selectorLocator | NoneNoneA phone locator’s selector fields. Its query and nth aren’t accepted, and its strategy options don’t apply.
Returns list[AXNode].

accessibility.partial()

One node, plus its ancestors, siblings and children unless fetch_relatives=False.
accessibility.partial(node_id, *, fetch_relatives=True)
Returns list[AXNode]. Raises StaleNodeError once the node is gone.

accessibility.children()

A node’s children.
accessibility.children(node_id)
Returns list[AXNode]. Raises StaleNodeError once the node is gone.

Types

All are frozen dataclasses, importable from halyard.phone.

AXTree

FieldTypeDescription
nodeslist[AXNode]Every node, in document order.
windowslist[AXWindow]The windows on screen.
captured_atdatetimeWhen the tree was read, in UTC.

AXNode

One node: the Chrome DevTools Protocol’s AXNode shape, plus bounds, window, actions and native Android fields.
FieldTypeDescription
node_idstrStable while the element lives. Pins a locator (phone.locator(node_id=...)) or seeds partial() and children().
ignoredboolWhether the node is ignored for accessibility.
roleAXValueThe role, such as android.button.
child_idslist[str]The children’s ids.
boundsBBoxScreen pixels: the space phone.tap() uses.
window_idstrThe window it is in.
actionslist[str]The actions it supports.
nameAXValue | NoneThe accessible name.
descriptionAXValue | NoneThe accessible description.
valueAXValue | NoneThe current value.
propertieslist[AXProperty] | NoneNamed properties, such as android.checked.
parent_idstr | NoneThe parent’s id.
androidAXAndroidNode | NoneNative Android fields.

AXValue

FieldTypeDescription
typestrThe value type, such as "role", "computedString" or "boolean".
valueAnyA string, boolean or number.

AXProperty

FieldTypeDescription
namestrThe property name, such as android.focusable.
valueAXValueIts value.

AXAndroidNode

The node’s native Android fields. Not portable to other platforms.
FieldType
class_namestr | None
view_id_resource_namestr | None
package_namestr | None
textstr | None
content_descriptionstr | None
hint_textstr | None

AXWindow

FieldTypeDescription
window_idstrThe window’s id.
typestrPlatform-scoped, such as android.application, android.inputMethod or android.system.
focusedboolWhether it has focus.
boundsBBoxScreen pixels.
titlestr | NoneThe window title.
appstr | NoneThe owning app’s package, when known.
root_idstr | NoneThe root node’s id.

AccessibilityState

FieldTypeDescription
enabledboolWhether the tree is on.
toggleableboolWhether this session can turn it on and off.