# InteractionRequest.Builder

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

*** ** * ** ***


```
class InteractionRequest.Builder
```

<br />

*** ** * ** ***

Creates an instance of `https://developer.android.com/reference/kotlin/androidx/test/espresso/remote/InteractionRequest` from a View matcher and action.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/test/espresso/remote/InteractionRequest.Builder#Builder()()` Creates a new `https://developer.android.com/reference/kotlin/androidx/test/espresso/remote/InteractionRequest.Builder` instance. |

| ### Public functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/test/espresso/remote/InteractionRequest!` | `https://developer.android.com/reference/kotlin/androidx/test/espresso/remote/InteractionRequest.Builder#build()()` Builds an `https://developer.android.com/reference/kotlin/androidx/test/espresso/remote/InteractionRequest` object. |
| `https://developer.android.com/reference/kotlin/androidx/test/espresso/remote/InteractionRequest.Builder!` | `https://developer.android.com/reference/kotlin/androidx/test/espresso/remote/InteractionRequest.Builder#setRequestProto(byte[])(protoByteArray: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>)` Set the result proto as a byte array. |
| `https://developer.android.com/reference/kotlin/androidx/test/espresso/remote/InteractionRequest.Builder!` | `https://developer.android.com/reference/kotlin/androidx/test/espresso/remote/InteractionRequest.Builder#setRootMatcher(org.hamcrest.Matcher<androidx.test.espresso.Root>)(rootMatcher: https://junit.org/junit4/javadoc/latest/org/hamcrest/Matcher.html<https://developer.android.com/reference/kotlin/androidx/test/espresso/Root!>)` Sets the root matcher for this `https://developer.android.com/reference/kotlin/androidx/test/espresso/remote/InteractionRequest` |
| `https://developer.android.com/reference/kotlin/androidx/test/espresso/remote/InteractionRequest.Builder!` | `https://developer.android.com/reference/kotlin/androidx/test/espresso/remote/InteractionRequest.Builder#setViewAction(androidx.test.espresso.ViewAction)(viewAction: https://developer.android.com/reference/kotlin/androidx/test/espresso/ViewAction)` Sets the `https://developer.android.com/reference/kotlin/androidx/test/espresso/ViewAction` for this `https://developer.android.com/reference/kotlin/androidx/test/espresso/remote/InteractionRequest` |
| `https://developer.android.com/reference/kotlin/androidx/test/espresso/remote/InteractionRequest.Builder!` | `https://developer.android.com/reference/kotlin/androidx/test/espresso/remote/InteractionRequest.Builder#setViewAssertion(androidx.test.espresso.ViewAssertion)(viewAssertion: https://developer.android.com/reference/kotlin/androidx/test/espresso/ViewAssertion)` Sets the `https://developer.android.com/reference/kotlin/androidx/test/espresso/ViewAssertion` for this `https://developer.android.com/reference/kotlin/androidx/test/espresso/remote/InteractionRequest` |
| `https://developer.android.com/reference/kotlin/androidx/test/espresso/remote/InteractionRequest.Builder!` | `https://developer.android.com/reference/kotlin/androidx/test/espresso/remote/InteractionRequest.Builder#setViewMatcher(org.hamcrest.Matcher<android.view.View>)(viewMatcher: https://junit.org/junit4/javadoc/latest/org/hamcrest/Matcher.html<https://developer.android.com/reference/android/view/View.html!>)` Sets the view matcher for this `https://developer.android.com/reference/kotlin/androidx/test/espresso/remote/InteractionRequest` |

## Public constructors

### Builder

```
Builder()
```

Creates a new `https://developer.android.com/reference/kotlin/androidx/test/espresso/remote/InteractionRequest.Builder` instance.

## Public functions

### build

```
fun build(): InteractionRequest!
```

Builds an `https://developer.android.com/reference/kotlin/androidx/test/espresso/remote/InteractionRequest` object.

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/test/espresso/remote/InteractionRequest!` | an `https://developer.android.com/reference/kotlin/androidx/test/espresso/remote/InteractionRequest` object. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | when conflicting properties are set. You can either set a `https://junit.org/junit4/javadoc/latest/org/hamcrest/Matcher.html` and a `https://developer.android.com/reference/kotlin/androidx/test/espresso/ViewAction` or set the proto byte array but not both. Setting all values would result in an override, therefore setting both properties will result in an exception. |
| `https://developer.android.com/reference/kotlin/androidx/test/espresso/remote/RemoteProtocolException` | when the provided proto byte array cannot be parsed into a protocol buffer of type |

### setRequestProto

```
fun setRequestProto(protoByteArray: ByteArray<Byte>): InteractionRequest.Builder!
```

Set the result proto as a byte array. This byte array will be parsed into an . Providing an invalid byte array will result in a `https://developer.android.com/reference/kotlin/androidx/test/espresso/remote/RemoteProtocolException` when the `https://developer.android.com/reference/kotlin/androidx/test/espresso/remote/InteractionRequest.Builder#build()` method is called!

| Parameters |
|---|---|
| `protoByteArray: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>` | the proto byte array to set |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/test/espresso/remote/InteractionRequest.Builder!` | fluent interface `https://developer.android.com/reference/kotlin/androidx/test/espresso/remote/InteractionRequest.Builder` |

### setRootMatcher

```
fun setRootMatcher(rootMatcher: Matcher<Root!>): InteractionRequest.Builder!
```

Sets the root matcher for this `https://developer.android.com/reference/kotlin/androidx/test/espresso/remote/InteractionRequest`

| Parameters |
|---|---|
| `rootMatcher: https://junit.org/junit4/javadoc/latest/org/hamcrest/Matcher.html<https://developer.android.com/reference/kotlin/androidx/test/espresso/Root!>` | the root matcher to set |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/test/espresso/remote/InteractionRequest.Builder!` | fluent interface |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/test/espresso/Root` |   |

### setViewAction

```
fun setViewAction(viewAction: ViewAction): InteractionRequest.Builder!
```

Sets the `https://developer.android.com/reference/kotlin/androidx/test/espresso/ViewAction` for this `https://developer.android.com/reference/kotlin/androidx/test/espresso/remote/InteractionRequest`

| Parameters |
|---|---|
| `viewAction: https://developer.android.com/reference/kotlin/androidx/test/espresso/ViewAction` | the view action to set |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/test/espresso/remote/InteractionRequest.Builder!` | fluent interface |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | if a `https://developer.android.com/reference/kotlin/androidx/test/espresso/ViewAssertion` was already set through `https://developer.android.com/reference/kotlin/androidx/test/espresso/remote/InteractionRequest.Builder#setViewAssertion(androidx.test.espresso.ViewAssertion)` before. `https://developer.android.com/reference/kotlin/androidx/test/espresso/remote/InteractionRequest` supports only one of `https://developer.android.com/reference/kotlin/androidx/test/espresso/ViewAction` or `https://developer.android.com/reference/kotlin/androidx/test/espresso/ViewAssertion`, but not both. |

### setViewAssertion

```
fun setViewAssertion(viewAssertion: ViewAssertion): InteractionRequest.Builder!
```

Sets the `https://developer.android.com/reference/kotlin/androidx/test/espresso/ViewAssertion` for this `https://developer.android.com/reference/kotlin/androidx/test/espresso/remote/InteractionRequest`

| Parameters |
|---|---|
| `viewAssertion: https://developer.android.com/reference/kotlin/androidx/test/espresso/ViewAssertion` | the view action to set |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/test/espresso/remote/InteractionRequest.Builder!` | fluent interface |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | if a `https://developer.android.com/reference/kotlin/androidx/test/espresso/ViewAction` was already set through `https://developer.android.com/reference/kotlin/androidx/test/espresso/remote/InteractionRequest.Builder#setViewAction(androidx.test.espresso.ViewAction)` before. `https://developer.android.com/reference/kotlin/androidx/test/espresso/remote/InteractionRequest` supports only one of `https://developer.android.com/reference/kotlin/androidx/test/espresso/ViewAction` or `https://developer.android.com/reference/kotlin/androidx/test/espresso/ViewAssertion`, but not both. |

### setViewMatcher

```
fun setViewMatcher(viewMatcher: Matcher<View!>): InteractionRequest.Builder!
```

Sets the view matcher for this `https://developer.android.com/reference/kotlin/androidx/test/espresso/remote/InteractionRequest`

| Parameters |
|---|---|
| `viewMatcher: https://junit.org/junit4/javadoc/latest/org/hamcrest/Matcher.html<https://developer.android.com/reference/android/view/View.html!>` | the view matcher to set |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/test/espresso/remote/InteractionRequest.Builder!` | fluent interface |