# 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)

*** ** * ** ***


```
public class InteractionRequest.Builder
```

<br />

*** ** * ** ***

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

## Summary

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

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

## Public constructors

### Builder

```
public Builder()
```

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

## Public methods

### build

```
public InteractionRequest build()
```

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

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/test/espresso/remote/InteractionRequest` | an `https://developer.android.com/reference/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/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/androidx/test/espresso/remote/RemoteProtocolException` | when the provided proto byte array cannot be parsed into a protocol buffer of type |

### setRequestProto

```
public InteractionRequest.Builder setRequestProto(@NonNull byte[] protoByteArray)
```

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/androidx/test/espresso/remote/RemoteProtocolException` when the `https://developer.android.com/reference/androidx/test/espresso/remote/InteractionRequest.Builder#build()` method is called!

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull byte[] protoByteArray` | the proto byte array to set |

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

### setRootMatcher

```
public InteractionRequest.Builder setRootMatcher(@NonNull Matcher<Root> rootMatcher)
```

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

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

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

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

### setViewAction

```
public InteractionRequest.Builder setViewAction(@NonNull ViewAction viewAction)
```

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

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

| Returns |
|---|---|
| `https://developer.android.com/reference/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/androidx/test/espresso/ViewAssertion` was already set through `https://developer.android.com/reference/androidx/test/espresso/remote/InteractionRequest.Builder#setViewAssertion(androidx.test.espresso.ViewAssertion)` before. `https://developer.android.com/reference/androidx/test/espresso/remote/InteractionRequest` supports only one of `https://developer.android.com/reference/androidx/test/espresso/ViewAction` or `https://developer.android.com/reference/androidx/test/espresso/ViewAssertion`, but not both. |

### setViewAssertion

```
public InteractionRequest.Builder setViewAssertion(@NonNull ViewAssertion viewAssertion)
```

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

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

| Returns |
|---|---|
| `https://developer.android.com/reference/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/androidx/test/espresso/ViewAction` was already set through `https://developer.android.com/reference/androidx/test/espresso/remote/InteractionRequest.Builder#setViewAction(androidx.test.espresso.ViewAction)` before. `https://developer.android.com/reference/androidx/test/espresso/remote/InteractionRequest` supports only one of `https://developer.android.com/reference/androidx/test/espresso/ViewAction` or `https://developer.android.com/reference/androidx/test/espresso/ViewAssertion`, but not both. |

### setViewMatcher

```
public InteractionRequest.Builder setViewMatcher(@NonNull Matcher<View> viewMatcher)
```

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

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

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