capture

fun capture(packageName: String? = null, maxDepth: Int = DEFAULT_MAX_DEPTH, uiAutomation: UiAutomation = InstrumentationRegistry.getInstrumentation().uiAutomation): List<AccessibilityElement>(source)

Reads the current accessibility trees.

Clears the accessibility cache first on API 34+, so a navigation is never answered with the previous screen. Enables interactive-window retrieval so windows of apps other than the instrumentation target are included. That setting stays on for the rest of the test process.

Return

The elements, in depth-first order.

Parameters

packageName

When set, reads only windows whose root node belongs to this package and keeps only elements from it. Nodes of this package embedded in another package's window are not returned.

maxDepth

The maximum depth to walk from each window root.

uiAutomation

The automation connection to read from.