RecyclerViewActions returns NoMatchingViewException in Espresso Android Testing

假如想象 提交于 2019-12-24 07:24:11

问题


I'm using this line of code to perform a click on RecyclerView's list at position 0.

onView(withId(R.id.rv)).perform(RecyclerViewActions.actionOnItemAtPosition(0, click()));

But it's not working and returns NoMatchingViewException.

But, when I perform a click operation on TextView (which is inside the RecyclerView layout), it's working and testing is passing, as shown in the line of code below,

    onView(allOf(result(withId(R.id.tv), 0), isDisplayed())).perform(click());

Am I using the RecyclerViewActions correctly, and how do I resolve the issue?

来源:https://stackoverflow.com/questions/50852995/recyclerviewactions-returns-nomatchingviewexception-in-espresso-android-testing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!