The action bar view has an identifier, but it does not appear. We can get it with getIdentifier:
Resources resources = getInstrumentation().getTargetContext().getResources();
int actionBarId = resources.getIdentifier("action_bar_container", "id", "android");
onView(withId(actionBarId)).check(matches(isDisplayed()));
Code adapted from this related answer . I think this will work, but I have not tested it.
source
share