android– 如何在浓缩咖啡中选择列表视图?

android– 如何在浓缩咖啡中选择列表视图?,第1张

概述我正在使用espresso进行测试,我在一个页面中有多个AdapterView,例如,当我使用时,id为:R.id.list1,R.id.list2昂达(withMainValue(“XX”)).检查(比赛(isDisplayed()))publicstaticMatcher<Object>withMainValue(finalStringvalue){returnnewBoundedMatcher<Object,

我正在使用espresso进行测试,我在一个页面中有多个AdapterVIEw,例如,当我使用时,ID为:R.ID.List1,R.ID.List2

昂达(withMainValue( “XX”)).检查(比赛(isdisplayed()))

public static Matcher<Object> withMainValue(final String value) {    return new BoundedMatcher<Object,                            GuessYoulikeGoodItem.DataEntity>(GuessYoulikeGoodItem.DataEntity.class) {        @OverrIDe public voID describeto(Description description) {            description.appendText("has value " + value);        }        @OverrIDe public boolean matchesSafely(                        GuessYoulikeGoodItem.DataEntity item) {            return item.store_name.contains(value);        }    };}, 

Espresso报道:

    androID.support.test.espresso.AmbiguousVIEwMatcherException: 'is assignable from class: class androID.Widget.AdapterVIEw' matches multiple vIEws in the hIErarchy.    Problem vIEws are marked with '****MATCHES****' below.

如何选择特定的列表视图并尝试使用onData?

解决方法:

如果您有多个具有唯一ID的ListvIEw,您应该能够检查是否显示了一个列表

onVIEw(withID(R.ID.List1)).check(matches(isdisplayed()));

如果你想进入AdapterVIEw,你可以点击ListvIEw中的一个元素

onData(anything()).inAdapterVIEw(withID(R.ID.List1)).atposition(0).perform(click());
总结

以上是内存溢出为你收集整理的android – 如何在浓缩咖啡中选择列表视图?全部内容,希望文章能够帮你解决android – 如何在浓缩咖啡中选择列表视图?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1108431.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-29
下一篇 2022-05-29

发表评论

登录后才能评论

评论列表(0条)

保存