Skip to content

Instantly share code, notes, and snippets.

@benjamintanweihao
Last active July 16, 2020 13:38
Show Gist options
  • Save benjamintanweihao/71b178ae94abef597157 to your computer and use it in GitHub Desktop.
Save benjamintanweihao/71b178ae94abef597157 to your computer and use it in GitHub Desktop.
Testing Navigation Drawer in Espresso
// This works!
onView(withId(R.id.drawer)).perform(swipeUp())
// This doesn't.
onView(withId(R.id.drawer))
.perform( actionOnItemAtPosition(5, click()));
onView(allOf(
withText(R.string.settings),
hasSibling(withText(R.string.about)),
isDisplayed()))
.perform(scrollTo(), click());
onData(instanceOf(NavigationMenuItemView.class))
.inAdapterView(anything(View.class))
.atPosition(6)
.check(matches(isDisplayed()));
onData(is(instanceOf(NavigationMenuItemView.class)))
.inAdapterView(withId(R.id.navigation_view))
.atPosition(5)
.check(matches(isDisplayed()))
.perform(ViewActions.click());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment