Reputation: 59274
I have an ExpandableListView
and I would like to click()
one of its childs.
I have tried LOADS OF different ways but I just can't seem to understand how Espresso works.
For instance, why does this code do not work?
onData(withId(R.id.execexpList)).onChildView(is(withId(200))).perform(click())
For some divine reason, it returns "ambiguous match" to my ExpandableLIstView and other ListView of mine, but they have DIFFERENT ids.
Can anyone help me out?
Upvotes: 2
Views: 462
Reputation: 4972
onData()
is used to match an item inside the adapter of your ListView, not the actual view.
onChildView()
is used to match a descendant of the ListView item that is matched in onData()
.
If you have multiple AdapterViews in hierarchy you have to use inAdapterView(Matcher<View>viewMatcher)
instead.
Official API guide explains onData()
usage in more details.
Upvotes: 1