I am using espresso-contrib to perform actions on a RecyclerView, and it works as it should, ex:
onView(withId(R.id.recycler_view))
.perform(Rec
Modified matcher solution for when you check if your item(Text in TextView) is first in RecyclerView.
// True if first item in the RV and input text
fun customMatcherForFirstItem(name: String, matcher: Matcher): Matcher {
return object: BaseMatcher () {
var isFirst = true
override fun matches(item: Any): Boolean {
if (isFirst && (item as TextView).text == name) {
isFirst = false
return true
}
return false
}
override fun describeTo(description: Description?) {}
}
}
Usage: (returns true if child textview in the item has the same text as we expect/search)
onView(withText("TEXT_VIEW_TEXT")).check(matches(
customMatcherForFirstItem("TEXT_VIEW_TEXT", withParent(withId(R.id.recycler_view)))))
Based on -> https://proandroiddev.com/working-with-recycler-views-in-espresso-tests-6da21495182c