I'm struggling with this:
- Click a button to get a set of data
- Check the number of rows returned is what I'm expecting
- I need to run this 10 times, each time, I'm expecting a different number of rows
The code snippet below doesn't work because 'i' isn't what I'm expecting. How can I make this work?
for (var i = 0; i < subElements.length; ++i) {
element(by.id('get-data')).click();
// Check users returned
element.all(by.id('users')).map(function (elm) {
return elm;
}).then(function (users) {
expect(users.length).toBe(expectedRecords[i]);
// Some more checks to be added later
});
}
What about:
As long as you aren't accessing
i
in athen
, it will be what you want, otherwisei
will the the last value in your loop and you'll need closure.EDIT: see Using protractor with loops
Using bluebird