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我總是得到承諾在待定狀態