5

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.

  • Oops, perhaps it isn't broken, but I was using it wrong. It looks like `isElementPresent` is expecting a locator as a parameter. It will then return `true` if there is more than one child element matching the locator - I think. I could definitely use verification though. – Mitchell Hentges Dec 22 '14 at 22:54
  • Hi @mitchell, please consider marking my answer 'accepted'. – Adam Dec 23 '14 at 15:03

1 Answers1

2

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: enter image description here

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.

Adam
  • 2,027
  • 1
  • 16
  • 27