androidx.test.uiautomator
Interfaces
Condition |
Represents a condition to be satisfied. |
IAutomationSupport |
Provides auxiliary support for running test cases |
Searchable |
The Searchable interface represents an object that can be searched for matching UI elements. |
UiAccessibilityValidator |
A validator that runs during test actions to check the accessibility of the UI. |
UiWatcher |
See |
Classes
By |
|
By.Window |
This nested class is used to create a |
BySelector |
A |
ByWindowSelector |
A |
Configurator |
Allows you to set key parameters for running UiAutomator tests. |
EventCondition |
An |
ResultsReporter |
Allows to report test results to Android Studio. |
SearchCondition |
A |
StableResult |
Represents a node that is considered stable and it's returned by |
UiAutomatorInstrumentationTestRunner |
This class is deprecated. as it only handles deprecated |
UiAutomatorTestCase |
This class is deprecated. It is no longer necessary to extend UiAutomatorTestCase. |
UiAutomatorTestScope |
A UiAutomator scope that allows to easily access UiAutomator api and utils class. |
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. |
UiDevice |
UiDevice provides access to state information about the device. |
UiObject |
A UiObject is a representation of a view. |
UiObject2 |
Represents a UI element, and exposes methods for performing gestures (clicks, swipes) or searching through its children. |
UiObject2Condition |
A |
UiScrollable |
UiScrollable is a |
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. |
UiWindow |
Represents a UI window on the screen and provides methods to access its properties and perform actions. |
Until |
The |
Exceptions
ElementNotFoundException |
Thrown when an element is not found after invoking |
StaleObjectException |
A |
UiObjectNotFoundException |
Generated in test runs when a |
Enums
Direction |
An enumeration used to specify the primary direction of certain gestures. |
Top-level functions summary
Unit |
uiAutomator(block: UiAutomatorTestScope.() -> Unit)Main entry point for ui automator tests. |
Extension functions summary
AccessibilityWindowInfo |
Returns the active window. |
Rect |
Returns the bounds of this node in screen coordinates. |
List<AccessibilityNodeInfo> |
AccessibilityNodeInfo.children(Returns all the immediate children of this node. |
List<AccessibilityNodeInfo> |
AccessibilityNodeInfo.descendants(Performs a DFS on the accessibility tree starting from this node and returns all the descendants discovered recursively. |
Boolean |
AccessibilityNodeInfo.isClass(cls: Class<*>)Returns whether this node class name is the same of the given class. |
UiObject2 |
AccessibilityNodeInfo.onElement(Performs a DFS on the accessibility tree starting from this node and returns the first node matching the given |
UiObject2 |
AccessibilityWindowInfo.onElement(Performs a DFS on the accessibility tree starting from the root node of this window and returns the first node matching the given |
UiObject2 |
UiDevice.onElement(Performs a DFS on the accessibility tree starting from the root node in the active window and returns the first node matching the given |
UiObject2 |
UiObject2.onElement(Performs a DFS on the accessibility tree starting from the node associated to this |
UiObject2? |
AccessibilityNodeInfo.onElementOrNull(Performs a DFS on the accessibility tree starting from this node and returns the first node matching the given |
UiObject2? |
AccessibilityWindowInfo.onElementOrNull(Performs a DFS on the accessibility tree starting from the root node of this window and returns the first node matching the given |
UiObject2? |
UiDevice.onElementOrNull(Performs a DFS on the accessibility tree starting from the root node in the active window and returns the first node matching the given |
UiObject2? |
UiObject2.onElementOrNull(Performs a DFS on the accessibility tree starting from the node associated to this |
List<UiObject2> |
AccessibilityNodeInfo.onElements(Performs a DFS on the accessibility tree starting from this node and returns all the nodes matching the given |
List<UiObject2> |
AccessibilityWindowInfo.onElements(Performs a DFS on the accessibility tree starting from the root node of this window and returns all the nodes matching the given |
List<UiObject2> |
UiDevice.onElements(Performs a DFS on the accessibility tree starting from this node and returns all the nodes matching the given |
List<UiObject2> |
UiObject2.onElements(Performs a DFS on the accessibility tree starting from the node associated to this |
Unit |
UiDevice.pressDelete(count: Int)Similar to |
Boolean |
Bitmap.saveToFile(Utility function to save a bitmap onto the given |
Boolean |
Bitmap.saveToFile(Utility function to save a bitmap onto the given |
UiObject2 |
UiObject2.scrollToElement(Keeps scrolling until the given |
UiObject2 |
UiObject2.scrollToElementOrNull(Keeps scrolling until the given |
List<AccessibilityNodeInfo> |
AccessibilityNodeInfo.siblings(Returns all the siblings of the this node. |
String? |
Returns this node's element id resource name without the resource namespace, i.e. only the portion after the "/" character. |
Bitmap |
Takes a screenshot of the screen that contains this node and cuts only the area covered by it. |
Bitmap |
Takes a screenshot of the screen that contains this window and cuts only the area covered by it. |
Bitmap |
Takes a screenshot of the screen that contains the accessibility node associated to this |
String? |
Returns this node's text as a string. |
Unit |
Types the given |
Boolean |
UiDevice.waitForAppToBeVisible(appPackageName: String, timeoutMs: Long)Waits for an application to become visible. |
AccessibilityNodeInfo |
AccessibilityWindowInfo.waitForRoot(Waits for the root node to become available in this window. |
AccessibilityNodeInfo |
UiDevice.waitForRootInActiveWindow(Waits for the root node to become available in this window. |
StableResult |
AccessibilityNodeInfo.waitForStable(Waits for the node to become stable. |
StableResult |
AccessibilityWindowInfo.waitForStable(Waits for the root node of this window to become stable. |
StableResult |
UiObject2.waitForStable(Waits for the node to become stable. |
StableResult |
UiDevice.waitForStableInActiveWindow(Waits for the root node of the active window to become stable. |
List<AccessibilityWindowInfo> |
Returns all the windows on all the displays. |
Top-level functions
uiAutomator
fun uiAutomator(block: UiAutomatorTestScope.() -> Unit): Unit
Main entry point for ui automator tests. It creates a UiAutomatorTestScope in which a test can be defined.
Example:
@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: UiAutomatorTestScope.() -> Unit |
A block containing the test to run within the |
Extension functions
boundsInScreen
fun AccessibilityNodeInfo.boundsInScreen(): Rect
Returns the bounds of this node in screen coordinates. This method is a shortcut for AccessibilityNodeInfo.getBoundsInScreen.
children
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[ AccessibilityNodeInfo.descendants.
| Parameters | |
|---|---|
block: (AccessibilityNodeInfo) -> Boolean = { true } |
an optional predicate to filter the node children |
| Returns | |
|---|---|
List<AccessibilityNodeInfo> |
the list of children of this node, with the given filter if specified. |
descendants
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: (AccessibilityNodeInfo) -> Boolean = { true } |
an optional predicate to filter the node children |
| Returns | |
|---|---|
List<AccessibilityNodeInfo> |
the list of all the descendants of this node, with the given filter if specified. |
isClass
fun AccessibilityNodeInfo.isClass(cls: Class<*>): Boolean
Returns whether this node class name is the same of the given class.
Usage:
onElement { isClass(Button::class.java) }.click()
onElement
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 block. The node is returned as an UiObject2 that allows interacting with it. If the requested node doesn't exist, a androidx.test.uiautomator.ElementNotFoundException is thrown. Internally it works searching periodically every pollIntervalMs.
Example:
node.onElement { textAsString == "Search" }.click()
| Parameters | |
|---|---|
timeoutMs: Long = 10000 |
a timeout to find the element that satisfies the given condition. |
pollIntervalMs: Long = 100 |
an interval to wait before rechecking the accessibility tree for updates. |
block: AccessibilityNodeInfo.() -> Boolean |
a block that specifies a condition on the node to find. |
onElement
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 block. The node is returned as an UiObject2 that allows interacting with it. If the requested node doesn't exist, a ElementNotFoundException is thrown.
Example:
onElement { textAsString == "Search" }.click()
| Parameters | |
|---|---|
timeoutMs: Long = 10000 |
a timeout to find the element that satisfies the given condition. |
pollIntervalMs: Long = 100 |
an interval to wait before rechecking the accessibility tree for updates. |
block: AccessibilityNodeInfo.() -> Boolean |
a block that specifies a condition on the node to find. |
onElement
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 block. The node is returned as an UiObject2 that allows interacting with it. If the requested node doesn't exist, a ElementNotFoundException is thrown. Internally it works searching periodically every pollIntervalMs.
Example:
uiDevice.onElement { textAsString == "Search" }.click()
| Parameters | |
|---|---|
timeoutMs: Long = 10000 |
a timeout to find the element that satisfies the given condition. |
pollIntervalMs: Long = 100 |
an interval to wait before rechecking the accessibility tree for updates. |
block: AccessibilityNodeInfo.() -> Boolean |
a block that specifies a condition on the node to find. |
onElement
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 UiObject2 and returns the first node matching the given block. The node is returned as an UiObject2 that allows interacting with it. If the requested node doesn't exist, a ElementNotFoundException is thrown. Internally it works searching periodically every pollIntervalMs.
Example:
onElement { textAsString == "Search" }.click()
| Parameters | |
|---|---|
timeoutMs: Long = 10000 |
a timeout to find the element that satisfies the given condition. |
pollIntervalMs: Long = 100 |
an interval to wait before rechecking the accessibility tree for updates. |
block: AccessibilityNodeInfo.() -> Boolean |
a block that specifies a condition on the node to find. |
onElementOrNull
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 block. The node is returned as an UiObject2 that allows interacting with it. If the requested node doesn't exist, null is returned. Internally it works searching periodically every pollIntervalMs.
Example:
node.onElement { textAsString == "Search" }.click()
| Parameters | |
|---|---|
timeoutMs: Long = 10000 |
a timeout to find the element that satisfies the given condition. |
pollIntervalMs: Long = 100 |
an interval to wait before rechecking the accessibility tree for updates. |
block: AccessibilityNodeInfo.() -> Boolean |
a block that specifies a condition on the node to find. |
onElementOrNull
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 block. The node is returned as an UiObject2 that allows interacting with it. If the requested node doesn't exist, null is returned. Internally it works searching periodically every pollIntervalMs.
Example:
onElement { textAsString == "Search" }.click()
| Parameters | |
|---|---|
timeoutMs: Long = 10000 |
a timeout to find the element that satisfies the given condition. |
pollIntervalMs: Long = 100 |
an interval to wait before rechecking the accessibility tree for updates. |
block: AccessibilityNodeInfo.() -> Boolean |
a block that specifies a condition on the node to find. |
onElementOrNull
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 block. The node is returned as an UiObject2 that allows interacting with it. If the requested node doesn't exist, null is returned. Internally it works searching periodically every pollIntervalMs.
Example:
uiDevice.onElement { textAsString == "Search" }.click()
| Parameters | |
|---|---|
timeoutMs: Long = 10000 |
a timeout to find the element that satisfies the given condition. |
pollIntervalMs: Long = 100 |
an interval to wait before rechecking the accessibility tree for updates. |
block: AccessibilityNodeInfo.() -> Boolean |
a block that specifies a condition on the node to find. |
onElementOrNull
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 UiObject2 and returns the first node matching the given block. The node is returned as an UiObject2 that allows interacting with it. If the requested node doesn't exist, null is returned. Internally it works searching periodically every pollIntervalMs.
Example:
onElement { textAsString == "Search" }.click()
| Parameters | |
|---|---|
timeoutMs: Long = 10000 |
a timeout to find the element that satisfies the given condition. |
pollIntervalMs: Long = 100 |
an interval to wait before rechecking the accessibility tree for updates. |
block: AccessibilityNodeInfo.() -> Boolean |
a block that specifies a condition on the node to find. |
onElements
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 block. This method stops waiting as soon as a single node with the given condition is returned. The nodes returned are UiObject2 that allow interacting with them. Internally it works searching periodically every pollIntervalMs.
Example:
node.onElements { className == Button::class.java.name }
If multiple nodes are expected but they appear at different times, it's recommended to call androidx.test.uiautomator.waitForStable before, to ensure any operation is complete.
| Parameters | |
|---|---|
timeoutMs: Long = 10000 |
a timeout to find the element that satisfies the given condition. |
pollIntervalMs: Long = 100 |
an interval to wait before rechecking the accessibility tree for updates. |
block: AccessibilityNodeInfo.() -> Boolean |
a block that specifies a condition on the node to find. |
onElements
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 block. This method stops waiting as soon as a single node with the given condition is returned. The nodes returned are UiObject2 that allow interacting with them. Internally it works searching periodically every pollIntervalMs.
Example:
node.onElements { className == Button::class.java.name }
If multiple nodes are expected but they appear at different times, it's recommended to call androidx.test.uiautomator.waitForStable before, to ensure any operation is complete.
| Parameters | |
|---|---|
timeoutMs: Long = 10000 |
a timeout to find the element that satisfies the given condition. |
pollIntervalMs: Long = 100 |
an interval to wait before rechecking the accessibility tree for updates. |
block: AccessibilityNodeInfo.() -> Boolean |
a block that specifies a condition on the node to find. |
onElements
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 block. This method stops waiting as soon as a single node with the given condition is returned. The nodes returned are UiObject2 that allow interacting with them. Internally it works searching periodically every pollIntervalMs.
Example:
node.onElements { className == Button::class.java.name }
If multiple nodes are expected but they appear at different times, it's recommended to call androidx.test.uiautomator.waitForStable before, to ensure any operation is complete.
| Parameters | |
|---|---|
timeoutMs: Long = 10000 |
a timeout to find the element that satisfies the given condition. |
pollIntervalMs: Long = 100 |
an interval to wait before rechecking the accessibility tree for updates. |
block: AccessibilityNodeInfo.() -> Boolean |
a block that specifies a condition on the node to find. |
onElements
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 UiObject2 and returns all the nodes matching the given block. This method stops waiting as soon as a single node with the given condition is returned. The nodes returned are UiObject2 that allow interacting with them. Internally it works searching periodically every pollIntervalMs.
Example:
node.onElements { isClass(Button::class.java) }
If multiple nodes are expected but they appear at different times, it's recommended to call androidx.test.uiautomator.waitForStable before, to ensure any operation is complete.
| Parameters | |
|---|---|
timeoutMs: Long = 10000 |
a timeout to find the element that satisfies the given condition. |
pollIntervalMs: Long = 100 |
an interval to wait before rechecking the accessibility tree for updates. |
block: AccessibilityNodeInfo.() -> Boolean |
a block that specifies a condition on the node to find. |
pressDelete
fun UiDevice.pressDelete(count: Int): Unit
Similar to type but presses the delete key for the given count times.
| Parameters | |
|---|---|
count: Int |
how many times the press delete key should be pressed. |
saveToFile
fun Bitmap.saveToFile(
file: File,
compressFormat: Bitmap.CompressFormat = Bitmap.CompressFormat.JPEG,
quality: Int = 100
): Boolean
Utility function to save a bitmap onto the given file.
| Parameters | |
|---|---|
file: File |
the file to store the bitmap. |
compressFormat: Bitmap.CompressFormat = Bitmap.CompressFormat.JPEG |
the |
quality: Int = 100 |
the quality for the compression. This is always 100 for png. |
| Returns | |
|---|---|
Boolean |
whether the bitmap was correctly saved onto a file. |
saveToFile
fun Bitmap.saveToFile(
parcelFileDescriptor: ParcelFileDescriptor,
compressFormat: Bitmap.CompressFormat = Bitmap.CompressFormat.JPEG,
quality: Int = 100
): Boolean
Utility function to save a bitmap onto the given parcelFileDescriptor.
| Parameters | |
|---|---|
parcelFileDescriptor: ParcelFileDescriptor |
the file descriptor pointing to a file to store the bitmap. |
compressFormat: Bitmap.CompressFormat = Bitmap.CompressFormat.JPEG |
the |
quality: Int = 100 |
the quality for the compression. This is always 100 for png. |
| Returns | |
|---|---|
Boolean |
whether the bitmap was correctly saved onto a file. |
scrollToElement
fun UiObject2.scrollToElement(
direction: Direction,
timeoutMs: Long = 10000,
pollIntervalMs: Long = 100,
block: AccessibilityNodeInfo.() -> Boolean
): UiObject2
Keeps scrolling until the given block condition is satisfied or until the given timeoutMs. Throws a ElementNotFoundException if the condition is not satisfied at the end of the timeout.
Example:
onElement { isScrollable }.scrollToElement(Direction.DOWN) { id == "button" }.click()
| Parameters | |
|---|---|
direction: Direction |
the scroll |
timeoutMs: Long = 10000 |
a timeout to find the element that satisfies the given condition. |
pollIntervalMs: Long = 100 |
an interval to wait before rechecking the accessibility tree for updates. |
block: AccessibilityNodeInfo.() -> Boolean |
a block that specifies a condition on the node to find. |
scrollToElementOrNull
fun UiObject2.scrollToElementOrNull(
direction: Direction,
timeoutMs: Long = 10000,
pollIntervalMs: Long = 100,
block: AccessibilityNodeInfo.() -> Boolean
): UiObject2
Keeps scrolling until the given block condition is satisfied or until the given timeoutMs. Returns null if the condition is not satisfied at the end of the timeout.
Example:
onElement { isScrollable }.scrollToElement(Direction.DOWN) { id == "button" }.click()
| Parameters | |
|---|---|
direction: Direction |
the scroll |
timeoutMs: Long = 10000 |
a timeout to find the element that satisfies the given condition. |
pollIntervalMs: Long = 100 |
an interval to wait before rechecking the accessibility tree for updates. |
block: AccessibilityNodeInfo.() -> Boolean |
a block that specifies a condition on the node to find. |
siblings
fun AccessibilityNodeInfo.siblings(
filterBlock: (AccessibilityNodeInfo) -> Boolean = { true }
): List<AccessibilityNodeInfo>
Returns all the siblings of the this node.
| Parameters | |
|---|---|
filterBlock: (AccessibilityNodeInfo) -> Boolean = { true } |
an optional predicate to filter the node siblings |
| Returns | |
|---|---|
List<AccessibilityNodeInfo> |
the list of the siblings of this node, with the given filter if specified. |
simpleViewResourceName
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.
takeScreenshot
fun AccessibilityNodeInfo.takeScreenshot(): Bitmap
Takes a screenshot of the screen that contains this node and cuts only the area covered by it.
| Returns | |
|---|---|
Bitmap |
a bitmap containing the image of this node. |
takeScreenshot
fun AccessibilityWindowInfo.takeScreenshot(): Bitmap
Takes a screenshot of the screen that contains this window and cuts only the area covered by it.
| Returns | |
|---|---|
Bitmap |
a bitmap containing the image of this node. |
takeScreenshot
fun UiObject2.takeScreenshot(): Bitmap
Takes a screenshot of the screen that contains the accessibility node associated to this UiObject2 and cuts only the area covered by it.
textAsString
fun AccessibilityNodeInfo.textAsString(): String?
Returns this node's text as a string. This should always be preferred to AccessibilityNodeInfo.text that instead returns a CharSequence, that might be either a String or a android.text.SpannableString. If a text is not specified, then it returns null.
Usage:
onElement { textAsString() == "Some text" }.click()
type
fun UiDevice.type(text: String): Unit
Types the given text string simulating key press through Instrumentation.sendKeySync. This is similar to tapping the keys on a virtual keyboard and will trigger the same listeners in the target app, as opposed to AccessibilityNodeInfo.setText that programmaticaly sets the given text in the target node.
| Parameters | |
|---|---|
text: String |
the text to type. |
waitForAppToBeVisible
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 appPackageName exists in the accessibility tree.
| Parameters | |
|---|---|
appPackageName: String |
the package name of the app to wait for. By default is the target app package name. |
timeoutMs: Long = 10000 |
a timeout for the app to become visible. |
| Returns | |
|---|---|
Boolean |
whether the app became visible in the given timeout. |
waitForRoot
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: Long = 10000 |
a timeout for the root node to become available. |
sleepIntervalMs: Long = 100 |
a interval to wait before retrying checking if the node is available. |
clearCache: Boolean = true |
whether the accessibility nodes cache should be cleared when checking. |
| Returns | |
|---|---|
AccessibilityNodeInfo |
the root node for this window. |
waitForRootInActiveWindow
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: Long = 10000 |
a timeout for the root node to become available. |
sleepIntervalMs: Long = 100 |
a interval to wait before retrying checking if the node is available. |
clearCache: Boolean = true |
whether the accessibility nodes cache should be cleared when checking. |
| Returns | |
|---|---|
AccessibilityNodeInfo |
the root node for this window. |
| Throws | |
|---|---|
kotlin.IllegalStateException |
if the root node in the active window cannot be acquired before the give timeout |
waitForStable
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: Long = 3000 |
a timeout for the wait operation, to ensure not waiting forever for stability. |
stableIntervalMs: Long = 500 |
the interval during which the node should not be changing, in order to be considered stable. |
stablePollIntervalMs: Long = 50 |
specifies how often the ui should be checked for changes. |
requireStableScreenshot: Boolean = true |
specifies if also the bitmap of the node should not change over the specified |
| Returns | |
|---|---|
StableResult |
a |
waitForStable
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: Long = 3000 |
a timeout for the wait operation, to ensure not waiting forever for stability. |
stableIntervalMs: Long = 500 |
the interval during which the node should not be changing, in order to be considered stable. |
stablePollIntervalMs: Long = 50 |
specifies how often the ui should be checked for changes. |
requireStableScreenshot: Boolean = true |
specifies if also the bitmap of the node should not change over the specified |
| Returns | |
|---|---|
StableResult |
a |
waitForStable
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: Long = 3000 |
a timeout for the wait operation, to ensure not waiting forever for stability. |
stableIntervalMs: Long = 500 |
the interval during which the node should not be changing, in order to be considered stable. |
stablePollIntervalMs: Long = 50 |
specifies how often the ui should be checked for changes. |
requireStableScreenshot: Boolean = true |
specifies if also the bitmap of the node should not change over the specified |
| Returns | |
|---|---|
StableResult |
a |
waitForStableInActiveWindow
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.
| Parameters | |
|---|---|
stableTimeoutMs: Long = 3000 |
a timeout for the wait operation, to ensure not waiting forever for stability. |
stableIntervalMs: Long = 500 |
the interval during which the node should not be changing, in order to be considered stable. |
stablePollIntervalMs: Long = 50 |
specifies how often the ui should be checked for changes. |
requireStableScreenshot: Boolean = true |
specifies if also the bitmap of the node should not change over the specified |
| Returns | |
|---|---|
StableResult |
a |
windows
fun UiDevice.windows(): List<AccessibilityWindowInfo>
Returns all the windows on all the displays.