【发布时间】:2016-04-27 14:46:39
【问题描述】:
我想为我的 Android 应用创建 Espresso 测试。我有一个 StaggeredGridView (StaggeredGridView Github ) 有很多由自定义模型 (Recipe.class) 制成的网格项目 (~1000)
<com.etsy.android.grid.StaggeredGridView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/mainPageGridView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="main_grid"
android:descendantFocusability="blocksDescendants"
app:column_count="2"
app:item_margin="8dp">
</com.etsy.android.grid.StaggeredGridView>
网格项目是一个简单的LinearLayout,带有Image 和TextView。
问题是当我想点击一个在屏幕上不可见的元素时,Espresso 卡住而不滚动到它来执行操作。
我尝试了以下方法(如果我将位置更改为 1,那么它工作正常):
onData(anything()).inAdapterView(withId(R.id.mainPageGridView))
.atPosition(5)
.perform(click());
并尝试了这个:
onData(anything()).inAdapterView(withId(R.id.mainPageGridView))
.atPosition(5)
.perform(scrollTo(), click());
这是一个错误,还是我缺少一些参数?
【问题讨论】:
-
很遗憾没有:/
-
你解决了吗???
标签: android gridview android-espresso staggered-gridview