Espresso - 为什么 Espresso 发现这个匹配项不明确?
Espresso - Why is Espresso finding this match ambiguous?
我有一个 ExpandableListView
我想 click()
它的一个孩子。
我尝试了 LOADS OF 不同的方法,但我似乎无法理解 Espresso 的工作原理。
例如,为什么这段代码不起作用?
onData(withId(R.id.execexpList)).onChildView(is(withId(200))).perform(click())
出于某种神圣的原因,它 returns "ambiguous match" 到我的 ExpandableLIstView 和我的其他 ListView,但它们有不同的 ID。
谁能帮帮我?
onData()
用于匹配 ListView 适配器内的项目,而不是实际视图。
onChildView()
用于匹配在 onData()
.
中匹配的 ListView 项的后代
如果层次结构中有多个 AdapterView,则必须改用 inAdapterView(Matcher<View>viewMatcher)
。
官方 API guide 更详细地解释了 onData()
用法。
我有一个 ExpandableListView
我想 click()
它的一个孩子。
我尝试了 LOADS OF 不同的方法,但我似乎无法理解 Espresso 的工作原理。
例如,为什么这段代码不起作用?
onData(withId(R.id.execexpList)).onChildView(is(withId(200))).perform(click())
出于某种神圣的原因,它 returns "ambiguous match" 到我的 ExpandableLIstView 和我的其他 ListView,但它们有不同的 ID。
谁能帮帮我?
onData()
用于匹配 ListView 适配器内的项目,而不是实际视图。
onChildView()
用于匹配在 onData()
.
如果层次结构中有多个 AdapterView,则必须改用 inAdapterView(Matcher<View>viewMatcher)
。
官方 API guide 更详细地解释了 onData()
用法。