Issue
I am using espresso-contrib to perform actions on a RecyclerView
, and it works as it should, ex:
//click on first item
onView(withId(R.id.recycler_view))
.perform(RecyclerViewActions.actionOnItemAtPosition(0, click()));
and I need to perform assertions on it. Something like this:
onView(withId(R.id.recycler_view))
.perform(
RecyclerViewActions.actionOnItemAtPosition(
0, check(matches(withText("Test Text")))
)
);
but, because RecyclerViewActions is, of course, expecting an action, it says wrong 2nd argument type. There's no RecyclerViewAssertions
on espresso-contrib.
Is there any way to perform assertions on a RecyclerView
?
Solution
You should check out Danny Roa's solution Custom RecyclerView Actions And use it like this:
onView(withRecyclerView(R.id.recycler_view)
.atPositionOnView(1, R.id.ofElementYouWantToCheck))
.check(matches(withText("Test text")));
Answered By - HowieH
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.