如果bar等于jsonObj.alias,则应返回true或false,并且应该是next函数的参数。但这不是在这里发生。请清除这一点。最后一个then函数的参数是什么?如何?
element
.all(by.repeater('portGroup in displayedCollection'))
.filter(function(eachRow) {
return eachRow.element(by.css('td:nth-child(2)')).getText().then(function(bar){
return bar === jsonObj.alias;
});
})
.then(function(values){
values[0].element(by.css('span[class="ng-binding"]')).click();
});
答案 0 :(得分:0)
将代码分为两部分,可以使您理解问题。
var satisfiedRows = element
.all(by.repeater('portGroup in displayedCollection'))
.filter(function(eachRow) {
// the filter function is to find out from all rows
// which's 3rd cell text equal to `jsonObj.alias`
return eachRow.element(by.css('td:nth-child(2)')).getText().then(function(bar){
return bar === jsonObj.alias;
});
}); // we can split your code at here
// satisfiedRows is a promise which eventual value are satisfied rows
// you call `then()` on this promise, the argument `function()` will be
// passed-in the promise's eventual value. In your case,
// they are rows which's 3rd cell text equal to `jsonObj.alias`
satisfiedRows.then(function(rowsAfterFilter){
rowsAfterFilter[0].element(by.css('span[class="ng-binding"]')).click();
});