我有一个listView包含另一个listView包含图像
需要点击第一张图片
我写了这个语句:
onData(withRegistrationNo(registrationNo))
.inAdapterView(allOf(withId(R.id.parent_listview), isDisplayed()))
.onChildView(withId(R.id.imageView))
.inAdapterView(allOf(withId(R.id.child_listview),isDisplayed()))
.atPosition(0).perform(longClick());
但是出现这个错误:在视图(id: com.package)上执行"加载适配器数据"时出错。App:id/child_listview并在屏幕上显示给用户)'
怎么了? ?
试试这个:
onData(anything())
.inAdapterView(allOf(withId(R.id.child_listview), isDisplayed(),
isDescendantOfA(allOf(withId(R.id.parent_listview), isDisplayed()))))
.atPosition(0).perform(longClick());
如果您只想检查文本:
onView(所有(withId (R.id.yourInnerListViewId) isDescendantOfA(所有(withId (R.id.yourOuterListViewId) withText (" xyz ")))支票(匹配(isDisplayed ())))),
如果你想执行操作:
onView(allOf(withId(R.id.yourInnerListViewId),isDescendantOfA(allOf(withId(R.id.yourOuterListViewId),withText("xyz"))).perform(click())));