What's the difference between ElementFinder.prototype.isPresent and ElementFinder.prototype.isElementPresent?
It sounds like isElementPresent
waits for Angular to finish, while isPresent
just does a check immediately, but I can't tell for sure.
Currently, isElementPresent
is broken as per a Protractor bug, so I can't manually test the difference.
Both isPresent
and isElementPresent
return an "Element Finder" which:
"represents a single element of an ElementArrayFinder (and is more like a convenience object). As a result, anything that can be done with an ElementFinder, can also be done using an ElementArrayFinder. The ElementFinder can be treated as a WebElement for most purposes, in particular, you may perform actions (i.e. click, getText) on them as you would a WebElement."
Reader's Digest version: You can call methods on it or test if it exists.
isElementPresent
actually calls isPresent
if the locator is met, see the return statement:
They essentially do the same thing. Protractor is built on top of WebDriver, which has its own methods. You can also use these methods in Protractor. In the event that testing Angular with these methods could result in faulty information, they provided users with an Angular work-around; isElementPresent
is one of those, for the reason you mentioned.
tl;dr: Use isPresent
. It was built for Protractor to test Angular.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With