ฉันกำลังพยายามค้นหาดัชนีของรายการจากมุมมองรายการ เพื่อค้นหาดัชนีที่ฉันใช้ฟังก์ชันนี้
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;
}
ในไม้โปรแทรกเตอร์ ฉันจะรอให้คำสัญญาข้างต้นได้รับการแก้ไขได้อย่างไร ตอนนี้เมื่อฉันเรียกส่วนที่เหลือของฉัน ฉันมักจะได้รับสัญญาในสถานะรอดำเนินการ