1
我正在尝试从列表视图中查找项目的索引。要找出我正在使用此功能的指数如何等待element.all得到解决?
function restFunction(appName) {
var indexForItem = 0;
var a = element.all(by.repeater("app in itemList").column("app.itemName")).each(function (element, index) {
element.getText().then(function (name) {
console.log("Name is " + name);
if (name == "sam") {
indexForItem = index + 1;
console.log("Ïndex is " + indexForItem);
a = index;
}
});
});
return a;
}
在量角器中我该如何等待上述承诺才能得到解决。现在,当我打电话给我restFunction我总是得到承诺在待定状态