# DeviceInteraction

Artifact: [androidx.test.espresso:espresso-device](https://developer.android.com/jetpack/androidx/releases/test-espresso) [View Source](https://cs.android.com/search?q=file:androidx/test/espresso/device/DeviceInteraction.kt+class:androidx.test.espresso.device.DeviceInteraction)

*** ** * ** ***


```
public final class DeviceInteraction
```

<br />

*** ** * ** ***

API surface for performing device-centric operations.

## Summary

| ### Nested types |
|---|
| `public static class https://developer.android.com/reference/androidx/test/espresso/device/DeviceInteraction.Companion` |

| ### Public constructors |
|---|
| `@https://docs.oracle.com/javaee/7/api/javax/inject/Inject.html https://developer.android.com/reference/androidx/test/espresso/device/DeviceInteraction#DeviceInteraction(androidx.test.platform.device.DeviceController)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/test/platform/device/DeviceController deviceController)` |

| ### Public methods |
|---|---|
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/test/espresso/device/DeviceInteraction` | `https://developer.android.com/reference/androidx/test/espresso/device/DeviceInteraction#perform(androidx.test.espresso.device.action.DeviceAction)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/test/espresso/device/action/DeviceAction action)` Performs the given action on the test device. |

## Public constructors

### DeviceInteraction

```
@Inject
public DeviceInteraction(@NonNull DeviceController deviceController)
```

## Public methods

### perform

```
public final @NonNull DeviceInteraction perform(@NonNull DeviceAction action)
```

Performs the given action on the test device. This method should not be called on the main thread. The calling thread is blocked until the requested device action is completed.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/test/espresso/device/action/DeviceAction action` | the DeviceAction to execute. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/test/espresso/device/DeviceInteraction` | this interaction for further perform/verification calls. |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` | when being invoked on the main thread. |