jeudi 4 juin 2015

Protractor map function returning undefined

Given an app with multiple widgets on it, each with their own title and whatnot, I would like to map each widget's elements, to make them easy to handle in tests.

For example, 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()
    };
});

And then in my spec:

expect(page.widgets.index).toBe(0);
expect(page.widgets.title).toBe('The Title');

Unfortunately, my expects are returning undefined.

What am I doing wrong? I'm using Protractor 2.0.

Aucun commentaire:

Enregistrer un commentaire