Android Espresso 2.0卡在点击GridView中的项上

3

我想为我的Android应用程序创建Espresso测试。我有一个包含许多自定义模型(Recipe.class)的StaggeredGridViewStaggeredGridView Github),其中包含大量网格项(约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,其中包含ImageTextView

问题在于,当我想点击屏幕上不可见的元素时,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());

这是一个bug吗,还是我漏了一些参数?


很遗憾,不是的 :/ - Slenkra
你解决了吗? - Maniraj
1个回答

0

对我来说它有效:

onData(anything()).inAdapterView(withId(R.id.main_drawerGridView)).atPosition(0).perform(click());


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接