Type inference failed: RecyclerViewActions.scrollTo()

One can get easily confused about which VH among many(specially if multiple VHs in a single RecyclerView) to use, you can simply use Generic ViewHolder i.e RecyclerView.ViewHolder like :

RecyclerViewActions.actionOnItem<RecyclerView.ViewHolder>

RecyclerViewActions.actionOnHolderItem<RecyclerView.ViewHolder>

RecyclerViewActions.actionOnItemAtPosition<RecyclerView.ViewHolder>

etc.

I hope this helps.


I needed to add <RecyclerView.ViewHolder> to scrollTo

onView(withId(R.id.recyclerView)).perform(
    RecyclerViewActions.scrollTo<RecyclerView.ViewHolder>(
    hasDescendant(withText(artistResult.nameVariations[0]))))

Tags:

Kotlin