AccessibilityElement

data class AccessibilityElement(val resourceName: String, val text: String, val contentDescription: String, val hintText: String?, val className: String, val packageName: String, val frame: Frame, val isEnabled: Boolean, val isVisibleToUser: Boolean, val isClickable: Boolean, val isLongClickable: Boolean, val isPassword: Boolean, val isFocused: Boolean, val isSelected: Boolean, val isChecked: Boolean, val isScrollable: Boolean, val depth: Int, val clickableAncestor: AccessibilityElement?)(source)

One accessibility node, read once into plain values.

Reading every field up front avoids the IPC round trip that each UiObject2 property access costs, so a whole screen can be queried quickly and consistently. Frames are in screen pixels.

Constructors

Link copied to clipboard
constructor(resourceName: String, text: String, contentDescription: String, hintText: String?, className: String, packageName: String, frame: Frame, isEnabled: Boolean, isVisibleToUser: Boolean, isClickable: Boolean, isLongClickable: Boolean, isPassword: Boolean, isFocused: Boolean, isSelected: Boolean, isChecked: Boolean, isScrollable: Boolean, depth: Int, clickableAncestor: AccessibilityElement?)

Properties

Link copied to clipboard

The widget class, such as android.widget.Button.

Link copied to clipboard

The nearest clickable ancestor, resolved while walking the tree.

Link copied to clipboard

The content description, or empty.

Link copied to clipboard
val depth: Int

The distance from the window root.

Link copied to clipboard

The bounds on screen.

Link copied to clipboard

The hint or placeholder, or null.

Link copied to clipboard

Whether the node is checked.

Link copied to clipboard

Whether the node handles clicks itself.

Link copied to clipboard

Whether the node accepts input.

Link copied to clipboard

Whether the node has input focus.

Link copied to clipboard

Whether the node handles long clicks.

Link copied to clipboard

Whether the node is a password field, whose text is masked.

Link copied to clipboard

Whether the node scrolls.

Link copied to clipboard

Whether the node is selected.

Link copied to clipboard

Whether any part of the node is on screen.

Link copied to clipboard

The text when present, otherwise the content description.

Link copied to clipboard

The package that owns the window.

Link copied to clipboard

The resource entry name, such as save for com.example:id/save, or empty.

Link copied to clipboard

The full view ID resource name, such as com.example:id/save, or empty.

Link copied to clipboard

The node's text, or empty.

Functions

Link copied to clipboard
fun matches(id: String? = null, text: String? = null, containsText: String? = null): Boolean

Returns whether this element matches every non-null selector.