# androidx.test.uiautomator

*** ** * ** ***

## Interfaces

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/Condition` | Represents a condition to be satisfied. |
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/IAutomationSupport` | Provides auxiliary support for running test cases |
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/Searchable` | The Searchable interface represents an object that can be searched for matching UI elements. |
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiAccessibilityValidator` | A validator that runs during test actions to check the accessibility of the UI. |
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiWatcher` | See `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiDevice#registerWatcher(java.lang.String,androidx.test.uiautomator.UiWatcher)` on how to register a a condition watcher to be called by the automation library. |

## Classes

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/By` | `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/By` is a utility class which enables the creation of `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector`s in a concise manner. |
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/By.Window` | This nested class is used to create a `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/ByWindowSelector` that matches a window. |
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector` | A `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector` specifies criteria for matching UI elements during a call to `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiDevice#findObject(androidx.test.uiautomator.BySelector)`. |
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/ByWindowSelector` | A `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/ByWindowSelector` specifies criteria for matching UI windows during a call to `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiDevice#findWindow(androidx.test.uiautomator.ByWindowSelector)`. |
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/Configurator` | Allows you to set key parameters for running UiAutomator tests. |
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/EventCondition` | An `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/EventCondition` is a condition which depends on an event or series of events having occurred. |
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/ResultsReporter` | Allows to report test results to Android Studio. |
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/SearchCondition` | A `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/SearchCondition` is a condition that is satisfied by searching for UI elements. |
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/StableResult` | Represents a node that is considered stable and it's returned by `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(android.view.accessibility.AccessibilityNodeInfo).waitForStable(kotlin.Long,kotlin.Long,kotlin.Long,kotlin.Boolean)`. |
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiAutomatorInstrumentationTestRunner` | **This class is deprecated.** as it only handles deprecated `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiAutomatorTestCase`s. <br /> |
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiAutomatorTestCase` | **This class is deprecated.** It is no longer necessary to extend UiAutomatorTestCase. <br /> |
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiAutomatorTestScope` | A UiAutomator scope that allows to easily access UiAutomator api and utils class. |
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiCollection` | Used to enumerate a container's UI elements for the purpose of counting, or targeting a sub elements by a child's text or description. |
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiDevice` | UiDevice provides access to state information about the device. |
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject` | A UiObject is a representation of a view. |
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2` | Represents a UI element, and exposes methods for performing gestures (clicks, swipes) or searching through its children. |
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2Condition` | A `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2Condition` is a condition which is satisfied when a `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2` is in a particular state. |
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiScrollable` | UiScrollable is a `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiCollection` and provides support for searching for items in scrollable layout elements. |
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiSelector` | Specifies the elements in the layout hierarchy for tests to target, filtered by properties such as text value, content-description, class name, and state information. |
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiWindow` | Represents a UI window on the screen and provides methods to access its properties and perform actions. |
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/Until` | The `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/Until` class provides factory methods for constructing common conditions. |

## Exceptions

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/ElementNotFoundException` | Thrown when an element is not found after invoking `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(android.view.accessibility.AccessibilityNodeInfo).onElement(kotlin.Long,kotlin.Long,kotlin.Function1)` or `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(android.view.accessibility.AccessibilityNodeInfo).onElements(kotlin.Long,kotlin.Long,kotlin.Function1)`. |
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/StaleObjectException` | A `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/StaleObjectException` exception is thrown when a `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2` is used after the underlying `https://developer.android.com/reference/android/view/View.html` has been destroyed. |
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObjectNotFoundException` | Generated in test runs when a `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiSelector` selector could not be matched to any UI element displayed. |

## Enums

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/Direction` | An enumeration used to specify the primary direction of certain gestures. |

## Top-level functions summary

|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#uiAutomator(kotlin.Function1)(block: https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiAutomatorTestScope.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)` Main entry point for ui automator tests. |

## Extension functions summary

|---|---|
| `https://developer.android.com/reference/android/view/accessibility/AccessibilityWindowInfo.html` | `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiDevice.https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(androidx.test.uiautomator.UiDevice).activeWindow()()` Returns the active window. |
| `https://developer.android.com/reference/android/graphics/Rect.html` | `https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.html.https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(android.view.accessibility.AccessibilityNodeInfo).boundsInScreen()()` Returns the bounds of this node in screen coordinates. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.html>` | `https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.html.https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(android.view.accessibility.AccessibilityNodeInfo).children(kotlin.Function1)( block: (https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.html) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html )` Returns all the immediate children of this node. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.html>` | `https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.html.https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(android.view.accessibility.AccessibilityNodeInfo).descendants(kotlin.Function1)( filterBlock: (https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.html) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html )` Performs a DFS on the accessibility tree starting from this node and returns all the descendants discovered recursively. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.html.https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(android.view.accessibility.AccessibilityNodeInfo).isClass(java.lang.Class)(cls: https://developer.android.com/reference/java/lang/Class.html<*>)` Returns whether this node class name is the same of the given class. |
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2` | `https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.html.https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(android.view.accessibility.AccessibilityNodeInfo).onElement(kotlin.Long,kotlin.Long,kotlin.Function1)( timeoutMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, pollIntervalMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, block: https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.html.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html )` Performs a DFS on the accessibility tree starting from this node and returns the first node matching the given `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(android.view.accessibility.AccessibilityNodeInfo).onElement(kotlin.Long,kotlin.Long,kotlin.Function1)`. |
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2` | `https://developer.android.com/reference/android/view/accessibility/AccessibilityWindowInfo.html.https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(android.view.accessibility.AccessibilityWindowInfo).onElement(kotlin.Long,kotlin.Long,kotlin.Function1)( timeoutMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, pollIntervalMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, block: https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.html.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html )` Performs a DFS on the accessibility tree starting from the root node of this window and returns the first node matching the given `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(android.view.accessibility.AccessibilityWindowInfo).onElement(kotlin.Long,kotlin.Long,kotlin.Function1)`. |
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2` | `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiDevice.https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(androidx.test.uiautomator.UiDevice).onElement(kotlin.Long,kotlin.Long,kotlin.Function1)( timeoutMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, pollIntervalMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, block: https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.html.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html )` Performs a DFS on the accessibility tree starting from the root node in the active window and returns the first node matching the given `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(androidx.test.uiautomator.UiDevice).onElement(kotlin.Long,kotlin.Long,kotlin.Function1)`. |
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2` | `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2.https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(androidx.test.uiautomator.UiObject2).onElement(kotlin.Long,kotlin.Long,kotlin.Function1)( timeoutMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, pollIntervalMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, block: https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.html.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html )` Performs a DFS on the accessibility tree starting from the node associated to this `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2` and returns the first node matching the given `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(androidx.test.uiautomator.UiObject2).onElement(kotlin.Long,kotlin.Long,kotlin.Function1)`. |
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2?` | `https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.html.https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(android.view.accessibility.AccessibilityNodeInfo).onElementOrNull(kotlin.Long,kotlin.Long,kotlin.Function1)( timeoutMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, pollIntervalMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, block: https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.html.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html )` Performs a DFS on the accessibility tree starting from this node and returns the first node matching the given `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(android.view.accessibility.AccessibilityNodeInfo).onElementOrNull(kotlin.Long,kotlin.Long,kotlin.Function1)`. |
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2?` | `https://developer.android.com/reference/android/view/accessibility/AccessibilityWindowInfo.html.https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(android.view.accessibility.AccessibilityWindowInfo).onElementOrNull(kotlin.Long,kotlin.Long,kotlin.Function1)( timeoutMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, pollIntervalMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, block: https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.html.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html )` Performs a DFS on the accessibility tree starting from the root node of this window and returns the first node matching the given `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(android.view.accessibility.AccessibilityWindowInfo).onElementOrNull(kotlin.Long,kotlin.Long,kotlin.Function1)`. |
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2?` | `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiDevice.https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(androidx.test.uiautomator.UiDevice).onElementOrNull(kotlin.Long,kotlin.Long,kotlin.Function1)( timeoutMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, pollIntervalMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, block: https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.html.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html )` Performs a DFS on the accessibility tree starting from the root node in the active window and returns the first node matching the given `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(androidx.test.uiautomator.UiDevice).onElementOrNull(kotlin.Long,kotlin.Long,kotlin.Function1)`. |
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2?` | `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2.https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(androidx.test.uiautomator.UiObject2).onElementOrNull(kotlin.Long,kotlin.Long,kotlin.Function1)( timeoutMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, pollIntervalMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, block: https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.html.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html )` Performs a DFS on the accessibility tree starting from the node associated to this `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2` and returns the first node matching the given `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(androidx.test.uiautomator.UiObject2).onElementOrNull(kotlin.Long,kotlin.Long,kotlin.Function1)`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2>` | `https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.html.https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(android.view.accessibility.AccessibilityNodeInfo).onElements(kotlin.Long,kotlin.Long,kotlin.Function1)( timeoutMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, pollIntervalMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, block: https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.html.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html )` Performs a DFS on the accessibility tree starting from this node and returns all the nodes matching the given `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(android.view.accessibility.AccessibilityNodeInfo).onElements(kotlin.Long,kotlin.Long,kotlin.Function1)`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2>` | `https://developer.android.com/reference/android/view/accessibility/AccessibilityWindowInfo.html.https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(android.view.accessibility.AccessibilityWindowInfo).onElements(kotlin.Long,kotlin.Long,kotlin.Function1)( timeoutMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, pollIntervalMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, block: https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.html.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html )` Performs a DFS on the accessibility tree starting from the root node of this window and returns all the nodes matching the given `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(android.view.accessibility.AccessibilityWindowInfo).onElements(kotlin.Long,kotlin.Long,kotlin.Function1)`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2>` | `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiDevice.https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(androidx.test.uiautomator.UiDevice).onElements(kotlin.Long,kotlin.Long,kotlin.Function1)( timeoutMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, pollIntervalMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, block: https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.html.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html )` Performs a DFS on the accessibility tree starting from this node and returns all the nodes matching the given `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(androidx.test.uiautomator.UiDevice).onElements(kotlin.Long,kotlin.Long,kotlin.Function1)`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2>` | `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2.https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(androidx.test.uiautomator.UiObject2).onElements(kotlin.Long,kotlin.Long,kotlin.Function1)( timeoutMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, pollIntervalMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, block: https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.html.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html )` Performs a DFS on the accessibility tree starting from the node associated to this `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2` and returns all the nodes matching the given `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(androidx.test.uiautomator.UiObject2).onElements(kotlin.Long,kotlin.Long,kotlin.Function1)`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiDevice.https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(androidx.test.uiautomator.UiDevice).pressDelete(kotlin.Int)(count: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Similar to `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(androidx.test.uiautomator.UiDevice).type(kotlin.String)` but presses the delete key for the given `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(androidx.test.uiautomator.UiDevice).pressDelete(kotlin.Int)` times. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/android/graphics/Bitmap.html.https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(android.graphics.Bitmap).saveToFile(java.io.File,android.graphics.Bitmap.CompressFormat,kotlin.Int)( file: https://developer.android.com/reference/java/io/File.html, compressFormat: https://developer.android.com/reference/android/graphics/Bitmap.CompressFormat.html, quality: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` Utility function to save a bitmap onto the given `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(android.graphics.Bitmap).saveToFile(java.io.File,android.graphics.Bitmap.CompressFormat,kotlin.Int)`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/android/graphics/Bitmap.html.https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(android.graphics.Bitmap).saveToFile(android.os.ParcelFileDescriptor,android.graphics.Bitmap.CompressFormat,kotlin.Int)( parcelFileDescriptor: https://developer.android.com/reference/android/os/ParcelFileDescriptor.html, compressFormat: https://developer.android.com/reference/android/graphics/Bitmap.CompressFormat.html, quality: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` Utility function to save a bitmap onto the given `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(android.graphics.Bitmap).saveToFile(android.os.ParcelFileDescriptor,android.graphics.Bitmap.CompressFormat,kotlin.Int)`. |
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2` | `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2.https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(androidx.test.uiautomator.UiObject2).scrollToElement(androidx.test.uiautomator.Direction,kotlin.Long,kotlin.Long,kotlin.Function1)( direction: https://developer.android.com/reference/kotlin/androidx/test/uiautomator/Direction, timeoutMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, pollIntervalMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, block: https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.html.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html )` Keeps scrolling until the given `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(androidx.test.uiautomator.UiObject2).scrollToElement(androidx.test.uiautomator.Direction,kotlin.Long,kotlin.Long,kotlin.Function1)` condition is satisfied or until the given `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(androidx.test.uiautomator.UiObject2).scrollToElement(androidx.test.uiautomator.Direction,kotlin.Long,kotlin.Long,kotlin.Function1)`. |
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2?` | `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2.https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(androidx.test.uiautomator.UiObject2).scrollToElementOrNull(androidx.test.uiautomator.Direction,kotlin.Long,kotlin.Long,kotlin.Function1)( direction: https://developer.android.com/reference/kotlin/androidx/test/uiautomator/Direction, timeoutMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, pollIntervalMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, block: https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.html.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html )` Keeps scrolling until the given `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(androidx.test.uiautomator.UiObject2).scrollToElementOrNull(androidx.test.uiautomator.Direction,kotlin.Long,kotlin.Long,kotlin.Function1)` condition is satisfied or until the given `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(androidx.test.uiautomator.UiObject2).scrollToElementOrNull(androidx.test.uiautomator.Direction,kotlin.Long,kotlin.Long,kotlin.Function1)`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.html>` | `https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.html.https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(android.view.accessibility.AccessibilityNodeInfo).siblings(kotlin.Function1)( filterBlock: (https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.html) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html )` Returns all the siblings of the this node. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?` | `https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.html.https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(android.view.accessibility.AccessibilityNodeInfo).simpleViewResourceName()()` Returns this node's element id resource name without the resource namespace, i.e. only the portion after the "/" character. |
| `https://developer.android.com/reference/android/graphics/Bitmap.html` | `https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.html.https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(android.view.accessibility.AccessibilityNodeInfo).takeScreenshot()()` Takes a screenshot of the screen that contains this node and cuts only the area covered by it. |
| `https://developer.android.com/reference/android/graphics/Bitmap.html` | `https://developer.android.com/reference/android/view/accessibility/AccessibilityWindowInfo.html.https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(android.view.accessibility.AccessibilityWindowInfo).takeScreenshot()()` Takes a screenshot of the screen that contains this window and cuts only the area covered by it. |
| `https://developer.android.com/reference/android/graphics/Bitmap.html` | `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2.https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(androidx.test.uiautomator.UiObject2).takeScreenshot()()` Takes a screenshot of the screen that contains the accessibility node associated to this `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2` and cuts only the area covered by it. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?` | `https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.html.https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(android.view.accessibility.AccessibilityNodeInfo).textAsString()()` Returns this node's text as a string. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiDevice.https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(androidx.test.uiautomator.UiDevice).type(kotlin.String)(text: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` Types the given `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(androidx.test.uiautomator.UiDevice).type(kotlin.String)` string simulating key press through `https://developer.android.com/reference/android/app/Instrumentation.html#sendKeySync(android.view.KeyEvent)`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiDevice.https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(androidx.test.uiautomator.UiDevice).waitForAppToBeVisible(kotlin.String,kotlin.Long)(appPackageName: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, timeoutMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` Waits for an application to become visible. |
| `https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.html` | `https://developer.android.com/reference/android/view/accessibility/AccessibilityWindowInfo.html.https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(android.view.accessibility.AccessibilityWindowInfo).waitForRoot(kotlin.Long,kotlin.Long,kotlin.Boolean)( timeoutMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, sleepIntervalMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, clearCache: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html )` Waits for the root node to become available in this window. |
| `https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.html` | `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiDevice.https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(androidx.test.uiautomator.UiDevice).waitForRootInActiveWindow(kotlin.Long,kotlin.Long,kotlin.Boolean)( timeoutMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, sleepIntervalMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, clearCache: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html )` Waits for the root node to become available in this window. |
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/StableResult` | `https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.html.https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(android.view.accessibility.AccessibilityNodeInfo).waitForStable(kotlin.Long,kotlin.Long,kotlin.Long,kotlin.Boolean)( stableTimeoutMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, stableIntervalMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, stablePollIntervalMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, requireStableScreenshot: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html )` Waits for the node to become stable. |
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/StableResult` | `https://developer.android.com/reference/android/view/accessibility/AccessibilityWindowInfo.html.https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(android.view.accessibility.AccessibilityWindowInfo).waitForStable(kotlin.Long,kotlin.Long,kotlin.Long,kotlin.Boolean)( stableTimeoutMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, stableIntervalMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, stablePollIntervalMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, requireStableScreenshot: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html )` Waits for the root node of this window to become stable. |
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/StableResult` | `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2.https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(androidx.test.uiautomator.UiObject2).waitForStable(kotlin.Long,kotlin.Long,kotlin.Long,kotlin.Boolean)( stableTimeoutMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, stableIntervalMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, stablePollIntervalMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, requireStableScreenshot: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html )` Waits for the node to become stable. |
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/StableResult` | `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiDevice.https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(androidx.test.uiautomator.UiDevice).waitForStableInActiveWindow(kotlin.Long,kotlin.Long,kotlin.Long,kotlin.Boolean)( stableTimeoutMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, stableIntervalMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, stablePollIntervalMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, requireStableScreenshot: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html )` Waits for the root node of the active window to become stable. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/android/view/accessibility/AccessibilityWindowInfo.html>` | `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiDevice.https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(androidx.test.uiautomator.UiDevice).windows()()` Returns all the windows on all the displays. |

## Top-level functions

### uiAutomator

Artifact: [androidx.test.uiautomator:uiautomator](https://developer.android.com/jetpack/androidx/releases/test-uiautomator) [View Source](https://cs.android.com/search?q=file:androidx/test/uiautomator/UiAutomatorTestScope.kt+function:uiAutomator) Added in [2.4.1](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.4.1)

```
fun uiAutomator(block: UiAutomatorTestScope.() -> Unit): Unit
```

Main entry point for ui automator tests. It creates a `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiAutomatorTestScope` in which a test can be defined.

Example:

```kotlin
@Test
fun myTest() = uiAutomator {

    startActivity(MyActivity::class.java)

    onElement { id == "button" }.click()

    onElement { id == "nested_elements" }
        .apply {
            onElement { text == "First Level" }
            onElement { text == "Second Level" }
            onElement { text == "Third Level" }
        }
}
```

| Parameters |
|---|---|
| `block: https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiAutomatorTestScope.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | A block containing the test to run within the `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiAutomatorTestScope`. |

## Extension functions

### UiDevice.activeWindow

Artifact: [androidx.test.uiautomator:uiautomator](https://developer.android.com/jetpack/androidx/releases/test-uiautomator) [View Source](https://cs.android.com/search?q=file:androidx/test/uiautomator/UiDeviceExt.kt+function:activeWindow) Added in [2.4.1](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.4.1)

```
fun UiDevice.activeWindow(): AccessibilityWindowInfo
```

Returns the active window.

### AccessibilityNodeInfo.boundsInScreen

Artifact: [androidx.test.uiautomator:uiautomator](https://developer.android.com/jetpack/androidx/releases/test-uiautomator) [View Source](https://cs.android.com/search?q=file:androidx/test/uiautomator/AccessibilityNodeInfoExt.kt+function:boundsInScreen) Added in [2.4.1](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.4.1)

```
fun AccessibilityNodeInfo.boundsInScreen(): Rect
```

Returns the bounds of this node in screen coordinates. This method is a shortcut for `https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.html#getBoundsInScreen(android.graphics.Rect)`.

| Returns |
|---|---|
| `https://developer.android.com/reference/android/graphics/Rect.html` | a `https://developer.android.com/reference/android/graphics/Rect.html` with the bounds of this node within the screen limits. |

### AccessibilityNodeInfo.children

Artifact: [androidx.test.uiautomator:uiautomator](https://developer.android.com/jetpack/androidx/releases/test-uiautomator) [View Source](https://cs.android.com/search?q=file:androidx/test/uiautomator/AccessibilityNodeInfoExt.kt+function:children) Added in [2.4.1](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.4.1)

```
fun AccessibilityNodeInfo.children(
    block: (AccessibilityNodeInfo) -> Boolean = { true }
): List<AccessibilityNodeInfo>
```

Returns all the immediate children of this node. To return all the descendants (including children of children , children of children of children and so on use\[ `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(android.view.accessibility.AccessibilityNodeInfo).descendants(kotlin.Function1)`.

| Parameters |
|---|---|
| `block: (https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.html) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html = { true }` | an optional predicate to filter the node children |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.html>` | the list of children of this node, with the given filter if specified. |

### AccessibilityNodeInfo.descendants

Artifact: [androidx.test.uiautomator:uiautomator](https://developer.android.com/jetpack/androidx/releases/test-uiautomator) [View Source](https://cs.android.com/search?q=file:androidx/test/uiautomator/AccessibilityNodeInfoExt.kt+function:descendants) Added in [2.4.1](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.4.1)

```
fun AccessibilityNodeInfo.descendants(
    filterBlock: (AccessibilityNodeInfo) -> Boolean = { true }
): List<AccessibilityNodeInfo>
```

Performs a DFS on the accessibility tree starting from this node and returns all the descendants discovered recursively. Optionally a filter can be specified. Note that this differs from AccessibilityNodeInfo.children() because this will return also children of children, children of children of children and so on.

| Parameters |
|---|---|
| `filterBlock: (https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.html) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html = { true }` | an optional predicate to filter the node children |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.html>` | the list of all the descendants of this node, with the given filter if specified. |

### AccessibilityNodeInfo.isClass

Artifact: [androidx.test.uiautomator:uiautomator](https://developer.android.com/jetpack/androidx/releases/test-uiautomator) [View Source](https://cs.android.com/search?q=file:androidx/test/uiautomator/AccessibilityNodeInfoExt.kt+function:isClass) Added in [2.4.1](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.4.1)

```
fun AccessibilityNodeInfo.isClass(cls: Class<*>): Boolean
```

Returns whether this node class name is the same of the given class.

Usage:

```kotlin
onElement { isClass(Button::class.java) }.click()
```

### AccessibilityNodeInfo.onElement

Artifact: [androidx.test.uiautomator:uiautomator](https://developer.android.com/jetpack/androidx/releases/test-uiautomator) [View Source](https://cs.android.com/search?q=file:androidx/test/uiautomator/AccessibilityNodeInfoExt.kt+function:onElement) Added in [2.4.1](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.4.1)

```
fun AccessibilityNodeInfo.onElement(
    timeoutMs: Long = 10000,
    pollIntervalMs: Long = 100,
    block: AccessibilityNodeInfo.() -> Boolean
): UiObject2
```

Performs a DFS on the accessibility tree starting from this node and returns the first node matching the given `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(android.view.accessibility.AccessibilityNodeInfo).onElement(kotlin.Long,kotlin.Long,kotlin.Function1)`. The node is returned as an `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2` that allows interacting with it. If the requested node doesn't exist, a `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/ElementNotFoundException` is thrown. Internally it works searching periodically every `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(android.view.accessibility.AccessibilityNodeInfo).onElement(kotlin.Long,kotlin.Long,kotlin.Function1)`.

Example:

```kotlin
node.onElement { textAsString == "Search" }.click()
```

| Parameters |
|---|---|
| `timeoutMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html = 10000` | a timeout to find the element that satisfies the given condition. |
| `pollIntervalMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html = 100` | an interval to wait before rechecking the accessibility tree for updates. |
| `block: https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.html.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | a block that specifies a condition on the node to find. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2` | a `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2` from a node that matches the given `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(android.view.accessibility.AccessibilityNodeInfo).onElement(kotlin.Long,kotlin.Long,kotlin.Function1)` condition. |

### AccessibilityWindowInfo.onElement

Artifact: [androidx.test.uiautomator:uiautomator](https://developer.android.com/jetpack/androidx/releases/test-uiautomator) [View Source](https://cs.android.com/search?q=file:androidx/test/uiautomator/AccessibilityWindowInfoExt.kt+function:onElement) Added in [2.4.1](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.4.1)

```
fun AccessibilityWindowInfo.onElement(
    timeoutMs: Long = 10000,
    pollIntervalMs: Long = 100,
    block: AccessibilityNodeInfo.() -> Boolean
): UiObject2
```

Performs a DFS on the accessibility tree starting from the root node of this window and returns the first node matching the given `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(android.view.accessibility.AccessibilityWindowInfo).onElement(kotlin.Long,kotlin.Long,kotlin.Function1)`. The node is returned as an `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2` that allows interacting with it. If the requested node doesn't exist, a `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/ElementNotFoundException` is thrown.

Example:

```kotlin
onElement { textAsString == "Search" }.click()
```

| Parameters |
|---|---|
| `timeoutMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html = 10000` | a timeout to find the element that satisfies the given condition. |
| `pollIntervalMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html = 100` | an interval to wait before rechecking the accessibility tree for updates. |
| `block: https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.html.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | a block that specifies a condition on the node to find. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2` | a `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2` from a node that matches the given `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(android.view.accessibility.AccessibilityWindowInfo).onElement(kotlin.Long,kotlin.Long,kotlin.Function1)` condition. |

### UiDevice.onElement

Artifact: [androidx.test.uiautomator:uiautomator](https://developer.android.com/jetpack/androidx/releases/test-uiautomator) [View Source](https://cs.android.com/search?q=file:androidx/test/uiautomator/UiDeviceExt.kt+function:onElement) Added in [2.4.1](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.4.1)

```
fun UiDevice.onElement(
    timeoutMs: Long = 10000,
    pollIntervalMs: Long = 100,
    block: AccessibilityNodeInfo.() -> Boolean
): UiObject2
```

Performs a DFS on the accessibility tree starting from the root node in the active window and returns the first node matching the given `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(androidx.test.uiautomator.UiDevice).onElement(kotlin.Long,kotlin.Long,kotlin.Function1)`. The node is returned as an `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2` that allows interacting with it. If the requested node doesn't exist, a `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/ElementNotFoundException` is thrown. Internally it works searching periodically every `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(androidx.test.uiautomator.UiDevice).onElement(kotlin.Long,kotlin.Long,kotlin.Function1)`.

Example:

```kotlin
uiDevice.onElement { textAsString == "Search" }.click()
```

| Parameters |
|---|---|
| `timeoutMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html = 10000` | a timeout to find the element that satisfies the given condition. |
| `pollIntervalMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html = 100` | an interval to wait before rechecking the accessibility tree for updates. |
| `block: https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.html.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | a block that specifies a condition on the node to find. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2` | a `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2` from a node that matches the given `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(androidx.test.uiautomator.UiDevice).onElement(kotlin.Long,kotlin.Long,kotlin.Function1)` condition. |

### UiObject2.onElement

Artifact: [androidx.test.uiautomator:uiautomator](https://developer.android.com/jetpack/androidx/releases/test-uiautomator) [View Source](https://cs.android.com/search?q=file:androidx/test/uiautomator/UiObject2Ext.kt+function:onElement) Added in [2.4.1](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.4.1)

```
fun UiObject2.onElement(
    timeoutMs: Long = 10000,
    pollIntervalMs: Long = 100,
    block: AccessibilityNodeInfo.() -> Boolean
): UiObject2
```

Performs a DFS on the accessibility tree starting from the node associated to this `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2` and returns the first node matching the given `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(androidx.test.uiautomator.UiObject2).onElement(kotlin.Long,kotlin.Long,kotlin.Function1)`. The node is returned as an `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2` that allows interacting with it. If the requested node doesn't exist, a `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/ElementNotFoundException` is thrown. Internally it works searching periodically every `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(androidx.test.uiautomator.UiObject2).onElement(kotlin.Long,kotlin.Long,kotlin.Function1)`.

Example:

```kotlin
onElement { textAsString == "Search" }.click()
```

| Parameters |
|---|---|
| `timeoutMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html = 10000` | a timeout to find the element that satisfies the given condition. |
| `pollIntervalMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html = 100` | an interval to wait before rechecking the accessibility tree for updates. |
| `block: https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.html.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | a block that specifies a condition on the node to find. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2` | a `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2` from a node that matches the given `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(androidx.test.uiautomator.UiObject2).onElement(kotlin.Long,kotlin.Long,kotlin.Function1)` condition. |

### AccessibilityNodeInfo.onElementOrNull

Artifact: [androidx.test.uiautomator:uiautomator](https://developer.android.com/jetpack/androidx/releases/test-uiautomator) [View Source](https://cs.android.com/search?q=file:androidx/test/uiautomator/AccessibilityNodeInfoExt.kt+function:onElementOrNull) Added in [2.4.1](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.4.1)

```
fun AccessibilityNodeInfo.onElementOrNull(
    timeoutMs: Long = 10000,
    pollIntervalMs: Long = 100,
    block: AccessibilityNodeInfo.() -> Boolean
): UiObject2?
```

Performs a DFS on the accessibility tree starting from this node and returns the first node matching the given `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(android.view.accessibility.AccessibilityNodeInfo).onElementOrNull(kotlin.Long,kotlin.Long,kotlin.Function1)`. The node is returned as an `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2` that allows interacting with it. If the requested node doesn't exist, null is returned. Internally it works searching periodically every `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(android.view.accessibility.AccessibilityNodeInfo).onElementOrNull(kotlin.Long,kotlin.Long,kotlin.Function1)`.

Example:

```kotlin
node.onElement { textAsString == "Search" }.click()
```

| Parameters |
|---|---|
| `timeoutMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html = 10000` | a timeout to find the element that satisfies the given condition. |
| `pollIntervalMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html = 100` | an interval to wait before rechecking the accessibility tree for updates. |
| `block: https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.html.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | a block that specifies a condition on the node to find. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2?` | a `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2` from a node that matches the given `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(android.view.accessibility.AccessibilityNodeInfo).onElementOrNull(kotlin.Long,kotlin.Long,kotlin.Function1)` condition or null. |

### AccessibilityWindowInfo.onElementOrNull

Artifact: [androidx.test.uiautomator:uiautomator](https://developer.android.com/jetpack/androidx/releases/test-uiautomator) [View Source](https://cs.android.com/search?q=file:androidx/test/uiautomator/AccessibilityWindowInfoExt.kt+function:onElementOrNull) Added in [2.4.1](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.4.1)

```
fun AccessibilityWindowInfo.onElementOrNull(
    timeoutMs: Long = 10000,
    pollIntervalMs: Long = 100,
    block: AccessibilityNodeInfo.() -> Boolean
): UiObject2?
```

Performs a DFS on the accessibility tree starting from the root node of this window and returns the first node matching the given `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(android.view.accessibility.AccessibilityWindowInfo).onElementOrNull(kotlin.Long,kotlin.Long,kotlin.Function1)`. The node is returned as an `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2` that allows interacting with it. If the requested node doesn't exist, null is returned. Internally it works searching periodically every `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(android.view.accessibility.AccessibilityWindowInfo).onElementOrNull(kotlin.Long,kotlin.Long,kotlin.Function1)`.

Example:

```kotlin
onElement { textAsString == "Search" }.click()
```

| Parameters |
|---|---|
| `timeoutMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html = 10000` | a timeout to find the element that satisfies the given condition. |
| `pollIntervalMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html = 100` | an interval to wait before rechecking the accessibility tree for updates. |
| `block: https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.html.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | a block that specifies a condition on the node to find. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2?` | a `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2` from a node that matches the given `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(android.view.accessibility.AccessibilityWindowInfo).onElementOrNull(kotlin.Long,kotlin.Long,kotlin.Function1)` condition or null. |

### UiDevice.onElementOrNull

Artifact: [androidx.test.uiautomator:uiautomator](https://developer.android.com/jetpack/androidx/releases/test-uiautomator) [View Source](https://cs.android.com/search?q=file:androidx/test/uiautomator/UiDeviceExt.kt+function:onElementOrNull) Added in [2.4.1](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.4.1)

```
fun UiDevice.onElementOrNull(
    timeoutMs: Long = 10000,
    pollIntervalMs: Long = 100,
    block: AccessibilityNodeInfo.() -> Boolean
): UiObject2?
```

Performs a DFS on the accessibility tree starting from the root node in the active window and returns the first node matching the given `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(androidx.test.uiautomator.UiDevice).onElementOrNull(kotlin.Long,kotlin.Long,kotlin.Function1)`. The node is returned as an `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2` that allows interacting with it. If the requested node doesn't exist, null is returned. Internally it works searching periodically every `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(androidx.test.uiautomator.UiDevice).onElementOrNull(kotlin.Long,kotlin.Long,kotlin.Function1)`.

Example:

```kotlin
uiDevice.onElement { textAsString == "Search" }.click()
```

| Parameters |
|---|---|
| `timeoutMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html = 10000` | a timeout to find the element that satisfies the given condition. |
| `pollIntervalMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html = 100` | an interval to wait before rechecking the accessibility tree for updates. |
| `block: https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.html.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | a block that specifies a condition on the node to find. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2?` | a `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2` from a node that matches the given `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(androidx.test.uiautomator.UiDevice).onElementOrNull(kotlin.Long,kotlin.Long,kotlin.Function1)` condition or null. |

### UiObject2.onElementOrNull

Artifact: [androidx.test.uiautomator:uiautomator](https://developer.android.com/jetpack/androidx/releases/test-uiautomator) [View Source](https://cs.android.com/search?q=file:androidx/test/uiautomator/UiObject2Ext.kt+function:onElementOrNull) Added in [2.4.1](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.4.1)

```
fun UiObject2.onElementOrNull(
    timeoutMs: Long = 10000,
    pollIntervalMs: Long = 100,
    block: AccessibilityNodeInfo.() -> Boolean
): UiObject2?
```

Performs a DFS on the accessibility tree starting from the node associated to this `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2` and returns the first node matching the given `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(androidx.test.uiautomator.UiObject2).onElementOrNull(kotlin.Long,kotlin.Long,kotlin.Function1)`. The node is returned as an `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2` that allows interacting with it. If the requested node doesn't exist, null is returned. Internally it works searching periodically every `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(androidx.test.uiautomator.UiObject2).onElementOrNull(kotlin.Long,kotlin.Long,kotlin.Function1)`.

Example:

```kotlin
onElement { textAsString == "Search" }.click()
```

| Parameters |
|---|---|
| `timeoutMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html = 10000` | a timeout to find the element that satisfies the given condition. |
| `pollIntervalMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html = 100` | an interval to wait before rechecking the accessibility tree for updates. |
| `block: https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.html.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | a block that specifies a condition on the node to find. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2?` | a `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2` from a node that matches the given `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(androidx.test.uiautomator.UiObject2).onElementOrNull(kotlin.Long,kotlin.Long,kotlin.Function1)` condition or null. |

### AccessibilityNodeInfo.onElements

Artifact: [androidx.test.uiautomator:uiautomator](https://developer.android.com/jetpack/androidx/releases/test-uiautomator) [View Source](https://cs.android.com/search?q=file:androidx/test/uiautomator/AccessibilityNodeInfoExt.kt+function:onElements) Added in [2.4.1](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.4.1)

```
fun AccessibilityNodeInfo.onElements(
    timeoutMs: Long = 10000,
    pollIntervalMs: Long = 100,
    block: AccessibilityNodeInfo.() -> Boolean
): List<UiObject2>
```

Performs a DFS on the accessibility tree starting from this node and returns all the nodes matching the given `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(android.view.accessibility.AccessibilityNodeInfo).onElements(kotlin.Long,kotlin.Long,kotlin.Function1)`. This method stops waiting as soon as a single node with the given condition is returned. The nodes returned are `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2` that allow interacting with them. Internally it works searching periodically every `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(android.view.accessibility.AccessibilityNodeInfo).onElements(kotlin.Long,kotlin.Long,kotlin.Function1)`.

Example:

```kotlin
node.onElements { className == Button::class.java.name }
```

If multiple nodes are expected but they appear at different times, it's recommended to call `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(android.view.accessibility.AccessibilityNodeInfo).waitForStable(kotlin.Long,kotlin.Long,kotlin.Long,kotlin.Boolean)` before, to ensure any operation is complete.

| Parameters |
|---|---|
| `timeoutMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html = 10000` | a timeout to find the element that satisfies the given condition. |
| `pollIntervalMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html = 100` | an interval to wait before rechecking the accessibility tree for updates. |
| `block: https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.html.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | a block that specifies a condition on the node to find. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2>` | a list of `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2` from nodes that matches the given `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(android.view.accessibility.AccessibilityNodeInfo).onElements(kotlin.Long,kotlin.Long,kotlin.Function1)` condition. |

### AccessibilityWindowInfo.onElements

Artifact: [androidx.test.uiautomator:uiautomator](https://developer.android.com/jetpack/androidx/releases/test-uiautomator) [View Source](https://cs.android.com/search?q=file:androidx/test/uiautomator/AccessibilityWindowInfoExt.kt+function:onElements) Added in [2.4.1](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.4.1)

```
fun AccessibilityWindowInfo.onElements(
    timeoutMs: Long = 10000,
    pollIntervalMs: Long = 100,
    block: AccessibilityNodeInfo.() -> Boolean
): List<UiObject2>
```

Performs a DFS on the accessibility tree starting from the root node of this window and returns all the nodes matching the given `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(android.view.accessibility.AccessibilityWindowInfo).onElements(kotlin.Long,kotlin.Long,kotlin.Function1)`. This method stops waiting as soon as a single node with the given condition is returned. The nodes returned are `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2` that allow interacting with them. Internally it works searching periodically every `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(android.view.accessibility.AccessibilityWindowInfo).onElements(kotlin.Long,kotlin.Long,kotlin.Function1)`.

Example:

```kotlin
node.onElements { className == Button::class.java.name }
```

If multiple nodes are expected but they appear at different times, it's recommended to call `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(android.view.accessibility.AccessibilityNodeInfo).waitForStable(kotlin.Long,kotlin.Long,kotlin.Long,kotlin.Boolean)` before, to ensure any operation is complete.

| Parameters |
|---|---|
| `timeoutMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html = 10000` | a timeout to find the element that satisfies the given condition. |
| `pollIntervalMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html = 100` | an interval to wait before rechecking the accessibility tree for updates. |
| `block: https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.html.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | a block that specifies a condition on the node to find. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2>` | a list of `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2` from nodes that matches the given `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(android.view.accessibility.AccessibilityWindowInfo).onElements(kotlin.Long,kotlin.Long,kotlin.Function1)` condition. |

### UiDevice.onElements

Artifact: [androidx.test.uiautomator:uiautomator](https://developer.android.com/jetpack/androidx/releases/test-uiautomator) [View Source](https://cs.android.com/search?q=file:androidx/test/uiautomator/UiDeviceExt.kt+function:onElements) Added in [2.4.1](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.4.1)

```
fun UiDevice.onElements(
    timeoutMs: Long = 10000,
    pollIntervalMs: Long = 100,
    block: AccessibilityNodeInfo.() -> Boolean
): List<UiObject2>
```

Performs a DFS on the accessibility tree starting from this node and returns all the nodes matching the given `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(androidx.test.uiautomator.UiDevice).onElements(kotlin.Long,kotlin.Long,kotlin.Function1)`. This method stops waiting as soon as a single node with the given condition is returned. The nodes returned are `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2` that allow interacting with them. Internally it works searching periodically every `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(androidx.test.uiautomator.UiDevice).onElements(kotlin.Long,kotlin.Long,kotlin.Function1)`.

Example:

```kotlin
node.onElements { className == Button::class.java.name }
```

If multiple nodes are expected but they appear at different times, it's recommended to call `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(android.view.accessibility.AccessibilityNodeInfo).waitForStable(kotlin.Long,kotlin.Long,kotlin.Long,kotlin.Boolean)` before, to ensure any operation is complete.

| Parameters |
|---|---|
| `timeoutMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html = 10000` | a timeout to find the element that satisfies the given condition. |
| `pollIntervalMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html = 100` | an interval to wait before rechecking the accessibility tree for updates. |
| `block: https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.html.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | a block that specifies a condition on the node to find. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2>` | a list of `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2` from nodes that matches the given `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(androidx.test.uiautomator.UiDevice).onElements(kotlin.Long,kotlin.Long,kotlin.Function1)` condition. |

### UiObject2.onElements

Artifact: [androidx.test.uiautomator:uiautomator](https://developer.android.com/jetpack/androidx/releases/test-uiautomator) [View Source](https://cs.android.com/search?q=file:androidx/test/uiautomator/UiObject2Ext.kt+function:onElements) Added in [2.4.1](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.4.1)

```
fun UiObject2.onElements(
    timeoutMs: Long = 10000,
    pollIntervalMs: Long = 100,
    block: AccessibilityNodeInfo.() -> Boolean
): List<UiObject2>
```

Performs a DFS on the accessibility tree starting from the node associated to this `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2` and returns all the nodes matching the given `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(androidx.test.uiautomator.UiObject2).onElements(kotlin.Long,kotlin.Long,kotlin.Function1)`. This method stops waiting as soon as a single node with the given condition is returned. The nodes returned are `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2` that allow interacting with them. Internally it works searching periodically every `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(androidx.test.uiautomator.UiObject2).onElements(kotlin.Long,kotlin.Long,kotlin.Function1)`.

Example:

```kotlin
node.onElements { isClass(Button::class.java) }
```

If multiple nodes are expected but they appear at different times, it's recommended to call `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(android.view.accessibility.AccessibilityNodeInfo).waitForStable(kotlin.Long,kotlin.Long,kotlin.Long,kotlin.Boolean)` before, to ensure any operation is complete.

| Parameters |
|---|---|
| `timeoutMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html = 10000` | a timeout to find the element that satisfies the given condition. |
| `pollIntervalMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html = 100` | an interval to wait before rechecking the accessibility tree for updates. |
| `block: https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.html.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | a block that specifies a condition on the node to find. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2>` | a list of `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2` from nodes that matches the given `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(androidx.test.uiautomator.UiObject2).onElements(kotlin.Long,kotlin.Long,kotlin.Function1)` condition. |

### UiDevice.pressDelete

Artifact: [androidx.test.uiautomator:uiautomator](https://developer.android.com/jetpack/androidx/releases/test-uiautomator) [View Source](https://cs.android.com/search?q=file:androidx/test/uiautomator/UiDeviceExt.kt+function:pressDelete) Added in [2.4.1](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.4.1)

```
fun UiDevice.pressDelete(count: Int): Unit
```

Similar to `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(androidx.test.uiautomator.UiDevice).type(kotlin.String)` but presses the delete key for the given `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(androidx.test.uiautomator.UiDevice).pressDelete(kotlin.Int)` times.

| Parameters |
|---|---|
| `count: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | how many times the press delete key should be pressed. |

### Bitmap.saveToFile

Artifact: [androidx.test.uiautomator:uiautomator](https://developer.android.com/jetpack/androidx/releases/test-uiautomator) [View Source](https://cs.android.com/search?q=file:androidx/test/uiautomator/Utils.kt+function:saveToFile) Added in [2.4.1](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.4.1)

```
fun Bitmap.saveToFile(
    file: File,
    compressFormat: Bitmap.CompressFormat = Bitmap.CompressFormat.JPEG,
    quality: Int = 100
): Boolean
```

Utility function to save a bitmap onto the given `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(android.graphics.Bitmap).saveToFile(java.io.File,android.graphics.Bitmap.CompressFormat,kotlin.Int)`.

| Parameters |
|---|---|
| `file: https://developer.android.com/reference/java/io/File.html` | the file to store the bitmap. |
| `compressFormat: https://developer.android.com/reference/android/graphics/Bitmap.CompressFormat.html = Bitmap.CompressFormat.JPEG` | the `https://developer.android.com/reference/android/graphics/Bitmap.CompressFormat.html` to use when storing the bitmap. Default is jpg. |
| `quality: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html = 100` | the quality for the compression. This is always 100 for png. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | whether the bitmap was correctly saved onto a file. |

### Bitmap.saveToFile

Artifact: [androidx.test.uiautomator:uiautomator](https://developer.android.com/jetpack/androidx/releases/test-uiautomator) [View Source](https://cs.android.com/search?q=file:androidx/test/uiautomator/Utils.kt+function:saveToFile) Added in [2.4.1](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.4.1)

```
fun Bitmap.saveToFile(
    parcelFileDescriptor: ParcelFileDescriptor,
    compressFormat: Bitmap.CompressFormat = Bitmap.CompressFormat.JPEG,
    quality: Int = 100
): Boolean
```

Utility function to save a bitmap onto the given `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(android.graphics.Bitmap).saveToFile(android.os.ParcelFileDescriptor,android.graphics.Bitmap.CompressFormat,kotlin.Int)`.

| Parameters |
|---|---|
| `parcelFileDescriptor: https://developer.android.com/reference/android/os/ParcelFileDescriptor.html` | the file descriptor pointing to a file to store the bitmap. |
| `compressFormat: https://developer.android.com/reference/android/graphics/Bitmap.CompressFormat.html = Bitmap.CompressFormat.JPEG` | the `https://developer.android.com/reference/android/graphics/Bitmap.CompressFormat.html` to use when storing the bitmap. Default is jpg. |
| `quality: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html = 100` | the quality for the compression. This is always 100 for png. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | whether the bitmap was correctly saved onto a file. |

### UiObject2.scrollToElement

Artifact: [androidx.test.uiautomator:uiautomator](https://developer.android.com/jetpack/androidx/releases/test-uiautomator) [View Source](https://cs.android.com/search?q=file:androidx/test/uiautomator/UiObject2Ext.kt+function:scrollToElement) Added in [2.4.1](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.4.1)

```
fun UiObject2.scrollToElement(
    direction: Direction,
    timeoutMs: Long = 10000,
    pollIntervalMs: Long = 100,
    block: AccessibilityNodeInfo.() -> Boolean
): UiObject2
```

Keeps scrolling until the given `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(androidx.test.uiautomator.UiObject2).scrollToElement(androidx.test.uiautomator.Direction,kotlin.Long,kotlin.Long,kotlin.Function1)` condition is satisfied or until the given `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(androidx.test.uiautomator.UiObject2).scrollToElement(androidx.test.uiautomator.Direction,kotlin.Long,kotlin.Long,kotlin.Function1)`. Throws a `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/ElementNotFoundException` if the condition is not satisfied at the end of the timeout.

Example:

```kotlin
onElement { isScrollable }.scrollToElement(Direction.DOWN) { id == "button" }.click()
```

| Parameters |
|---|---|
| `direction: https://developer.android.com/reference/kotlin/androidx/test/uiautomator/Direction` | the scroll `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/Direction`. |
| `timeoutMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html = 10000` | a timeout to find the element that satisfies the given condition. |
| `pollIntervalMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html = 100` | an interval to wait before rechecking the accessibility tree for updates. |
| `block: https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.html.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | a block that specifies a condition on the node to find. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2` | a `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2` that matches the given `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(androidx.test.uiautomator.UiObject2).scrollToElement(androidx.test.uiautomator.Direction,kotlin.Long,kotlin.Long,kotlin.Function1)` condition. |

### UiObject2.scrollToElementOrNull

Artifact: [androidx.test.uiautomator:uiautomator](https://developer.android.com/jetpack/androidx/releases/test-uiautomator) [View Source](https://cs.android.com/search?q=file:androidx/test/uiautomator/UiObject2Ext.kt+function:scrollToElementOrNull) Added in [2.4.1](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.4.1)

```
fun UiObject2.scrollToElementOrNull(
    direction: Direction,
    timeoutMs: Long = 10000,
    pollIntervalMs: Long = 100,
    block: AccessibilityNodeInfo.() -> Boolean
): UiObject2?
```

Keeps scrolling until the given `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(androidx.test.uiautomator.UiObject2).scrollToElementOrNull(androidx.test.uiautomator.Direction,kotlin.Long,kotlin.Long,kotlin.Function1)` condition is satisfied or until the given `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(androidx.test.uiautomator.UiObject2).scrollToElementOrNull(androidx.test.uiautomator.Direction,kotlin.Long,kotlin.Long,kotlin.Function1)`. Returns null if the condition is not satisfied at the end of the timeout.

Example:

```kotlin
onElement { isScrollable }.scrollToElement(Direction.DOWN) { id == "button" }.click()
```

| Parameters |
|---|---|
| `direction: https://developer.android.com/reference/kotlin/androidx/test/uiautomator/Direction` | the scroll `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/Direction`. |
| `timeoutMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html = 10000` | a timeout to find the element that satisfies the given condition. |
| `pollIntervalMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html = 100` | an interval to wait before rechecking the accessibility tree for updates. |
| `block: https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.html.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | a block that specifies a condition on the node to find. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2?` | a `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2` that matches the given `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(androidx.test.uiautomator.UiObject2).scrollToElementOrNull(androidx.test.uiautomator.Direction,kotlin.Long,kotlin.Long,kotlin.Function1)` condition. |

### AccessibilityNodeInfo.siblings

Artifact: [androidx.test.uiautomator:uiautomator](https://developer.android.com/jetpack/androidx/releases/test-uiautomator) [View Source](https://cs.android.com/search?q=file:androidx/test/uiautomator/AccessibilityNodeInfoExt.kt+function:siblings) Added in [2.4.1](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.4.1)

```
fun AccessibilityNodeInfo.siblings(
    filterBlock: (AccessibilityNodeInfo) -> Boolean = { true }
): List<AccessibilityNodeInfo>
```

Returns all the siblings of the this node.

| Parameters |
|---|---|
| `filterBlock: (https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.html) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html = { true }` | an optional predicate to filter the node siblings |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.html>` | the list of the siblings of this node, with the given filter if specified. |

### AccessibilityNodeInfo.simpleViewResourceName

Artifact: [androidx.test.uiautomator:uiautomator](https://developer.android.com/jetpack/androidx/releases/test-uiautomator) [View Source](https://cs.android.com/search?q=file:androidx/test/uiautomator/AccessibilityNodeInfoExt.kt+function:simpleViewResourceName) Added in [2.4.1](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.4.1)

```
fun AccessibilityNodeInfo.simpleViewResourceName(): String?
```

Returns this node's element id resource name without the resource namespace, i.e. only the portion after the "/" character. If the element id is not specified, then it returns `null`.

### AccessibilityNodeInfo.takeScreenshot

Artifact: [androidx.test.uiautomator:uiautomator](https://developer.android.com/jetpack/androidx/releases/test-uiautomator) [View Source](https://cs.android.com/search?q=file:androidx/test/uiautomator/AccessibilityNodeInfoExt.kt+function:takeScreenshot) Added in [2.4.1](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.4.1)

```
fun AccessibilityNodeInfo.takeScreenshot(): Bitmap
```

Takes a screenshot of the screen that contains this node and cuts only the area covered by it.

| Returns |
|---|---|
| `https://developer.android.com/reference/android/graphics/Bitmap.html` | a bitmap containing the image of this node. |

### AccessibilityWindowInfo.takeScreenshot

Artifact: [androidx.test.uiautomator:uiautomator](https://developer.android.com/jetpack/androidx/releases/test-uiautomator) [View Source](https://cs.android.com/search?q=file:androidx/test/uiautomator/AccessibilityWindowInfoExt.kt+function:takeScreenshot) Added in [2.4.1](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.4.1)

```
fun AccessibilityWindowInfo.takeScreenshot(): Bitmap
```

Takes a screenshot of the screen that contains this window and cuts only the area covered by it.

| Returns |
|---|---|
| `https://developer.android.com/reference/android/graphics/Bitmap.html` | a bitmap containing the image of this node. |

### UiObject2.takeScreenshot

Artifact: [androidx.test.uiautomator:uiautomator](https://developer.android.com/jetpack/androidx/releases/test-uiautomator) [View Source](https://cs.android.com/search?q=file:androidx/test/uiautomator/UiObject2Ext.kt+function:takeScreenshot) Added in [2.4.1](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.4.1)

```
fun UiObject2.takeScreenshot(): Bitmap
```

Takes a screenshot of the screen that contains the accessibility node associated to this `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2` and cuts only the area covered by it.

| Returns |
|---|---|
| `https://developer.android.com/reference/android/graphics/Bitmap.html` | a bitmap containing the image of the node associated to this `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2`. |

### AccessibilityNodeInfo.textAsString

Artifact: [androidx.test.uiautomator:uiautomator](https://developer.android.com/jetpack/androidx/releases/test-uiautomator) [View Source](https://cs.android.com/search?q=file:androidx/test/uiautomator/AccessibilityNodeInfoExt.kt+function:textAsString) Added in [2.4.1](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.4.1)

```
fun AccessibilityNodeInfo.textAsString(): String?
```

Returns this node's text as a string. This should always be preferred to `https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.html#text` that instead returns a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html`, that might be either a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` or a `https://developer.android.com/reference/android/text/SpannableString.html`. If a text is not specified, then it returns `null`.

Usage:

```kotlin
onElement { textAsString() == "Some text" }.click()
```

### UiDevice.type

Artifact: [androidx.test.uiautomator:uiautomator](https://developer.android.com/jetpack/androidx/releases/test-uiautomator) [View Source](https://cs.android.com/search?q=file:androidx/test/uiautomator/UiDeviceExt.kt+function:type) Added in [2.4.1](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.4.1)

```
fun UiDevice.type(text: String): Unit
```

Types the given `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(androidx.test.uiautomator.UiDevice).type(kotlin.String)` string simulating key press through `https://developer.android.com/reference/android/app/Instrumentation.html#sendKeySync(android.view.KeyEvent)`. This is similar to tapping the keys on a virtual keyboard and will trigger the same listeners in the target app, as opposed to `https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.html#setText(java.lang.CharSequence)` that programmatically sets the given text in the target node.

| Parameters |
|---|---|
| `text: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | the text to type. |

### UiDevice.waitForAppToBeVisible

Artifact: [androidx.test.uiautomator:uiautomator](https://developer.android.com/jetpack/androidx/releases/test-uiautomator) [View Source](https://cs.android.com/search?q=file:androidx/test/uiautomator/UiDeviceExt.kt+function:waitForAppToBeVisible) Added in [2.4.1](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.4.1)

```
fun UiDevice.waitForAppToBeVisible(
    appPackageName: String,
    timeoutMs: Long = 10000
): Boolean
```

Waits for an application to become visible. Note that internally it checks if an accessibility node with the given `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(androidx.test.uiautomator.UiDevice).waitForAppToBeVisible(kotlin.String,kotlin.Long)` exists in the accessibility tree.

| Parameters |
|---|---|
| `appPackageName: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | the package name of the app to wait for. By default is the target app package name. |
| `timeoutMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html = 10000` | a timeout for the app to become visible. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | whether the app became visible in the given timeout. |

### AccessibilityWindowInfo.waitForRoot

Artifact: [androidx.test.uiautomator:uiautomator](https://developer.android.com/jetpack/androidx/releases/test-uiautomator) [View Source](https://cs.android.com/search?q=file:androidx/test/uiautomator/AccessibilityWindowInfoExt.kt+function:waitForRoot) Added in [2.4.1](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.4.1)

```
fun AccessibilityWindowInfo.waitForRoot(
    timeoutMs: Long = 10000,
    sleepIntervalMs: Long = 100,
    clearCache: Boolean = true
): AccessibilityNodeInfo
```

Waits for the root node to become available in this window.

| Parameters |
|---|---|
| `timeoutMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html = 10000` | a timeout for the root node to become available. |
| `sleepIntervalMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html = 100` | a interval to wait before retrying checking if the node is available. |
| `clearCache: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html = true` | whether the accessibility nodes cache should be cleared when checking. |

| Returns |
|---|---|
| `https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.html` | the root node for this window. |

### UiDevice.waitForRootInActiveWindow

Artifact: [androidx.test.uiautomator:uiautomator](https://developer.android.com/jetpack/androidx/releases/test-uiautomator) [View Source](https://cs.android.com/search?q=file:androidx/test/uiautomator/UiDeviceExt.kt+function:waitForRootInActiveWindow) Added in [2.4.1](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.4.1)

```
fun UiDevice.waitForRootInActiveWindow(
    timeoutMs: Long = 10000,
    sleepIntervalMs: Long = 100,
    clearCache: Boolean = true
): AccessibilityNodeInfo
```

Waits for the root node to become available in this window.

| Parameters |
|---|---|
| `timeoutMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html = 10000` | a timeout for the root node to become available. |
| `sleepIntervalMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html = 100` | a interval to wait before retrying checking if the node is available. |
| `clearCache: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html = true` | whether the accessibility nodes cache should be cleared when checking. |

| Returns |
|---|---|
| `https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.html` | the root node for this window. |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` | if the root node in the active window cannot be acquired before the give timeout `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(androidx.test.uiautomator.UiDevice).waitForRootInActiveWindow(kotlin.Long,kotlin.Long,kotlin.Boolean)`. |

### AccessibilityNodeInfo.waitForStable

Artifact: [androidx.test.uiautomator:uiautomator](https://developer.android.com/jetpack/androidx/releases/test-uiautomator) [View Source](https://cs.android.com/search?q=file:androidx/test/uiautomator/AccessibilityNodeInfoExt.kt+function:waitForStable) Added in [2.4.1](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.4.1)

```
fun AccessibilityNodeInfo.waitForStable(
    stableTimeoutMs: Long = 3000,
    stableIntervalMs: Long = 500,
    stablePollIntervalMs: Long = 50,
    requireStableScreenshot: Boolean = true
): StableResult
```

Waits for the node to become stable. A node is considered stable when it and its descendants have not changed over an interval of time. Optionally also the node image can be checked. Internally it works checking periodically that the internal properties of the node have not changed.

| Parameters |
|---|---|
| `stableTimeoutMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html = 3000` | a timeout for the wait operation, to ensure not waiting forever for stability. |
| `stableIntervalMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html = 500` | the interval during which the node should not be changing, in order to be considered stable. |
| `stablePollIntervalMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html = 50` | specifies how often the ui should be checked for changes. |
| `requireStableScreenshot: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html = true` | specifies if also the bitmap of the node should not change over the specified `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(android.view.accessibility.AccessibilityNodeInfo).waitForStable(kotlin.Long,kotlin.Long,kotlin.Long,kotlin.Boolean)`. Note that this won't work with elements that change constantly, like a video player. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/StableResult` | a `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/StableResult` containing the latest acquired element hierarchy and screenshot, and a flag indicating if the node was stable before timeout. The flag `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/StableResult#isTimeout()` is set to false if the node was stable before the timeout expired, true otherwise. |

### AccessibilityWindowInfo.waitForStable

Artifact: [androidx.test.uiautomator:uiautomator](https://developer.android.com/jetpack/androidx/releases/test-uiautomator) [View Source](https://cs.android.com/search?q=file:androidx/test/uiautomator/AccessibilityWindowInfoExt.kt+function:waitForStable) Added in [2.4.1](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.4.1)

```
fun AccessibilityWindowInfo.waitForStable(
    stableTimeoutMs: Long = 3000,
    stableIntervalMs: Long = 500,
    stablePollIntervalMs: Long = 50,
    requireStableScreenshot: Boolean = true
): StableResult
```

Waits for the root node of this window to become stable. A node is considered stable when it and its descendants have not changed over an interval of time. Optionally also the node image can be checked. Internally it works checking periodically that the internal properties of the node have not changed.

| Parameters |
|---|---|
| `stableTimeoutMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html = 3000` | a timeout for the wait operation, to ensure not waiting forever for stability. |
| `stableIntervalMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html = 500` | the interval during which the node should not be changing, in order to be considered stable. |
| `stablePollIntervalMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html = 50` | specifies how often the ui should be checked for changes. |
| `requireStableScreenshot: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html = true` | specifies if also the bitmap of the node should not change over the specified `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(android.view.accessibility.AccessibilityWindowInfo).waitForStable(kotlin.Long,kotlin.Long,kotlin.Long,kotlin.Boolean)`. Note that this won't work with elements that change constantly, like a video player. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/StableResult` | a `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/StableResult` containing the latest acquired element hierarchy and screenshot, and a flag indicating if the node was stable before timeout. The flag `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/StableResult#isTimeout()` is set to false if the node was stable before the timeout expired, true otherwise. |

### UiObject2.waitForStable

Artifact: [androidx.test.uiautomator:uiautomator](https://developer.android.com/jetpack/androidx/releases/test-uiautomator) [View Source](https://cs.android.com/search?q=file:androidx/test/uiautomator/UiObject2Ext.kt+function:waitForStable) Added in [2.4.1](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.4.1)

```
fun UiObject2.waitForStable(
    stableTimeoutMs: Long = 3000,
    stableIntervalMs: Long = 500,
    stablePollIntervalMs: Long = 50,
    requireStableScreenshot: Boolean = true
): StableResult
```

Waits for the node to become stable. A node is considered stable when it and its descendants have not changed over an interval of time. Optionally also the node image can be checked. Internally it works checking periodically that the internal properties of the node have not changed.

| Parameters |
|---|---|
| `stableTimeoutMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html = 3000` | a timeout for the wait operation, to ensure not waiting forever for stability. |
| `stableIntervalMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html = 500` | the interval during which the node should not be changing, in order to be considered stable. |
| `stablePollIntervalMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html = 50` | specifies how often the ui should be checked for changes. |
| `requireStableScreenshot: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html = true` | specifies if also the bitmap of the node should not change over the specified `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(androidx.test.uiautomator.UiObject2).waitForStable(kotlin.Long,kotlin.Long,kotlin.Long,kotlin.Boolean)`. Note that this won't work with elements that change constantly, like a video player. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/StableResult` | a `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/StableResult` containing the latest acquired element hierarchy and screenshot, and a flag indicating if the node was stable before timeout. The flag `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/StableResult#isTimeout()` is set to false if the node was stable before the timeout expired, true otherwise. |

### UiDevice.waitForStableInActiveWindow

Artifact: [androidx.test.uiautomator:uiautomator](https://developer.android.com/jetpack/androidx/releases/test-uiautomator) [View Source](https://cs.android.com/search?q=file:androidx/test/uiautomator/UiDeviceExt.kt+function:waitForStableInActiveWindow) Added in [2.4.1](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.4.1)

```
fun UiDevice.waitForStableInActiveWindow(
    stableTimeoutMs: Long = 3000,
    stableIntervalMs: Long = 500,
    stablePollIntervalMs: Long = 50,
    requireStableScreenshot: Boolean = true
): StableResult
```

Waits for the root node of the active window to become stable.

A node is considered stable when it and its descendants have not changed over an interval of time. Optionally also the node image can be checked. Internally it works checking periodically that the internal properties of the node have not changed.

**Note** : Usage of this API in tests will result in non-deterministic tests. So, this API should only be used as a last resort and **only** when there are no other alternatives available.

| Parameters |
|---|---|
| `stableTimeoutMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html = 3000` | a timeout for the wait operation, to ensure not waiting forever for stability. |
| `stableIntervalMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html = 500` | the interval during which the node should not be changing, in order to be considered stable. |
| `stablePollIntervalMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html = 50` | specifies how often the ui should be checked for changes. |
| `requireStableScreenshot: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html = true` | specifies if also the bitmap of the node should not change over the specified `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/package-summary#(androidx.test.uiautomator.UiDevice).waitForStableInActiveWindow(kotlin.Long,kotlin.Long,kotlin.Long,kotlin.Boolean)`. Note that this won't work with elements that change constantly, like a video player. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/StableResult` | a `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/StableResult` containing the latest acquired element hierarchy and screenshot, and a flag indicating if the node was stable before timeout. The flag `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/StableResult#isTimeout()` is set to false if the node was stable before the timeout expired, true otherwise. |

### UiDevice.windows

Artifact: [androidx.test.uiautomator:uiautomator](https://developer.android.com/jetpack/androidx/releases/test-uiautomator) [View Source](https://cs.android.com/search?q=file:androidx/test/uiautomator/UiDeviceExt.kt+function:windows) Added in [2.4.1](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.4.1)

```
fun UiDevice.windows(): List<AccessibilityWindowInfo>
```

Returns all the windows on all the displays.