Configurator


public final class Configurator


Allows you to set key parameters for running UiAutomator tests. The new settings take effect immediately and can be changed at any time during a test run.

To modify parameters, 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 a UiObject click.

static @NonNull Configurator

Retrieves a singleton instance of Configurator.

long

This method is deprecated.

This parameter is no longer used (text is set directly rather than by key).

long

Gets the current timeout for waiting for an acknowledgement of a UiScrollable scroll 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 before starting a UiAutomator action.

long

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

@NonNull Configurator

Sets the timeout for waiting for an acknowledgment of a UiObject click.

@NonNull Configurator

This method is deprecated.

This parameter is no longer used (text is set directly rather than by key).

@NonNull Configurator

Sets the timeout for waiting for an acknowledgement of a UiScrollable scroll action.

@NonNull Configurator
setToolType(int toolType)

Sets the 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 UiObject to become visible in the user interface so that it can be matched by a UiSelector.

Public methods

getActionAcknowledgmentTimeout

Added in 2.2.0
public long getActionAcknowledgmentTimeout()

Gets the current timeout for waiting for an acknowledgment of a UiObject click.

Returns
long

current timeout in milliseconds

getInstance

Added in 2.2.0
public static @NonNull Configurator getInstance()

Retrieves a singleton instance of Configurator.

Returns
@NonNull Configurator

Configurator instance

getKeyInjectionDelay

Added in 2.2.0
Deprecated in 2.4.0-alpha01
public long getKeyInjectionDelay()

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

Returns
long

current delay in milliseconds

getScrollAcknowledgmentTimeout

Added in 2.2.0
public long getScrollAcknowledgmentTimeout()

Gets the current timeout for waiting for an acknowledgement of a UiScrollable scroll action.

Returns
long

current timeout in milliseconds

getToolType

Added in 2.2.0
public int getToolType()

Gets the current tool type to use for motion events.

Returns
int

current tool type

See also
getToolType

getUiAutomationFlags

Added in 2.2.0
public int getUiAutomationFlags()

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

Returns
int

UiAutomation flags

getWaitForIdleTimeout

Added in 2.2.0
public long getWaitForIdleTimeout()

Gets the current timeout used for waiting for the user interface to go into an idle state before starting a UiAutomator action.

Returns
long

current timeout in milliseconds

getWaitForSelectorTimeout

Added in 2.2.0
public long getWaitForSelectorTimeout()

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

Returns
long

current timeout in milliseconds

setActionAcknowledgmentTimeout

Added in 2.2.0
public @NonNull Configurator setActionAcknowledgmentTimeout(long timeout)

Sets the timeout for waiting for an acknowledgment of a UiObject click.

The acknowledgment is an android.view.accessibility.AccessibilityEvent corresponding to a content change that lets the framework determine if the action was successful. Generally, this timeout should not be modified.

Has no effect on UiDevice and UiObject2 clicks.

Parameters
long timeout

Timeout value in milliseconds

Returns
@NonNull Configurator

self

setKeyInjectionDelay

Added in 2.2.0
Deprecated in 2.4.0-alpha01
public @NonNull Configurator setKeyInjectionDelay(long delay)

Sets a delay between key presses when injecting text input.

Parameters
long delay

Delay value in milliseconds

Returns
@NonNull Configurator

self

setScrollAcknowledgmentTimeout

Added in 2.2.0
public @NonNull Configurator setScrollAcknowledgmentTimeout(long timeout)

Sets the timeout for waiting for an acknowledgement of a UiScrollable scroll action.

The acknowledgment is an android.view.accessibility.AccessibilityEvent corresponding to the scroll action that lets the framework determine if it was successful. Generally, this timeout should not be modified.

Has no effect on UiObject2 scrolls.

Parameters
long timeout

Timeout value in milliseconds

Returns
@NonNull Configurator

self

setToolType

Added in 2.2.0
public @NonNull Configurator setToolType(int toolType)

Sets the tool type to use for motion events.

Parameters
int toolType

The tool type to use

Returns
@NonNull Configurator

self

setUiAutomationFlags

Added in 2.2.0
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

self

setWaitForIdleTimeout

Added in 2.2.0
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.

Parameters
long timeout

Timeout value in milliseconds

Returns
@NonNull Configurator

self

setWaitForSelectorTimeout

Added in 2.2.0
public @NonNull Configurator setWaitForSelectorTimeout(long timeout)

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

For UiObjects, the underlying node is fetched with this timeout before every action.

Has no effect on UiObject2s, which cache the underlying node. Instead, use wait and findObject to wait for the object to become visible.

Parameters
long timeout

Timeout value in milliseconds

Returns
@NonNull Configurator

self