[英]Espresso RecyclerView inside ViewPager
I am new to Android Espresso library. 我是Android Espresso库的新手。 Trying to test click on
RecyclerView
item inside the ViewPager
. 试图点击
ViewPager
RecyclerView
项目。 I've searched the Internet but found nothing about ViewPager. 我搜索过互联网,但没有发现任何有关ViewPager的信息。 So my question is: how to access
RecyclerView
inside a ViewPager
using Espresso to perform click? 所以我的问题是:如何使用Espresso在
ViewPager
访问RecyclerView
来执行点击?
Let's suppose you want to tap on buttonClick , which is the id of a button inside your RecyclerView. 假设您想要点击buttonClick ,它是RecyclerView中按钮的ID。
I use this code: 我用这个代码:
onView(allOf(withId(R.id.buttonToClick), isCompletelyDisplayed()))
.perform(click());
This gets the view with this id which is currently displayed and performs a click on it. 这将获取当前显示的此id的视图,并对其执行单击。
Hope this helps. 希望这可以帮助。
PS: Also, on espresso-contrib there are RecyclerViewActions
that maybe you can use: actionOnHolderItem
, actionOnItem
and actionOnItemAtPosition
. PS:另外,在espresso-contrib上有您可以使用的
RecyclerViewActions
: actionOnHolderItem
, actionOnItem
和actionOnItemAtPosition
。 You can do something like: 你可以这样做:
onView(withId(R.id.recyclerView))
.perform(RecyclerViewActions.actionOnItemAtPosition(0, click()));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.