richersoon
richersoon

Reputation: 4902

Espresso 2.2.1 - Check if fragment layout is displayed

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

Answers (1)

craya
craya

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

Related Questions