My function successfully retrieves the index of an element with the text "check" and prints it using console.log:
function getIndex() {
return element.all(by.css(".palette__item.ng-scope>span")).then(function (colorList) {
colorList.forEach(function (elem, index) {
elem.getText().then(function (text) {
if (text == "check") {
console.log(index);
return index;
}
});
});
});
}
Despite numerous attempts, I have been unable to retrieve the data from it successfully. My latest approach was:
var res = null;
webDriver.promise.fullyResolved(getIndex()).then(function (index) {
res = index;
});
console.log(res);
Even after initializing the `res` value inside the function to guarantee promise resolution, it still returns null.
I suspect an error in the `getIndex()` function, possibly related to the placement of the return operator. I am in need of assistance as I am out of ideas on how to make it work. Any help is greatly appreciated.