Performing an action on a view

suggest change

It is possible to perform ViewActions on a view using the perform method.

The ViewActions class provides helper methods for the most common actions, like:

For example, to click on the view:


You can execute more than one action with one perform call:

onView(...).perform(typeText("Hello"), click());

If the view you are working with is located inside a ScrollView (vertical or horizontal), consider preceding actions that require the view to be displayed (like click() and typeText()) with scrollTo(). This ensures that the view is displayed before proceeding to the other action:

onView(...).perform(scrollTo(), click());

Feedback about page:

Optional: your email if you want me to get back to you:

Table Of Contents