# Configurator

Artifact: [androidx.test.uiautomator:uiautomator](https://developer.android.com/jetpack/androidx/releases/test-uiautomator) [View Source](https://cs.android.com/search?q=file:androidx/test/uiautomator/Configurator.java+class:androidx.test.uiautomator.Configurator) Added in [2.2.0](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.2.0)

*** ** * ** ***


```
class Configurator
```

<br />

*** ** * ** ***

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 `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/Configurator#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 functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/Configurator#addUiAccessibilityValidator(androidx.test.uiautomator.UiAccessibilityValidator)(validator: https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiAccessibilityValidator)` Adds a validator to be run before important test actions like click(), swipe(), etc. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/Configurator#getActionAcknowledgmentTimeout()()` Gets the current timeout for waiting for an acknowledgment of a `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject` click. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/Configurator#getDefaultDisplayId()()` Gets the default display ID to use when obtaining a `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector` instance, or returns `https://developer.android.com/reference/android/view/Display.html#INVALID_DISPLAY` if the default display ID is not set yet. |
| `java-static https://developer.android.com/reference/kotlin/androidx/test/uiautomator/Configurator` | `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/Configurator#getInstance()()` Retrieves a singleton instance of Configurator. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `[getKeyInjectionDelay](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/Configurator#getKeyInjectionDelay())()` **This function is deprecated.** This parameter is no longer used (text is set directly rather than by key). <br /> |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/Configurator#getScrollAcknowledgmentTimeout()()` Gets the current timeout for waiting for an acknowledgement of a `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiScrollable` scroll action. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/Configurator#getToolType()()` Gets the current tool type to use for motion events. |
| `(https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiAccessibilityValidator!>` | `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/Configurator#getUiAccessibilityValidators()()` Gets the currently assigned UiAccessibilityValidators. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/Configurator#getUiAutomationFlags()()` Gets the current flags that are used to obtain a `https://developer.android.com/reference/android/app/UiAutomation.html` instance. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/Configurator#getWaitForIdleTimeout()()` Gets the current timeout used for waiting for the user interface to go into an idle state before starting a UiAutomator action. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/Configurator#getWaitForSelectorTimeout()()` Gets the current timeout for waiting for a `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject` to become visible in the user interface so that it can be matched by a `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiSelector`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/Configurator#removeUiAccessibilityValidator(androidx.test.uiautomator.UiAccessibilityValidator)(validator: https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiAccessibilityValidator)` Removes a validator added via `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/Configurator#addUiAccessibilityValidator(androidx.test.uiautomator.UiAccessibilityValidator)`. |
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/Configurator` | `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/Configurator#resetDefaultDisplayId()()` Resets the default display ID to use when obtaining a `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector` instance. |
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/Configurator` | `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/Configurator#setActionAcknowledgmentTimeout(long)(timeout: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` Sets the timeout for waiting for an acknowledgment of a `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject` click. |
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/Configurator` | `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/Configurator#setDefaultDisplayId(int)(defaultDisplayId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Sets the default display ID to use when obtaining a `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector` instance. |
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/Configurator` | `[setKeyInjectionDelay](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/Configurator#setKeyInjectionDelay(long))(delay: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` **This function is deprecated.** This parameter is no longer used (text is set directly rather than by key). <br /> |
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/Configurator` | `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/Configurator#setScrollAcknowledgmentTimeout(long)(timeout: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` Sets the timeout for waiting for an acknowledgement of a `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiScrollable` scroll action. |
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/Configurator` | `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/Configurator#setToolType(int)(toolType: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Sets the tool type to use for motion events. |
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/Configurator` | `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/Configurator#setUiAutomationFlags(int)(flags: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Sets the flags to use when obtaining a `https://developer.android.com/reference/android/app/UiAutomation.html` instance. |
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/Configurator` | `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/Configurator#setWaitForIdleTimeout(long)(timeout: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` Sets the timeout for waiting for the user interface to go into an idle state before starting a UiAutomator action. |
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/Configurator` | `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/Configurator#setWaitForSelectorTimeout(long)(timeout: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` Sets the timeout for waiting for a `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject` to become visible in the user interface so that it can be matched by a `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiSelector`. |

## Public functions

### addUiAccessibilityValidator

Added in [2.4.1](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.4.1)

```
fun addUiAccessibilityValidator(validator: UiAccessibilityValidator): Unit
```

Adds a validator to be run before important test actions like click(), swipe(), etc.

The validator can provide custom accessibility checks. The validate method is called before performing any action on a UI element via `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2`, or the display via `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiDevice`, such as clicking or scrolling.

| Parameters |
|---|---|
| `validator: https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiAccessibilityValidator` | to be invoked during UI actions |

### getActionAcknowledgmentTimeout

Added in [2.2.0](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.2.0)

```
fun getActionAcknowledgmentTimeout(): Long
```

Gets the current timeout for waiting for an acknowledgment of a `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject` click.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | current timeout in milliseconds |

### getDefaultDisplayId

Added in [2.4.1](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.4.1)

```
fun getDefaultDisplayId(): Int
```

Gets the default display ID to use when obtaining a `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector` instance, or returns `https://developer.android.com/reference/android/view/Display.html#INVALID_DISPLAY` if the default display ID is not set yet.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | the default display ID |

### getInstance

Added in [2.2.0](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.2.0)

```
java-static fun getInstance(): Configurator
```

Retrieves a singleton instance of Configurator.

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/Configurator` | Configurator instance |

### getKeyInjectionDelay

Added in [2.2.0](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.2.0) Deprecated in [2.4.1](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.4.1)

```
fun [getKeyInjectionDelay](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/Configurator#getKeyInjectionDelay())(): Long
```

> [!CAUTION]
> **This function is deprecated.**   
>
> This parameter is no longer used (text is set directly rather than by key).

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

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | current delay in milliseconds |

### getScrollAcknowledgmentTimeout

Added in [2.2.0](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.2.0)

```
fun getScrollAcknowledgmentTimeout(): Long
```

Gets the current timeout for waiting for an acknowledgement of a `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiScrollable` scroll action.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | current timeout in milliseconds |

### getToolType

Added in [2.2.0](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.2.0)

```
fun getToolType(): Int
```

Gets the current tool type to use for motion events.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | current tool type |

| See also |
|---|---|
| `https://developer.android.com/reference/android/view/MotionEvent.html#getToolType(int)` |   |

### getUiAccessibilityValidators

Added in [2.4.1](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.4.1)

```
fun getUiAccessibilityValidators(): (Mutable)List<UiAccessibilityValidator!>
```

Gets the currently assigned UiAccessibilityValidators.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/Configurator#addUiAccessibilityValidator(androidx.test.uiautomator.UiAccessibilityValidator)` |   |

### getUiAutomationFlags

Added in [2.2.0](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.2.0)

```
fun getUiAutomationFlags(): Int
```

Gets the current flags that are used to obtain a `https://developer.android.com/reference/android/app/UiAutomation.html` instance.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | UiAutomation flags |

| See also |
|---|---|
| `https://developer.android.com/reference/android/app/Instrumentation.html#getUiAutomation(int)` |   |
| `https://developer.android.com/reference/android/app/UiAutomation.html#FLAG_DONT_SUPPRESS_ACCESSIBILITY_SERVICES` |   |

### getWaitForIdleTimeout

Added in [2.2.0](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.2.0)

```
fun getWaitForIdleTimeout(): Long
```

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

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | current timeout in milliseconds |

### getWaitForSelectorTimeout

Added in [2.2.0](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.2.0)

```
fun getWaitForSelectorTimeout(): Long
```

Gets the current timeout for waiting for a `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject` to become visible in the user interface so that it can be matched by a `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiSelector`.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | current timeout in milliseconds |

### removeUiAccessibilityValidator

Added in [2.4.1](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.4.1)

```
fun removeUiAccessibilityValidator(validator: UiAccessibilityValidator): Unit
```

Removes a validator added via `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/Configurator#addUiAccessibilityValidator(androidx.test.uiautomator.UiAccessibilityValidator)`.

### resetDefaultDisplayId

Added in [2.4.1](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.4.1)

```
fun resetDefaultDisplayId(): Configurator
```

Resets the default display ID to use when obtaining a `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector` instance.

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/Configurator` | self |

### setActionAcknowledgmentTimeout

Added in [2.2.0](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.2.0)

```
fun setActionAcknowledgmentTimeout(timeout: Long): Configurator
```

Sets the timeout for waiting for an acknowledgment of a `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject` click.

The acknowledgment is an `https://developer.android.com/reference/android/view/accessibility/AccessibilityEvent.html` 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 `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiDevice` and `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2` clicks.

| Parameters |
|---|---|
| `timeout: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | Timeout value in milliseconds |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/Configurator` | self |

### setDefaultDisplayId

Added in [2.4.1](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.4.1)

```
fun setDefaultDisplayId(defaultDisplayId: Int): Configurator
```

Sets the default display ID to use when obtaining a `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/BySelector` instance. To avoid interfering with other tests, the caller must call `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/Configurator#resetDefaultDisplayId()` when the test is finished.

| Parameters |
|---|---|
| `defaultDisplayId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | the default display ID to use |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/Configurator` | self |

### setKeyInjectionDelay

Added in [2.2.0](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.2.0) Deprecated in [2.4.1](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.4.1)

```
fun [setKeyInjectionDelay](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/Configurator#setKeyInjectionDelay(long))(delay: Long): Configurator
```

> [!CAUTION]
> **This function is deprecated.**   
>
> This parameter is no longer used (text is set directly rather than by key).

Sets a delay between key presses when injecting text input.

| Parameters |
|---|---|
| `delay: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | Delay value in milliseconds |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/Configurator` | self |

### setScrollAcknowledgmentTimeout

Added in [2.2.0](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.2.0)

```
fun setScrollAcknowledgmentTimeout(timeout: Long): Configurator
```

Sets the timeout for waiting for an acknowledgement of a `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiScrollable` scroll action.

The acknowledgment is an `https://developer.android.com/reference/android/view/accessibility/AccessibilityEvent.html` 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 `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2` scrolls.

| Parameters |
|---|---|
| `timeout: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | Timeout value in milliseconds |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/Configurator` | self |

### setToolType

Added in [2.2.0](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.2.0)

```
fun setToolType(toolType: Int): Configurator
```

Sets the tool type to use for motion events.

| Parameters |
|---|---|
| `toolType: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The tool type to use |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/Configurator` | self |

| See also |
|---|---|
| `https://developer.android.com/reference/android/view/MotionEvent.html#getToolType(int)` |   |
| `https://developer.android.com/reference/android/view/MotionEvent.html#TOOL_TYPE_FINGER` |   |
| `https://developer.android.com/reference/android/view/MotionEvent.html#TOOL_TYPE_STYLUS` |   |
| `https://developer.android.com/reference/android/view/MotionEvent.html#TOOL_TYPE_MOUSE` |   |
| `https://developer.android.com/reference/android/view/MotionEvent.html#TOOL_TYPE_ERASER` |   |
| `https://developer.android.com/reference/android/view/MotionEvent.html#TOOL_TYPE_UNKNOWN` |   |

### setUiAutomationFlags

Added in [2.2.0](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.2.0)

```
fun setUiAutomationFlags(flags: Int): Configurator
```

Sets the flags to use when obtaining a `https://developer.android.com/reference/android/app/UiAutomation.html` instance.

| Parameters |
|---|---|
| `flags: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The UiAutomation flags to use |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/Configurator` | self |

| See also |
|---|---|
| `https://developer.android.com/reference/android/app/Instrumentation.html#getUiAutomation(int)` |   |
| `https://developer.android.com/reference/android/app/UiAutomation.html#FLAG_DONT_SUPPRESS_ACCESSIBILITY_SERVICES` |   |

### setWaitForIdleTimeout

Added in [2.2.0](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.2.0)

```
fun setWaitForIdleTimeout(timeout: Long): Configurator
```

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

| Parameters |
|---|---|
| `timeout: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | Timeout value in milliseconds |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/Configurator` | self |

### setWaitForSelectorTimeout

Added in [2.2.0](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.2.0)

```
fun setWaitForSelectorTimeout(timeout: Long): Configurator
```

Sets the timeout for waiting for a `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject` to become visible in the user interface so that it can be matched by a `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiSelector`.

For `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject`s, the underlying node is fetched with this timeout before every action.

Has no effect on `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiObject2`s, which cache the underlying node. Instead, use `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiDevice#wait(androidx.test.uiautomator.SearchCondition<U>,long)` and `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/Until#findObject(androidx.test.uiautomator.BySelector)` to wait for the object to become visible.

| Parameters |
|---|---|
| `timeout: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | Timeout value in milliseconds |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/Configurator` | self |