Skip to content

Instantly share code, notes, and snippets.

@quentin7b
Last active May 21, 2021 11:16
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save quentin7b/9c5669fd940865cf2e89 to your computer and use it in GitHub Desktop.
Save quentin7b/9c5669fd940865cf2e89 to your computer and use it in GitHub Desktop.
Espresso recycler view item button click
onView(withId(R.id.recycler_view_id))
.perform(
RecyclerViewActions.actionOnItemAtPosition(
itemPosition,
new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return null;
}
@Override
public String getDescription() {
return "Click on specific button";
}
@Override
public void perform(UiController uiController, View view) {
View button = view.findViewById(R.id.button_id);
// Maybe check for null
button.performClick();
}
})
);
@silascaxias
Copy link

Thanks!

@Kochenkov
Copy link

nice, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment