rafaelc
rafaelc

Reputation: 59274

Espresso - Why is Espresso finding this match ambiguous?

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

Answers (1)

Be_Negative
Be_Negative

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

Related Questions