# InteractionRequest.Builder

Summary:[Ctors](https://developer.android.com/reference/android/support/test/espresso/remote/InteractionRequest.Builder#pubctors)\|[Methods](https://developer.android.com/reference/android/support/test/espresso/remote/InteractionRequest.Builder#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/support/test/espresso/remote/InteractionRequest.Builder#inhmethods)\|[\[Expand All\]](https://developer.android.com/reference/android/support/test/espresso/remote/InteractionRequest.Builder#)  

# InteractionRequest.Builder

| This package is part of the Android[support library](https://developer.android.com/topic/libraries/support-library)which is no longer maintained. The support library has been superseded by[AndroidX](https://developer.android.com/jetpack/androidx)which is part of[Jetpack](https://developer.android.com/jetpack). We recommend using the AndroidX libraries in all new projects. You should also consider[migrating](https://developer.android.com/jetpack/androidx/migrate)existing projects to AndroidX. To find the AndroidX class that maps to this deprecated class, see the AndroidX support library[class mappings](https://developer.android.com/jetpack/androidx/migrate/class-mappings).

`
public
static


class
InteractionRequest.Builder
`  
`

extends `[Object](https://developer.android.com/reference/java/lang/Object.html)`


``


`

|---|-----------------------------------------------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object.html) ||
| ↳ | android.support.test.espresso.remote.InteractionRequest.Builder |

<br />

*** ** * ** ***

Creates an instance of[InteractionRequest](https://developer.android.com/reference/android/support/test/espresso/remote/InteractionRequest)from a View matcher and action.

## Summary

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

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

| ### Inherited methods |
|-----------------------|---|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/test/espresso/remote/InteractionRequest.Builder#)From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object.html)` ` |-------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object.html)          | ` clone() `                                                                                | | ` boolean`                                                                          | ` equals(`[Object](https://developer.android.com/reference/java/lang/Object.html)` arg0) ` | | ` void`                                                                             | ` finalize() `                                                                             | | ` final `[Class](https://developer.android.com/reference/java/lang/Class.html)`<?>` | ` getClass() `                                                                             | | ` int`                                                                              | ` hashCode() `                                                                             | | ` final void`                                                                       | ` notify() `                                                                               | | ` final void`                                                                       | ` notifyAll() `                                                                            | | ` `[String](https://developer.android.com/reference/java/lang/String.html)          | ` toString() `                                                                             | | ` final void`                                                                       | ` wait(long arg0, int arg1) `                                                              | | ` final void`                                                                       | ` wait(long arg0) `                                                                        | | ` final void`                                                                       | ` wait() `                                                                                 | ||

## Public constructors

### InteractionRequest.Builder

```
InteractionRequest.Builder ()
```

Creates a new[InteractionRequest.Builder](https://developer.android.com/reference/android/support/test/espresso/remote/InteractionRequest.Builder)instance.

<br />

## Public methods

### build

```
InteractionRequest build ()
```

Builds an[InteractionRequest](https://developer.android.com/reference/android/support/test/espresso/remote/InteractionRequest)object.

<br />

|                                                                                                                           Returns                                                                                                                            ||
|-----------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------|
| [InteractionRequest](https://developer.android.com/reference/android/support/test/espresso/remote/InteractionRequest) | an[InteractionRequest](https://developer.android.com/reference/android/support/test/espresso/remote/InteractionRequest)object. <br /> |

|                                                                                                                                                                                                                                                 Throws                                                                                                                                                                                                                                                 ||
|---------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException.html)                           | when conflicting properties are set. You can either set a[ERROR(/Matcher)](https://developer.android.com/)and a[ViewAction](https://developer.android.com/reference/android/support/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. |
| [RemoteProtocolException](https://developer.android.com/reference/android/support/test/espresso/remote/RemoteProtocolException) | when the provided proto byte array cannot be parsed into a protocol buffer of type[UiInteraction.InteractionRequestProto](https://developer.android.com/reference/android/support/test/espresso/proto/UiInteraction.InteractionRequestProto)                                                                                                                          |

### setRequestProto

```
InteractionRequest.Builder setRequestProto (byte[] protoByteArray)
```

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

<br />

|                          Parameters                          ||
|------------------|--------------------------------------------|
| `protoByteArray` | `byte`: the proto byte array to set <br /> |

|                                                                                                                                               Returns                                                                                                                                               ||
|---------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [InteractionRequest.Builder](https://developer.android.com/reference/android/support/test/espresso/remote/InteractionRequest.Builder) | fluent interface[InteractionRequest.Builder](https://developer.android.com/reference/android/support/test/espresso/remote/InteractionRequest.Builder) <br /> |

### setRootMatcher

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

Sets the root matcher for this[InteractionRequest](https://developer.android.com/reference/android/support/test/espresso/remote/InteractionRequest)

<br />

|                        Parameters                        ||
|---------------|-------------------------------------------|
| `rootMatcher` | `Matcher`: the root matcher to set <br /> |

|                                                                            Returns                                                                             ||
|---------------------------------------------------------------------------------------------------------------------------------------|-------------------------|
| [InteractionRequest.Builder](https://developer.android.com/reference/android/support/test/espresso/remote/InteractionRequest.Builder) | fluent interface <br /> |

**See also:**

- [Root](https://developer.android.com/reference/android/support/test/espresso/Root)  

### setViewAction

```
InteractionRequest.Builder setViewAction (ViewAction viewAction)
```

Sets the[ViewAction](https://developer.android.com/reference/android/support/test/espresso/ViewAction)for this[InteractionRequest](https://developer.android.com/reference/android/support/test/espresso/remote/InteractionRequest)

<br />

|                        Parameters                         ||
|--------------|---------------------------------------------|
| `viewAction` | `ViewAction`: the view action to set <br /> |

|                                                                            Returns                                                                             ||
|---------------------------------------------------------------------------------------------------------------------------------------|-------------------------|
| [InteractionRequest.Builder](https://developer.android.com/reference/android/support/test/espresso/remote/InteractionRequest.Builder) | fluent interface <br /> |

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

### setViewAssertion

```
InteractionRequest.Builder setViewAssertion (ViewAssertion viewAssertion)
```

Sets the[ViewAssertion](https://developer.android.com/reference/android/support/test/espresso/ViewAssertion)for this[InteractionRequest](https://developer.android.com/reference/android/support/test/espresso/remote/InteractionRequest)

<br />

|                           Parameters                            ||
|-----------------|------------------------------------------------|
| `viewAssertion` | `ViewAssertion`: the view action to set <br /> |

|                                                                            Returns                                                                             ||
|---------------------------------------------------------------------------------------------------------------------------------------|-------------------------|
| [InteractionRequest.Builder](https://developer.android.com/reference/android/support/test/espresso/remote/InteractionRequest.Builder) | fluent interface <br /> |

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

### setViewMatcher

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

Sets the view matcher for this[InteractionRequest](https://developer.android.com/reference/android/support/test/espresso/remote/InteractionRequest)

<br />

|                        Parameters                        ||
|---------------|-------------------------------------------|
| `viewMatcher` | `Matcher`: the view matcher to set <br /> |

|                                                                            Returns                                                                             ||
|---------------------------------------------------------------------------------------------------------------------------------------|-------------------------|
| [InteractionRequest.Builder](https://developer.android.com/reference/android/support/test/espresso/remote/InteractionRequest.Builder) | fluent interface <br /> |

-

  ## Interfaces

  - [Bindable](https://developer.android.com/reference/android/support/test/espresso/remote/Bindable)
  - [Converter](https://developer.android.com/reference/android/support/test/espresso/remote/Converter)
  - [EspressoRemoteMessage](https://developer.android.com/reference/android/support/test/espresso/remote/EspressoRemoteMessage)
  - [EspressoRemoteMessage.From](https://developer.android.com/reference/android/support/test/espresso/remote/EspressoRemoteMessage.From)
  - [EspressoRemoteMessage.To](https://developer.android.com/reference/android/support/test/espresso/remote/EspressoRemoteMessage.To)
  - [RemoteInteraction](https://developer.android.com/reference/android/support/test/espresso/remote/RemoteInteraction)
-

  ## Classes

  - [ConstructorInvocation](https://developer.android.com/reference/android/support/test/espresso/remote/ConstructorInvocation)
  - [EspressoRemote](https://developer.android.com/reference/android/support/test/espresso/remote/EspressoRemote)
  - [FieldDescriptor](https://developer.android.com/reference/android/support/test/espresso/remote/FieldDescriptor)
  - [GenericRemoteMessage](https://developer.android.com/reference/android/support/test/espresso/remote/GenericRemoteMessage)
  - [InteractionRequest](https://developer.android.com/reference/android/support/test/espresso/remote/InteractionRequest)
  - [InteractionRequest.Builder](https://developer.android.com/reference/android/support/test/espresso/remote/InteractionRequest.Builder)
  - [InteractionResponse](https://developer.android.com/reference/android/support/test/espresso/remote/InteractionResponse)
  - [InteractionResponse.Builder](https://developer.android.com/reference/android/support/test/espresso/remote/InteractionResponse.Builder)
  - [InteractionResponse.RemoteError](https://developer.android.com/reference/android/support/test/espresso/remote/InteractionResponse.RemoteError)
  - [NoopRemoteInteraction](https://developer.android.com/reference/android/support/test/espresso/remote/NoopRemoteInteraction)
  - [ProtoUtils](https://developer.android.com/reference/android/support/test/espresso/remote/ProtoUtils)
  - [RemoteDescriptor](https://developer.android.com/reference/android/support/test/espresso/remote/RemoteDescriptor)
  - [RemoteDescriptor.Builder](https://developer.android.com/reference/android/support/test/espresso/remote/RemoteDescriptor.Builder)
  - [RemoteDescriptorRegistry](https://developer.android.com/reference/android/support/test/espresso/remote/RemoteDescriptorRegistry)
  - [RemoteInteractionRegistry](https://developer.android.com/reference/android/support/test/espresso/remote/RemoteInteractionRegistry)
  - [TypeProtoConverters](https://developer.android.com/reference/android/support/test/espresso/remote/TypeProtoConverters)
-

  ## Enums

  - [InteractionResponse.Status](https://developer.android.com/reference/android/support/test/espresso/remote/InteractionResponse.Status)
-

  ## Exceptions

  - [NoRemoteEspressoInstanceException](https://developer.android.com/reference/android/support/test/espresso/remote/NoRemoteEspressoInstanceException)
  - [RemoteEspressoException](https://developer.android.com/reference/android/support/test/espresso/remote/RemoteEspressoException)
  - [RemoteProtocolException](https://developer.android.com/reference/android/support/test/espresso/remote/RemoteProtocolException)