我正在尝试使用一个函数来随时检查 Activity 图形元素的一致性。我发现当进度对话框显示 Espresso 时,无法在下方找到任何 View 。有什么办法可以看到下面的景色吗?
最佳答案
是的,您使用 RootMatcher .例如:
// Specifically target the main window view hierarchy
onView(withId(R.id.view_to_match))
.inRoot(withDecorView(is(getActivity().getWindow().getDecorView())))
.perform(click());
或者也许:
// Specifically disregard the dialog window view hierarchy
onView(withId(R.id.view_to_match))
.inRoot(not(isDialog()))
.perform(click());
参见 the official documentation举个例子。
希望对您有所帮助!
关于android - 可以使用 Espresso 在进度对话框下方测试 View 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46383142/