Issue
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?
Solution
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.
Answered By - Be_Negative
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.