I have popup notification. My first test checks if that notification is displayed and it passes succesfully. I use next method for this test:
fun viewInNotificationPopupIsDisplayed(viewMatcher: Matcher<View>) {
onView(viewMatcher)
.inRoot(RootMatchers.isPlatformPopup())
.check(ViewAssertions.matches(isDisplayed()))
}
I have a problem with second test case where i have to check that my popup notification has already gone (means it's not displayed anymore). So i'm trying to use next method:
fun viewInNotificationPopupIsNotDisplayed(viewMatcher: Matcher<View>) {
Espresso.onView(viewMatcher)
.inRoot(RootMatchers.isPlatformPopup())
.check(matches(not(isDisplayed())))
//.check(ViewAssertions.doesNotExist()) // doesn't work as well
}
I get next exception:
android.support.test.espresso.NoMatchingRootException:
Matcher 'with decor view of type PopupWindow$PopupViewContainer'
did not match any of the following roots:
[Root{application-window-token=android.view.ViewRootImpl$W@bb8371e,
window-token=android.view.ViewRootImpl$W@bb8371e, has-window-focus=true,
Please, can anybody help with this?