AngularJS + Protractor sum all row values in repeater

孤街醉人 提交于 2019-12-03 20:32:25

rows is an array and it's being called like a function (the side effect is that getText() is being called over the entire array instead of the desired element)

Also getText()'s response should be handled with another callback.

var total = 100;
var sum = element.all(By.repeater('item in publishers_data')).map(function(row) {
  return row.getText();
}).then(function(arr) {
  return arr.reduce(function(a, b) {
    return Number(a) + Number(b);
  })
});
expect(sum).toEqual(total);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!