Reputation: 141
How can I press the "search button" on the soft keyboard emulator in Espresso Test Android Studio? It's on the bottom right.
Upvotes: 14
Views: 5319
Reputation: 517
android:imeOptions="actionSearch"
;Then use the previous answer:
onView(withId(R.id.search_box)) .perform(pressImeActionButton());
Upvotes: 1
Reputation: 2078
Use the pressImeActionButton()
ViewAction documented here: https://developer.android.com/reference/android/support/test/espresso/action/ViewActions.html#pressImeActionButton()
onView(withId(R.id.search_box))
.perform(pressImeActionButton());
In addition, you can use hasImeAction (int imeAction)
documented here https://developer.android.com/reference/android/support/test/espresso/matcher/ViewMatchers.html#hasImeAction(int) to check whether the expected IME action is displayed.
Upvotes: 27