I am trying to get the recycle view using onData but i am stuck in this error:
No views in hierarchy found matching: is assignable from class: class android.widget.AdapterView
The code is just this:
onData(allOf(isAssignableFrom(RecyclerView.class), withId(R.id.ce_musers_list)))
.check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)));
My adaptor extends RecyclerView.Adapter
as it should for a RecycleView, yet, seams the matcher is looking for a simple Adapter.
This is my first time with espress, so i may be failing in something basic.
My Espresso version is 3.0.0
onData()
is used only with the AdapterView
and its subclasses, which RecyclerView does not belong to.
There is a helper class that espresso comes with: RecyclerViewActions that can be used to perform various actions on a recyclerview and itemviews of the viewholders.
For instance, if you want to make an assertion - you can scroll to the itemview and then use regular onView()...
to check particulars of that viewholder.
val recyclerView = onView(
allOf(
withId(R.id.myRecyclerView),
childAtPosition(
withClassName(`is`("androidx.constraintlayout.widget.ConstraintLayout")),
0
)
)
)
recyclerView.perform(actionOnItemAtPosition<ViewHolder>(1, click()))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With