gpt4 book ai didi

Android Espresso 2.0 卡在点击 gridview 项目上

转载 作者:行者123 更新时间:2023-12-05 07:49:51 27 4
gpt4 key购买 nike

我想为我的 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());

这是一个错误,还是我遗漏了一些参数?

最佳答案

对我有用:

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

关于Android Espresso 2.0 卡在点击 gridview 项目上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36893287/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com