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

Syntax

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

Remarks

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]

Requirements

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

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

See Also: Object

Public Fields

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

Public Properties

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

Protected Properties

[read-only]
override
ThresholdClassIntPtr. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.
[read-only]
override
ThresholdTypeType. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

Public Methods

ClearWindowAnimationFrameStats()
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.
SetOnAccessibilityEventListener(UiAutomation+IOnAccessibilityEventListener)
Sets a callback for observing the stream of AccessibilityEvents.
SetRotation(UiAutomationRotation) : Boolean
Sets the device rotation.
SetRunAsMonkey(Boolean)
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