I can't make ViewActions.closeSoftKeyboard() work in Espresso 2.2.2

ViewAction on its own does not do anything unless it is used in the ViewInteraction. That means that you need to either chain it with your previous action in perform() like this: onView()..perform(typeText(..), closeSoftKeyboard()) or use a built-in helper which is in Espresso class like this: Espresso.closeSoftKeyboard()


You can implement this:

fun hideKeyboard() {
    onView(ViewMatchers.isRoot()).perform(ViewActions.closeSoftKeyboard())
  }

After that only use this: paymentMethodPage.hideKeyboard()