Check if a dialog is displayed with Espresso

后端 未结 6 601
孤街浪徒
孤街浪徒 2020-12-04 14:07

I\'m trying to write some tests with the new android-test-kit (Espresso). But I can\'t find any information on how to check if a dialog is displayed and per

6条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-04 14:42

    I currently use this and it seems to work fine.

    onView(withText(R.string.my_title))
        .inRoot(isDialog()) // <---
        .check(matches(isDisplayed()));
    

提交回复
热议问题