Package-level declarations

Types

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

One accessibility node, read once into plain values.

Link copied to clipboard

Captures every window's accessibility tree as AccessibilityElements in one pass.

Link copied to clipboard
class DiagnosticsOnFailureRule(val directory: File = defaultDirectory()) : TestWatcher

Saves a screenshot and the window hierarchy when a test fails, so a CI failure shows what was on screen.

Link copied to clipboard
open class InstrumentationArgsRunner(forwardedArguments: Set<String>) : AndroidJUnitRunner

An AndroidJUnitRunner that copies selected instrumentation arguments to system properties before tests start, so app code that reads System.getProperty (for example a base URL override) sees values passed with -e or testInstrumentationRunnerArguments.

Properties

Link copied to clipboard

The default wait budget for device helpers, in milliseconds.

Functions

Link copied to clipboard
fun View.containsText(expected: String, substring: Boolean = false): Boolean

Returns whether this view or a descendant is a TextView showing expected, including text inside AndroidView interop content that Compose semantics cannot see.

Link copied to clipboard
fun UiDevice.dragWithHold(fromX: Int, fromY: Int, toX: Int, toY: Int, durationMillis: Long = 500, holdMillis: Long = 600, uiAutomation: UiAutomation = InstrumentationRegistry.getInstrumentation().uiAutomation): Boolean

Performs a real drag: presses at the origin, holds for holdMillis, moves to the destination over durationMillis, settles, and releases.

Link copied to clipboard

Returns the element to tap for the single element matching predicate.

Link copied to clipboard
fun hasResourceEntryName(name: String): Matcher<View>

Matches views whose ID has the resource entry name name, such as save for R.id.save.

Link copied to clipboard

Returns an instrumentation argument passed with -e name value or testInstrumentationRunnerArguments, such as a mock server URL.

Link copied to clipboard
fun UiDevice.isKeyboardVisible(uiAutomation: UiAutomation = InstrumentationRegistry.getInstrumentation().uiAutomation): Boolean

Returns whether the on-screen keyboard is shown, from the window list rather than shell output.

Link copied to clipboard
fun UiDevice.launchPackage(packageName: String, timeout: Duration = DefaultDeviceTimeout)

Launches another installed app's launcher activity in a fresh task and waits for its window.

Link copied to clipboard

Launches the instrumented app's launcher activity in a fresh task.

Link copied to clipboard
fun UiDevice.pressBackReliably(uiAutomation: UiAutomation = InstrumentationRegistry.getInstrumentation().uiAutomation): Boolean

Navigates back and reports whether the system accepted the action.

Link copied to clipboard
fun UiDevice.scrollUntilVisible(target: BySelector, container: BySelector? = null, direction: Direction = Direction.DOWN, maxScrolls: Int = 10): UiObject2?

Scrolls until an object matching target is visible, within maxScrolls attempts.

Link copied to clipboard

Turns the system window, transition, and animator animations off or back on, so UI tests do not wait on, or race with, animations. Restore them when the suite finishes.

Link copied to clipboard
fun UiDevice.setAppLocales(packageName: String, languageTags: List<String>)

Sets the per-app languages of packageName, like choosing an app language in Settings.

Link copied to clipboard
fun UiDevice.setTextVerified(selector: BySelector, text: String, timeout: Duration = DefaultDeviceTimeout)

Replaces the text of the single field matching selector and verifies the result.

Link copied to clipboard
fun UiDevice.uniqueObject(selector: BySelector, timeout: Duration = DefaultDeviceTimeout): UiObject2

Waits for exactly one object matching selector and returns it.

Link copied to clipboard
fun waitForView(matcher: Matcher<View>, timeout: Duration = DefaultDeviceTimeout, displayed: Boolean = true): ViewAction

Returns an action, performed on the root view, that waits until a view matching matcher is displayed (displayed true) or until none is (displayed false).

Link copied to clipboard
fun waitUntilDisplayed(matcher: Matcher<View>, timeout: Duration = DefaultDeviceTimeout)

Waits until a view matching matcher is displayed.

Link copied to clipboard
fun waitUntilNotDisplayed(matcher: Matcher<View>, timeout: Duration = DefaultDeviceTimeout)

Waits until no view matching matcher is displayed.

Link copied to clipboard
fun withIndex(matcher: Matcher<View>, index: Int): Matcher<View>

Matches only the indexth view, in breadth-first order, among views matching matcher.