Android Espresso:如何断言不应显示视图

Android Espresso:如何断言不应显示视图,第1张

概述这似乎是正确的…… onView (withId (R.id.menu_delete)).check (matches (not (isDisplayed ()))); …但它抛出了这个异常: android.support.test.espresso.NoMatchingViewException: No views in hierarchy found matching: with id: c 这似乎是正确的……
onVIEw (withID (R.ID.menu_delete)).check (matches (not (isdisplayed ())));

…但它抛出了这个异常:

androID.support.test.espresso.NoMatchingVIEwException: No vIEws in hIErarchy found matching: with ID: com.just10.androID:ID/menu_deleteIf the target vIEw is not part of the vIEw hIErarchy,you may need to use Espresso.onData to load it from one of the following AdapterVIEws:com.github.ksoichiro.androID.observablescrollvIEw.ObservableListVIEw{3169f0f3 VFED.VC. .F...... 0,0-480,724 #102000a androID:ID/List}

不应该显示断言视图的最佳方法是什么?

解决方法 我应该使用的是:
onVIEw (withID(R.ID.menu_delete)).check (doesNotExist ());

这可能特别是视图位于选项菜单中,并且可能在任何给定时间实际存在或不存在,具体取决于onCreateOptionsMenu和onPrepareOptionsMenu中的实现.

编辑

这是另一种适用于非菜单视图的方法:

onVIEw (withID(R.ID.menu_delete)) .check(matches(withEffectiveVisibility(VIEwMatchers.Visibility.GONE)));
总结

以上是内存溢出为你收集整理的Android Espresso:如何断言不应显示视图全部内容,希望文章能够帮你解决Android Espresso:如何断言不应显示视图所遇到的程序开发问题。

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

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

原文地址:https://54852.com/web/1136974.html

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

发表评论

登录后才能评论

评论列表(0条)

    保存