When working with an application containing multiple widgets, each with its own title and content, I want to effectively map the elements of each widget for easier testing purposes.
For instance, let's consider a 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()
};
});
Then, in my specification file:
expect(page.widgets[0].index).toBe(0);
expect(page.widgets[0].title).toBe('The Title');
However, I am encountering issues where my expectations are returning undefined
.
What could be causing this issue? My development environment uses Protractor 2.0.