Im trying to do a Espresso test for checking if actionbar is hidden/shown, but I cant seem to figure out how to match it with Espresso.onView(...). Afaik it doesnt have a id, right?
Thanks a lot
Im trying to do a Espresso test for checking if actionbar is hidden/shown, but I cant seem to figure out how to match it with Espresso.onView(...). Afaik it doesnt have a id, right?
Thanks a lot
The action bar view has an ID but it's not exposed. 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 haven't tested it.