1

I would like to know if there is a benefit or difference in using one approach of page object definition versus the other:

Page Object Technique 1:

titlePageHeader: { get: function () { return element.all(by.css('h3.panel-title')).get(0); }},
homeIcon: { get: function () { return element(by.css('a[title="Home"]')); }},
menuIcon: { get: function () { return element(by.css('i.md.md-menu')); }},

Page Object Technique 2:

this.getTitlePageHeader = element.all(by.css('h3.panel-title')).get(0);
this.homeIcon = element(by.css('a[title="Home"]'));
this.menuIcon = element(by.css('i.md.md-menu'));
  • I think this is somewhat related to http://stackoverflow.com/questions/31466489/canonical-way-to-define-page-objects-in-protractor. A new guide should come out soon, stay tuned. – alecxe Jul 27 '15 at 23:37
  • Thanks Alec. I guess one returns a function the other a promise. I don't know if that is the focus of the guide but i would like to know since we are debating that now. – Jason Corbett Jul 27 '15 at 23:54

1 Answers1

0

As a ElementFinder isn't evaluated until an action is performed on it, there is no benefit of using getters to regular variables. I would go with the latter alternative as it feels more familiar.

An ElementFinder does not actually attempt to find the element until an action is called, which means they can be set up in helper files before the page is available. 1

Olov
  • 1,103
  • 11
  • 27