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
Espresso Test Recorder is a new feature released in Android Studio 2.2 Preview 3 that makes it easy to generate automated UI tests by recording your own interactions on a device so you don't have to actually write any test code.
Espresso created by Google is a native framework for Android automated testing. The tool is a part of the Android SDK and is easy to use for native mobile development. Thanks to Espresso, you can create tests that are close to the Android app's logic.
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.
android:imeOptions="actionSearch"
;Then use the previous answer:
onView(withId(R.id.search_box)) .perform(pressImeActionButton());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With