Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No views in hierarchy found matching: is assignable from class: class android.widget.AdapterView

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

like image 223
MiguelSlv Avatar asked Aug 19 '17 09:08

MiguelSlv


2 Answers

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.

like image 176
Be_Negative Avatar answered Nov 24 '22 12:11

Be_Negative


    val recyclerView = onView(
        allOf(
            withId(R.id.myRecyclerView),
            childAtPosition(
                withClassName(`is`("androidx.constraintlayout.widget.ConstraintLayout")),
                0
            )
        )
    )
    recyclerView.perform(actionOnItemAtPosition<ViewHolder>(1, click()))
like image 22
TheLastBorn Avatar answered Nov 24 '22 13:11

TheLastBorn