我在垂直RecyclerView
内有一个水平onView(allOf(isDescendantOfA(withRecyclerView(R.id.parentVerticalRecyclerView).atPosition(parentPosition)),
isDescendantOfA(withRecyclerView(R.id.childHorizontalRecyclerView).atPosition(childPosition)),
(withText("USA"))))
.perform(click());
// It is not working for parentPosition > 0
。我正在使用我在其他问题上找到的代码:
RecyclerView
但这仅适用于父RecyclerView
的第一行。
如何点击第二行父.htaccess
的子RecyclerView上的元素?
答案 0 :(得分:4)
我终于找到了解决方案:
onView(allOf(
withId(R.id.childHorizontalRecyclerView),
withParent(
withRecyclerView(R.id.parentVerticalRecyclerView).atPosition(2)
)
)
).perform(RecyclerViewActions.actionOnItemAtPosition(3, scrollTo()))
.check(matches(hasDescendant(withText("USA"))));