UiAutomation Class

Definition

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

[Android.Runtime.Register("android/app/UiAutomation", DoNotGenerateAcw=true)]
public sealed class UiAutomation : Java.Lang.Object
[<Android.Runtime.Register("android/app/UiAutomation", DoNotGenerateAcw=true)>]
type UiAutomation = class
    inherit Object
Inheritance
UiAutomation
Attributes

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 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 reference for android.app.UiAutomation.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Fields

Name Description
FlagDontSuppressAccessibilityServices
Obsolete.

UiAutomation suppresses accessibility services by default.

FlagDontUseAccessibility
Obsolete.

UiAutomation uses the accessibility subsystem by default.

RotationFreeze0
Obsolete.

Rotation constant: Freeze rotation to 0 degrees (natural orientation)

RotationFreeze180
Obsolete.

Rotation constant: Freeze rotation to 180 degrees .

RotationFreeze270
Obsolete.

Rotation constant: Freeze rotation to 270 degrees .

RotationFreeze90
Obsolete.

Rotation constant: Freeze rotation to 90 degrees .

RotationFreezeCurrent
Obsolete.

Rotation constant: Freeze rotation to its current state.

RotationUnfreeze
Obsolete.

Rotation constant: Unfreeze rotation (rotating the device changes its rotation state).

Properties

Name Description
Class

Returns the runtime class of this Object.

(Inherited from Object)
Handle

The handle to the underlying Android instance.

(Inherited from Object)
JniIdentityHashCode

Gets the identity hash code assigned to this Java peer by the interop runtime.

(Inherited from Object)
JniManagedPeerState (Inherited from JavaObject)
JniPeerMembers

Provides JNI binding infrastructure for Android.App.UiAutomation.

PeerReference

Gets the JNI object reference for this Java peer.

(Inherited from Object)
RootInActiveWindow

Gets the root AccessibilityNodeInfo in the active window.

ServiceInfo

Gets the an AccessibilityServiceInfo describing this UiAutomation.

ThresholdClass

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

(Inherited from Object)
ThresholdType

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

(Inherited from Object)
WindowAnimationFrameStats

This method was deprecated in API level 33.

Windows

Gets the windows on the screen associated with the UiAutomation context (usually the default display.

WindowsOnAllDisplays

Gets the windows on the screen of all displays.

Methods

Name Description
AdoptShellPermissionIdentity()

Adopt the permission identity of the shell UID for all permissions.

AdoptShellPermissionIdentity(String[])

Adopt the permission identity of the shell UID only for the provided permissions.

ClearCache()

Clears the accessibility cache.

ClearWindowAnimationFrameStats()

This method was deprecated in API level 33.

ClearWindowContentFrameStats(Int32)

Clears the frame statistics for the content of a given window.

Clone()

Creates and returns a copy of this object.

(Inherited from Object)
Construct(JniObjectReference, JniObjectReferenceOptions) (Inherited from JavaObject)
Dispose()

Releases the resources held by this Java peer.

(Inherited from Object)
Dispose(Boolean)

Releases the resources held by this Java peer.

(Inherited from Object)
DisposeUnlessReferenced() (Inherited from JavaObject)
DropShellPermissionIdentity()

Drop the shell permission identity adopted by a previous call to adoptShellPermissionIdentity().

Equals(Object) (Inherited from JavaObject)
Equals(Object)

Indicates whether some other object is "equal to" this one.

(Inherited from Object)
ExecuteAndWaitForEvent(IRunnable, UiAutomation+IAccessibilityEventFilter, Int64)

Executes a command and waits for a specific accessibility event up to a given wait timeout.

ExecuteShellCommand(String)

Executes a shell command.

ExecuteShellCommandRw(String)

Executes a shell command.

ExecuteShellCommandRwe(String)

Executes a shell command.

FindFocus(NodeFocus)

Find the view that has the specified focus type.

GetHashCode()

Returns a hash code value for the object.

(Inherited from Object)
GetWindowContentFrameStats(Int32)

Gets the frame statistics for a given window.

GrantRuntimePermission(String, String)

Grants a runtime permission to a package.

GrantRuntimePermissionAsUser(String, String, UserHandle)

Grants a runtime permission to a package for a user.

InjectInputEvent(InputEvent, Boolean)

A method for injecting an arbitrary input event.

JavaFinalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

(Inherited from Object)
Notify()

Wakes up a single thread that is waiting on this object's monitor.

(Inherited from Object)
NotifyAll()

Wakes up all threads that are waiting on this object's monitor.

(Inherited from Object)
PerformGlobalAction(GlobalAction)

Performs a global action.

RevokeRuntimePermission(String, String)

Revokes a runtime permission from a package.

RevokeRuntimePermissionAsUser(String, String, UserHandle)

Revokes a runtime permission from a package.

SetAnimationScale(Single)

Sets the system settings values that control the scaling factor for animations.

SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
SetOnAccessibilityEventListener(UiAutomation+IOnAccessibilityEventListener)

Sets a callback for observing the stream of AccessibilityEvents.

SetPeerReference(JniObjectReference, JniObjectReferenceOptions) (Inherited from JavaObject)
SetRotation(UiAutomationRotation)

Sets the device rotation.

SetRunAsMonkey(Boolean)

Sets whether this UiAutomation to run in a "monkey" mode.

TakeScreenshot()

Takes a screenshot.

TakeScreenshot(Window)

Used to capture a screenshot of a Window.

ToArray<T>()

Creates a managed array from this Java array wrapper.

(Inherited from Object)
ToString()

Returns a string representation of the object.

(Inherited from Object)
UnregisterFromRuntime()

Unregisters this Java peer from the interop runtime.

(Inherited from Object)
Wait()

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>.

(Inherited from Object)
Wait(Int64, Int32)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
Wait(Int64)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
WaitForIdle(Int64, Int64)

Waits for the accessibility event stream to become idle, which is not to have received an accessibility event within idleTimeoutMillis.

Events

Name Description
AccessibilityEvent

Explicit Interface Implementations

Name Description
IJavaPeerable.Disposed() (Inherited from JavaObject)
IJavaPeerable.Finalized() (Inherited from JavaObject)
IJavaPeerable.JniObjectReferenceControlBlock (Inherited from JavaObject)
IJavaPeerable.SetJniIdentityHashCode(Int32) (Inherited from JavaObject)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) (Inherited from JavaObject)
IJavaPeerable.SetPeerReference(JniObjectReference) (Inherited from JavaObject)

Extension Methods

Name Description
GetJniTypeName(IJavaPeerable)

Gets the JNI name of the type of the instance self.

JavaAs<TResult>(IJavaPeerable)

Try to coerce self to type TResult, checking that the coercion is valid on the Java side.

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
TryJavaCast<TResult>(IJavaPeerable, TResult)

Try to coerce self to type TResult, checking that the coercion is valid on the Java side.

Applies to