# UiAutomatorTestScopeKt

Added in 2.4.1

*** ** * ** ***


```
public final class UiAutomatorTestScopeKt
```

<br />

*** ** * ** ***

## Summary

| ### Public methods |
|---|---|
| `static final void` | `https://developer.android.com/reference/androidx/test/uiautomator/UiAutomatorTestScopeKt#uiAutomator(kotlin.Function1)(@https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/test/uiautomator/UiAutomatorTestScope, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> block)` Main entry point for ui automator tests. |

## Public methods

### uiAutomator

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/UiAutomatorTestScope.kt+function:uiAutomator) Added in [2.4.1](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.4.1)

```
public static final void uiAutomator(@NonNull Function1<@NonNull UiAutomatorTestScope, Unit> block)
```

Main entry point for ui automator tests. It creates a `https://developer.android.com/reference/androidx/test/uiautomator/UiAutomatorTestScope` in which a test can be defined.

Example:

```
@Test
fun myTest() = uiAutomator {

    startActivity(MyActivity::class.java)

    onElement { id == "button" }.click()

    onElement { id == "nested_elements" }
        .apply {
            onElement { text == "First Level" }
            onElement { text == "Second Level" }
            onElement { text == "Third Level" }
        }
}
```

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/test/uiautomator/UiAutomatorTestScope, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> block` | A block containing the test to run within the `https://developer.android.com/reference/androidx/test/uiautomator/UiAutomatorTestScope`. |