Closed iamthevoid closed 4 years ago
Hi there! You should pass the parent matcher of your RecyclerView's item as an argument of a constructor:
val clickable = KView(parent) {
withId(R.id.clickableView)
}
Did it:
object CatalogItemsScreen : Screen<CatalogItemsScreen>() {
val recycler = KRecyclerView(
builder = { withId(R.id.recyclerView) },
itemTypeBuilder = { itemType(::Item) }
)
class Item(parent: Matcher<View>) : KRecyclerItem<Item>(parent) {
val clickable = KView(parent) { withId(R.id.clickableView) }
}
}
but error the same
@iamthevoid could you try to change object
to class
Tried to use as 'class' same as 'KAbsListView' and got the same result. Seems rly strange to me, because screens without adapters works good.
May different adapter items types provoke this error? If answer is 'yes' - how can I resolve it?
Usually, if you get AmbiguousViewMatcherException
that means there is something wrong with the layout of the screen, not necessarily with Kakao itself. Kakao is a wrapper around Espresso, and to be sure that the issue is coming not from the library, you can reproduce it with direct espresso matching:
onView(allOf(withParent(PositionMatcher(withId(R.id. recyclerView), 1), withId(R.id.clickableView)).perform(click())
Most probable issues that I think might happen: Issues with generated R file (in a multi-module project while merging ids from different modules) You can have multiple fragments on activity with the same contents Incompatible versions of espresso/androidx libraries
Please try to reproduce issue with raw espresso call instead of Kakao call and provide us full stacktrace, as well as your screen layout + item layout files.
Specifying the versions of your dependencies might help too.
Also, just try to click your item with the official Espresso way of doing it:
onView(withId(R.id.recyclerView)).perform(actionOnItemAtPosition(1, object : ViewAction {
override fun perform(controller: UiController, view: View) {
view.findViewById(R.id.clickableView).click()
}
}))
Hey @Unlimity I have the same problem with ViewPager, I have two fragment in viewpager and this fragments have a recyclerview with the same Id
@uziassantosferreira could you create PR with example in the sample app with reproducing the issue? That will probably help us a lot.
@uziassantosferreira right now KViewPager
do not have the api to match exact page (but maybe we will add it somewhere in the future), but you still can match the recycler view with withIndex()
matcher. Basically, if you need the recycler on the second page, you match it with withIndex(1)
and so on.
But keep in mind that withIndex()
matcher is one-time use per instance, so your recycler view matching should be function based, not property based.
Cheers!
Closing this issue due to no activity
Steps to reproduce:
I have object like
and use it like
Observed Results:
at this place I got exception (sorry for full listing, but it need for clearly show the issue)
Message in exception say "MULTIPLE views marked", but i found with simple text search ONLY ONE mark. How can it be?