Dela via


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 android.accessibilityservice.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.

Java documentation 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

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

Class

Returns the runtime class of this Object.

(Inherited from Object)
Handle

The handle to the underlying Android instance.

(Inherited from Object)
JniIdentityHashCode (Inherited from Object)
JniPeerMembers
PeerReference (Inherited from Object)
RootInActiveWindow

Gets the root AccessibilityNodeInfo in the active window.

ServiceInfo

Gets the an AccessibilityServiceInfo describing this UiAutomation. -or- Sets the AccessibilityServiceInfo that describes how this UiAutomation will be handled by the platform accessibility layer.

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

Gets the window animation frame statistics.

Windows

Gets the windows on the screen associated with the UiAutomation context (usually the android.view.Display#DEFAULT_DISPLAY default display).

        &lt;p&gt;
        This method returns only the windows that a sighted user can interact with, as opposed to
        all windows.

        &lt;p&gt;
        For example, if there is a modal dialog shown and the user cannot touch
        anything behind it, then only the modal window will be reported
        (assuming it is the top one). For convenience the returned windows
        are ordered in a descending layer order, which is the windows that
        are higher in the Z-order are reported first.
        &lt;p&gt;
        &lt;strong&gt;Note:&lt;/strong&gt; In order to access the windows you have to opt-in
        to retrieve the interactive windows by setting the
        {@link AccessibilityServiceInfo#FLAG_RETRIEVE_INTERACTIVE_WINDOWS</code> flag.
WindowsOnAllDisplays

Gets the windows on the screen of all displays.

Methods

AdoptShellPermissionIdentity()

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

AdoptShellPermissionIdentity(String[])

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

ClearCache()

Clears the accessibility cache.

ClearWindowAnimationFrameStats()

Clears the window animation rendering statistics.

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)
Dispose() (Inherited from Object)
Dispose(Boolean) (Inherited from Object)
DropShellPermissionIdentity()

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

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.

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>() (Inherited from Object)
ToString()

Returns a string representation of the object.

(Inherited from Object)
UnregisterFromRuntime() (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

AccessibilityEvent

Explicit Interface Implementations

IJavaPeerable.Disposed() (Inherited from Object)
IJavaPeerable.DisposeUnlessReferenced() (Inherited from Object)
IJavaPeerable.Finalized() (Inherited from Object)
IJavaPeerable.JniManagedPeerState (Inherited from Object)
IJavaPeerable.SetJniIdentityHashCode(Int32) (Inherited from Object)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) (Inherited from Object)
IJavaPeerable.SetPeerReference(JniObjectReference) (Inherited from Object)

Extension Methods

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable)

Applies to