【问题标题】:Android Espresso 2.0 stuck on clicking gridview itemAndroid Espresso 2.0 卡在单击 gridview 项目上
【发布时间】: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,带有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());

这是一个错误,还是我缺少一些参数?

【问题讨论】:

  • 很遗憾没有:/
  • 你解决了吗???

标签: android gridview android-espresso staggered-gridview


【解决方案1】:

它对我有用:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多