Test if soft keyboard is visible using espresso

前端 未结 4 1517
野的像风
野的像风 2021-02-19 02:08

I want to test keyboard visibility when an activity calls onCreate() and onResume().

How can i test whether or not the keyboard is shown using espresso?

4条回答
  •  無奈伤痛
    2021-02-19 02:34

    fun isKeyboardShown(): Boolean {
        val inputMethodManager = InstrumentationRegistry.getInstrumentation().targetContext.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
        return inputMethodManager.isAcceptingText
    }
    

    found at Google groups

提交回复
热议问题