Android Testing UI with Espresso edit

Performing an action on a view

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:

ViewActions.click()
ViewActions.typeText()
ViewActions.clearText()

For example, to click on the view:

onView(...).perform(click());
onView(withId(R.id.button_simple)).perform(click());

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:

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


Table Of Contents
39 ACRA
64 Menu
93 Testing UI with Espresso
112 Loader
119 Xposed
132 Colors
135 Fresco
140 AdMob
147 Button
156 Vk SDK
170 XMPP
176 OpenCV
200 FileIO
203 Moshi
217 Paint
231 AIDL
241 JCodec
243 Okio
255 Looper
  ↑ ↓ to navigate     ↵ to select     Esc to close