Reputation: 4902
How can I check if fragment is displayed in espresso? Can I use layout id in withId?
onView(withId(R.layout.foo_fragment)).check(matches(isDisplayed()));
I get a no views in hierarchy exception.
Upvotes: 1
Views: 4794
Reputation: 653
R.layout.foo_fragment is not the ID of the root of your fragment; that's the layout ID for inflation. You should set an ID on the root of your fragment, then do onView(withId(R.id.fragmentIDname)).check(matches(isDisplayed()));
Upvotes: 6