2

I know that ElementFinders are promises but I'm not sure how the promise behaves if we define the ElementFinders in the beginning of the Page Object. Looking at an example:

var EventHeader = function (context) {
    this.eventName = this.moduleRoot.element(by.css('.event-name'));
    this.venueName = this.moduleRoot.element(by.css('.venue-name'));
    this.eventTime = this.moduleRoot.element(by.css('.event-time'));
    this.eventDate = this.moduleRoot.element(by.css('.event-date'));
    this.marketName = this.moduleRoot.element(by.css('.market-name'));
};

Will protractor try to resolve all the promises when the page objects is initialised?

I guess the other option would be to define the locators in the beginning and then create methods to return the ElementFinder itself.

jpsstavares
  • 3,303
  • 5
  • 25
  • 32

1 Answers1

4

The element finders will not execute until you call a function on them. You just have to make sure that the elements are on the page when you call something like click(), sendKyes(), etc.

Andres D
  • 8,910
  • 2
  • 26
  • 31