【发布时间】:2019-01-09 19:22:14
【问题描述】:
我有弹出通知。我的第一个测试检查该通知是否显示并成功通过。我在这个测试中使用了下一个方法:
fun viewInNotificationPopupIsDisplayed(viewMatcher: Matcher<View>) {
onView(viewMatcher)
.inRoot(RootMatchers.isPlatformPopup())
.check(ViewAssertions.matches(isDisplayed()))
}
第二个测试用例有问题,我必须检查我的弹出通知是否已经消失(意味着它不再显示)。 所以我正在尝试使用下一个方法:
fun viewInNotificationPopupIsNotDisplayed(viewMatcher: Matcher<View>) {
Espresso.onView(viewMatcher)
.inRoot(RootMatchers.isPlatformPopup())
.check(matches(not(isDisplayed())))
//.check(ViewAssertions.doesNotExist()) // doesn't work as well
}
我得到下一个异常:
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,
请问有人可以帮忙吗?
【问题讨论】:
-
你找到答案了吗?我有同样的问题
标签: android kotlin android-espresso