Espresso - How to check if one of the view is displayed

后端 未结 10 2005
心在旅途
心在旅途 2021-02-03 17:22

In my test, after one action, there are two possible views which can appear and both of them are correct. How can I check if one of the view is displayed. For a single view I ca

10条回答
  •  孤独总比滥情好
    2021-02-03 17:34

    You can use Matchers.anyOf to check if any of the two views are displayed:

    onView(
       anyOf(withId(R.id.view_1), withId(R.id.view_2)) 
    ).check(matches(isDisplayed()));
    

提交回复
热议问题