matches(not(isDisplayed())) fails with NoMatchingViewException

前端 未结 5 674
既然无缘
既然无缘 2020-12-25 09:25

I am trying to test the absence of the UI view. The view selector is as follows:

public static ViewInteraction onMyTestUi() {
    return onView(withId(R.id.m         


        
5条回答
  •  孤独总比滥情好
    2020-12-25 09:52

    Need to use doesNotExist() instead. Found here.

    If the view is there in the view hierarchy but in an invisible state (visibility is set to 'INVISIBLE'), use not(isDisplayed). However, if the view is not there at all in the view hierarchy (e.g. visibility set to 'GONE'), doesNotExist() is used.

提交回复
热议问题