What is the difference between the isPresent and isDisplayed methods

后端 未结 5 582
走了就别回头了
走了就别回头了 2020-12-08 06:40

I just started using Protractor to write tests. I am wondering what the difference is between the isPresent() and isDisplayed() methods.

5条回答
  •  伪装坚强ぢ
    2020-12-08 07:44

    There is a major difference between isDisplayed() and isPresent().

    isDisplayed() - Your element is present on the page but it is displayed.

    isPresent() - Your element is present in entire DOM of the page. Probably it can be hidden or not disabled, but present.

    You should not use isPresent() when you need to validate on specific element you are searching, rather you can use it to validate some other checks based on that element's presence.

提交回复
热议问题