javascript - Protractor map function returning undefined -
given app multiple widgets on it, each own title , whatnot, map each widget's elements, make them easy handle in tests.
for example, page:
this.widgets = element.all(by.css('ul.widget-grid')).map(function(widget, index) { return { index: index, title: widget.element(by.css('div.title')).gettext() }; });
and in spec:
expect(page.widgets[0].index).tobe(0); expect(page.widgets[0].title).tobe('the title');
unfortunately, expects returning undefined
.
what doing wrong? i'm using protractor 2.0.
this confused me thought i'd add answer others...
while understood map()
returns promise, because using in expect
, thought resolved, , should act array. nope. returns object, looks array, not array.
Comments
Post a Comment