gpt4 book ai didi

android - Espresso 中的 PreferenceMatchers

转载 作者:行者123 更新时间:2023-11-29 17:26:20 26 4
gpt4 key购买 nike

我想在我的偏好 Activity 中点击一个项目。我试过下面的代码,

onData(withKey("preference-key")).perform(click());

但是它会抛出一个异常,比如,

Caused by: android.support.test.espresso.AmbiguousViewMatcherException: Multiple Ambiguous Views found for matcher is assignable from class: class android.widget.AdapterView

我怎样才能正确地点击这个项目?

最佳答案

首先,您注意到 AmbiguousViewMatcherException 意味着您至少有两个具有相同 idkey 的 View 文本, contentDescription

你的代码告诉我你正在尝试编写 AdapterView 测试,就像你只有一个 View 一样,所以你尝试使用 onData 匹配器,就像它是 onView 匹配器。抱歉,AdapterView 测试从未如此简单。

代替

onData(withKey("preference-key")).perform(click());

这样写代码

onData(anything())
.inAdapterView(allOf(
isDescendantOfA(withId(R.id.fragment1)),
withId(R.id.listview)))
.atPosition(4)
.perform(click());

在 StackOverflow 上查找 AmbiguousViewMatcherException Espresso 问题。它经常退出问题,也许有人有像你这样的观点。

关于android - Espresso 中的 PreferenceMatchers,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34428854/

26 4 0
文章推荐: javascript - 谷歌图表可视化实例化问题仪表板
文章推荐: android - 如何使用 Jsoup 从
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com