public final class Configurator


Allows you to set key parameters for running uiautomator tests. The new settings take effect immediately and can be changed any time during a test run. To modify parameters using Configurator, first obtain an instance by calling getInstance. As a best practice, make sure you always save the original value of any parameter that you are modifying. After running your tests with the modified parameters, make sure to also restore the original parameter values, otherwise this will impact other tests cases.

Summary

Public methods

long

Gets the current timeout for waiting for an acknowledgment of generic uiautomator actions, such as clicks, text setting, and menu presses.

static @NonNull Configurator

Retrieves a singleton instance of Configurator.

long

Gets the current delay between key presses when injecting text input.

long

Gets the timeout for waiting for an acknowledgement of an uiautomtor scroll swipe action.

int

Gets the current tool type to use for motion events.

int

Gets the current flags that are used to obtain a android.app.UiAutomation instance.

long

Gets the current timeout used for waiting for the user interface to go into an idle state.

long

Gets the current timeout for waiting for a widget to become visible in the user interface so that it can be matched by a selector.

@NonNull Configurator

Sets the timeout for waiting for an acknowledgment of generic uiautomator actions, such as clicks, text setting, and menu presses.

@NonNull Configurator

Sets a delay between key presses when injecting text input.

@NonNull Configurator

Sets the timeout for waiting for an acknowledgement of an uiautomtor scroll swipe action.

@NonNull Configurator
setToolType(int toolType)

Sets the current tool type to use for motion events.

@NonNull Configurator

Sets the flags to use when obtaining a android.app.UiAutomation instance.

@NonNull Configurator
setWaitForIdleTimeout(long timeout)

Sets the timeout for waiting for the user interface to go into an idle state before starting a uiautomator action.

@NonNull Configurator

Sets the timeout for waiting for a widget to become visible in the user interface so that it can be matched by a selector.

Public methods

getActionAcknowledgmentTimeout

public long getActionAcknowledgmentTimeout()

Gets the current timeout for waiting for an acknowledgment of generic uiautomator actions, such as clicks, text setting, and menu presses. The acknowledgment is an AccessibilityEvent, corresponding to an action, that lets the framework determine if the action was successful. Generally, this timeout should not be modified. See UiObject

Returns
long

current timeout in milliseconds

getInstance

public static @NonNull Configurator getInstance()

Retrieves a singleton instance of Configurator.

Returns
@NonNull Configurator

Configurator instance

getKeyInjectionDelay

public long getKeyInjectionDelay()

Gets the current delay between key presses when injecting text input. See setText

Returns
long

current delay in milliseconds

getScrollAcknowledgmentTimeout

public long getScrollAcknowledgmentTimeout()

Gets the timeout for waiting for an acknowledgement of an uiautomtor scroll swipe action. The acknowledgment is an AccessibilityEvent, corresponding to the scroll action, that lets the framework determine if the scroll action was successful. Generally, this timeout should not be modified. See UiScrollable

Returns
long

current timeout in milliseconds

getToolType

public int getToolType()

Gets the current tool type to use for motion events.

See also
getToolType

getUiAutomationFlags

public int getUiAutomationFlags()

Gets the current flags that are used to obtain a android.app.UiAutomation instance.

Returns
int

The UiAutomation flags.

getWaitForIdleTimeout

public long getWaitForIdleTimeout()

Gets the current timeout used for waiting for the user interface to go into an idle state. By default, all core uiautomator objects except UiDevice will perform this wait before starting to search for the widget specified by the object's UiSelector. Once the idle state is detected or the timeout elapses (whichever occurs first), the object will start to wait for the selector to find a match. See setWaitForSelectorTimeout

Returns
long

Current timeout value in milliseconds

getWaitForSelectorTimeout

public long getWaitForSelectorTimeout()

Gets the current timeout for waiting for a widget to become visible in the user interface so that it can be matched by a selector. Because user interface content is dynamic, sometimes a widget may not be visible immediately and won't be detected by a selector. This timeout allows the uiautomator framework to wait for a match to be found, up until the timeout elapses.

Returns
long

Current timeout value in milliseconds

setActionAcknowledgmentTimeout

public @NonNull Configurator setActionAcknowledgmentTimeout(long timeout)

Sets the timeout for waiting for an acknowledgment of generic uiautomator actions, such as clicks, text setting, and menu presses. The acknowledgment is an AccessibilityEvent, corresponding to an action, that lets the framework determine if the action was successful. Generally, this timeout should not be modified. See UiObject

Parameters
long timeout

Timeout value in milliseconds

Returns
@NonNull Configurator

self

setKeyInjectionDelay

public @NonNull Configurator setKeyInjectionDelay(long delay)

Sets a delay between key presses when injecting text input. See setText

Parameters
long delay

Delay value in milliseconds

Returns
@NonNull Configurator

self

setScrollAcknowledgmentTimeout

public @NonNull Configurator setScrollAcknowledgmentTimeout(long timeout)

Sets the timeout for waiting for an acknowledgement of an uiautomtor scroll swipe action. The acknowledgment is an AccessibilityEvent, corresponding to the scroll action, that lets the framework determine if the scroll action was successful. Generally, this timeout should not be modified. See UiScrollable

Parameters
long timeout

Timeout value in milliseconds

Returns
@NonNull Configurator

self

setToolType

public @NonNull Configurator setToolType(int toolType)

Sets the current tool type to use for motion events.

setUiAutomationFlags

public @NonNull Configurator setUiAutomationFlags(int flags)

Sets the flags to use when obtaining a android.app.UiAutomation instance.

Parameters
int flags

The UiAutomation flags to use.

Returns
@NonNull Configurator

A reference to this object.

setWaitForIdleTimeout

public @NonNull Configurator setWaitForIdleTimeout(long timeout)

Sets the timeout for waiting for the user interface to go into an idle state before starting a uiautomator action. By default, all core uiautomator objects except UiDevice will perform this wait before starting to search for the widget specified by the object's UiSelector. Once the idle state is detected or the timeout elapses (whichever occurs first), the object will start to wait for the selector to find a match. See setWaitForSelectorTimeout

Parameters
long timeout

Timeout value in milliseconds

Returns
@NonNull Configurator

self

setWaitForSelectorTimeout

public @NonNull Configurator setWaitForSelectorTimeout(long timeout)

Sets the timeout for waiting for a widget to become visible in the user interface so that it can be matched by a selector. Because user interface content is dynamic, sometimes a widget may not be visible immediately and won't be detected by a selector. This timeout allows the uiautomator framework to wait for a match to be found, up until the timeout elapses.

Parameters
long timeout

Timeout value in milliseconds.

Returns
@NonNull Configurator

self