I am trying to test the absence of the UI view. The view selector is as follows:
public static ViewInteraction onMyTestUi() {
return onView(withId(R.id.m
If you want to check if View
is either not visible or does not exist.
public static ViewAssertion isNotDisplayed() {
return new ViewAssertion() {
@Override
public void check(View view, NoMatchingViewException noView) {
if (view != null && isDisplayed().matches(view)) {
throw new AssertionError("View is present in the hierarchy and Displayed: "
+ HumanReadables.describe(view));
}
}
};
}
Usage:
onView(withId(R.id.someView)).check(isNotDisplayed());