Q:

How to press "search button" on softkeyboard emulator in Espresso Test Android Studio

How can I press the "search button" on the soft keyboard emulator in Espresso Test Android Studio? It's on the bottom right. 
screenshot of emulator

A:

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.

