KakaoCup / Kakao

Nice and simple DSL for Espresso in Kotlin
https://kakaocup.github.io/Kakao/
Apache License 2.0
325 stars 28 forks source link

KRecyclerView built using IndexMatcher could not match children. #75

Open jermainedilao opened 1 year ago

jermainedilao commented 1 year ago

Steps to reproduce:

  1. I have a TabLayout with 2 tabs. Both contain RecyclerView with the same id.
  2. I match the RecyclerView in the second tab using withIndex(1) { withId(R.id.recyclerView) }
  3. Now if I try to do any child matching with the RecyclerView inside second tab, it fails. (childAt, childWith, etc).

Observed Results:

androidx.test.espresso.NoMatchingViewException: No views in hierarchy found matching: view holder at 0 position of recycler view: (1th view with: (view.getId() is <2131363464/com.package.name.debug:id/recyclerView>))

Expected Results:

I am expecting it to match the children of the RecyclerView inside the second tab.

Note that matching child items of the RecyclerView inside the first tab (withIndex(0)) works properly.

Relevant Code:

This is how I match my RecyclerViews.

// First tab RecyclerView
KRecyclerView(
    builder = {
        withIndex(0) {
            withId(R.id.recyclerView)
        }
    },
    itemTypeBuilder = {
        itemType(::Item)
    }
)

// Second tab RecyclerView
KRecyclerView(
    builder = {
        withIndex(1) {
            withId(R.id.recyclerView)
        }
    },
    itemTypeBuilder = {
        itemType(::Item)
    }
)

// Item
private class Item(parent: Matcher<View>) : KRecyclerItem<Item>(parent) {
        val moreOptionsIcon = KImageView(parent) { withId(R.id.moreIcon) }
}

Is there something wrong with how it is set up? Please help.

Vacxe commented 1 year ago

@jermainedilao could you create a Pull Request to reproduce your issue. By sample provided by you - it looks definitely incorrect. For issues like that I can suggest you use support chat in Telegram. Link can be found in repo README