我有方法,我点击我的 recyclerView 的位置:
Espresso.onView(ViewMatchers.withId(R.id.recyclerView))
.perform(RecyclerViewActions.actionOnItemAtPosition<CurrencySelectorItemHolder>(1, ViewActions.click()))
但我如何才能检查文本的位置呢?
最佳答案
将“whatever”更改为您想要的文本:
Espresso.onView(withId(R.id.recyclerView))
.perform(RecyclerViewActions.actionOnItem(
hasDescendant(withText("whatever")), click()));
更新:此代码用于按位置检查文本:
onView(withRecyclerView(R.id.recyclerView).atPosition(3))
.check(matches(hasDescendant(withText("whatever"))));
public static RecyclerViewMatcher withRecyclerView(final int recyclerViewId) {
return new RecyclerViewMatcher(recyclerViewId);
}
关于android - 检查回收站中位置的文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42161149/