Reputation: 131
How to assign count of number of rows to another value which can be use later in the test cases in Protractor.
I have written following code but its not returning count value:
var rows = element.all(by.repeater('row in renderedRows'));
var row1 = rows.count().then(function(rowsn) {
return rowsn;
console.log(rowsn);
});
Now i want to use this count value in for loop
Upvotes: 1
Views: 90
Reputation: 25177
Protractor functions generally return promises, not values. So, you need to do your computation in a then
or other code that resolves the promise.
You'll want to read the Protractor Control Flow doc and probably the WebDriverJS control flow doc
In your case, some thing like:
var rowsPromise = element.all(by.repeater('row in renderedRows'));
rowsPromise.count().then(function(rowsn) {
for (var i = 0; i < rowsn; i++) {
// do something with rowsPromise[i] (which is also a promise)
}
});
Upvotes: 2