Android Guides | Samples

Android.App.UiAutomation Class

Class for interacting with the device's UI by simulation user actions and introspection of the screen content.

See Also: UiAutomation


[Android.Runtime.Register("android/app/UiAutomation", DoNotGenerateAcw=true)]
public sealed class UiAutomation : Object


Class for interacting with the device's UI by simulation user actions and introspection of the screen content. It relies on the platform accessibility APIs to introspect the screen and to perform some actions on the remote view tree. It also allows injecting of arbitrary raw input events simulating user interaction with keyboards and touch devices. One can think of a UiAutomation as a special type of AccessibilityService which does not provide hooks for the service life cycle and exposes other APIs that are useful for UI test automation.

The APIs exposed by this class are low-level to maximize flexibility when developing UI test automation tools and libraries. Generally, a UiAutomation client should be using a higher-level library or implement high-level functions. For example, performing a tap on the screen requires construction and injecting of a touch down and up events which have to be delivered to the system by a call to UiAutomation.InjectInputEvent(InputEvent,Boolean).

The APIs exposed by this class operate across applications enabling a client to write tests that cover use cases spanning over multiple applications. For example, going to the settings application to change a setting and then interacting with another application whose behavior depends on that setting.

[Android Documentation]


Namespace: Android.App
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions:
Since: Added in API level 18

The members of Android.App.UiAutomation are listed below.

See Also: Object

Public Fields

RotationFreeze0UiAutomationRotation (0). Rotation constant: Freeze rotation to 0 degrees (natural orientation)
RotationFreeze180UiAutomationRotation (2). Rotation constant: Freeze rotation to 180 degrees .
RotationFreeze270UiAutomationRotation (3). Rotation constant: Freeze rotation to 270 degrees .
RotationFreeze90UiAutomationRotation (1). Rotation constant: Freeze rotation to 90 degrees .
RotationFreezeCurrentUiAutomationRotation (-1). Rotation constant: Freeze rotation to its current state.
RotationUnfreezeUiAutomationRotation (-2). Rotation constant: Unfreeze rotation (rotating the device changes its rotation state).

Public Properties

RootInActiveWindowAccessibilityNodeInfo. Gets the root AccessibilityNodeInfo in the active window.
ServiceInfoAccessibilityServiceInfo. Gets the an AccessibilityServiceInfo describing this UiAutomation.
WindowAnimationFrameStatsWindowAnimationFrameStats. Gets the window animation frame statistics.
WindowsIList<Android.Views.Accessibility.AccessibilityWindowInfo>. Gets the windows on the screen.

Protected Properties

ThresholdClassIntPtr. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.
ThresholdTypeType. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

Public Methods

Clears the window animation rendering statistics.
ClearWindowContentFrameStats(Int32) : Boolean
Clears the frame statistics for the content of a given window.
ExecuteAndWaitForEvent(IRunnable, UiAutomation+IAccessibilityEventFilter, Int64) : AccessibilityEvent
Executes a command and waits for a specific accessibility event up to a given wait timeout.
ExecuteShellCommand(String) : ParcelFileDescriptor
Executes a shell command.
FindFocus(NodeFocus) : AccessibilityNodeInfo
Find the view that has the specified focus type.
GetWindowContentFrameStats(Int32) : WindowContentFrameStats
Gets the frame statistics for a given window.
InjectInputEvent(InputEvent, Boolean) : Boolean
A method for injecting an arbitrary input event.
PerformGlobalAction(GlobalAction) : Boolean
Performs a global action.
Sets a callback for observing the stream of AccessibilityEvents.
SetRotation(UiAutomationRotation) : Boolean
Sets the device rotation.
Sets whether this UiAutomation to run in a "monkey" mode.
TakeScreenshot() : Bitmap
Takes a screenshot.
WaitForIdle(Int64, Int64)
Waits for the accessibility event stream to become idle, which is not to have received an accessibility event within idleTimeoutMillis.

Public Events