如何在Espresso Test Android Studio中的软键盘模拟器上按"search button"



如何在Espresso Test Android Studio中按下软键盘模拟器上的"搜索按钮"?它在右下角。

模拟器的屏幕截图

使用此处记录的pressImeActionButton() ViewAction:https://developer.android.com/reference/android/support/test/espresso/action/ViewActions.html#pressImeActionButton((

onView(withId(R.id.search_box))
    .perform(pressImeActionButton());

此外,您可以使用此处记录的hasImeAction (int imeAction)https://developer.android.com/reference/android/support/test/espresso/matcher/ViewMatchers.html#hasImeAction(int(检查是否显示了预期的IME操作。

  1. 在EditText android:imeOptions="actionSearch"的布局文件集属性中
  2. 然后使用前面的答案:

    onView(带id(R.id.search_box((执行(按ImeActionButton(((;

最新更新