Skip to content

Most visited

Recently visited

navigation

ViewInteraction

public final class ViewInteraction
extends Object

java.lang.Object
   ↳ android.support.test.espresso.ViewInteraction


Provides the primary interface for test authors to perform actions or asserts on views.

Each interaction is associated with a view identified by a view matcher. All view actions and asserts are performed on the UI thread (thus ensuring sequential execution). The same goes for retrieval of views (this is done to ensure that view state is "fresh" prior to execution of each operation).

Summary

Public methods

ViewInteraction check(ViewAssertion viewAssert)

Checks the given ViewAssertion on the the view selected by the current view matcher.

ViewInteraction inRoot(Matcher<Root> rootMatcher)

Makes this ViewInteraction scoped to the root selected by the given root matcher.

ViewInteraction perform(ViewAction... viewActions)

Performs the given action(s) on the view selected by the current view matcher.

ViewInteraction withFailureHandler(FailureHandler failureHandler)

Replaces the default failure handler (@see Espresso.setFailureHandler) with a custom failurehandler for this particular interaction.

Inherited methods

From class java.lang.Object

Public methods

check

ViewInteraction check (ViewAssertion viewAssert)

Checks the given ViewAssertion on the the view selected by the current view matcher.

Parameters
viewAssert ViewAssertion: the assertion to check.
Returns
ViewInteraction this interaction for further perform/verification calls.

inRoot

ViewInteraction inRoot (Matcher<Root> rootMatcher)

Makes this ViewInteraction scoped to the root selected by the given root matcher.

Parameters
rootMatcher Matcher
Returns
ViewInteraction

perform

ViewInteraction perform (ViewAction... viewActions)

Performs the given action(s) on the view selected by the current view matcher. If more than one action is provided, actions are executed in the order provided with precondition checks running prior to each action.

Parameters
viewActions ViewAction: one or more actions to execute.
Returns
ViewInteraction this interaction for further perform/verification calls.

withFailureHandler

ViewInteraction withFailureHandler (FailureHandler failureHandler)

Replaces the default failure handler (@see Espresso.setFailureHandler) with a custom failurehandler for this particular interaction.

Parameters
failureHandler FailureHandler: a non-null failurehandler to use to report failures.
Returns
ViewInteraction this interaction for further perform/verification calls.
This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields

Hooray!

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a one-minute survey?
Help us improve Android tools and documentation.