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

后端 未结 10 2007
心在旅途
心在旅途 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:43

    One simple way to check for a View or its subclass like a Button is to use method getVisibility from View class. I must caution that visibility attribute is not clearly defined in the GUI world. A view may be considered visible but may be overlapped with another view, for one example, making it hidden.

    Another way but more accurate (I have not tried) is to check for the rectangular bounds of the View. Not so simple.

    Is that clear enough? cannot give you specific examples since you did not post code.

提交回复
热议问题