Espresso: return boolean if view exists

前端 未结 8 1683
陌清茗
陌清茗 2020-12-09 01:23

I am trying to check to see if a view is displayed with Espresso. Here is some pseudo code to show what I am trying:

if (!Espresso.onView(withId(R.id.someID)         


        
8条回答
  •  时光说笑
    2020-12-09 01:33

    Why no one mentioned:

    onView(withId(R.id.some_view_id)).check(matches(not(doesNotExist())))
    

    just add not before doesNotExist. But if you use this logic a lot it's better to use a custom matcher.

提交回复
热议问题