android – 检查回收器中位置的文本
作者:互联网
我有方法,我点击我的recyclerView的位置:
Espresso.onView(ViewMatchers.withId(R.id.recyclerView))
.perform(RecyclerViewActions.actionOnItemAtPosition<CurrencySelectorItemHolder>(1, ViewActions.click()))
但我怎么能检查我的文字的位置呢?
解决方法:
将“what”更改为您想要的文本:
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,android-recyclerview,android-espresso,espresso 来源: https://codeday.me/bug/20190522/1154538.html