I am working on a method that shall select a valid entry (depends on status). If a valid entry is found, it should leave the loop and go to another function.
But my code does not work. What do i have to change?
function DetectVehicle(vehicles) {
browser.waitForAngular();
if (vehicles > 1) {
basics.checkElementPresent(PDP.elementSelectCar);
for (var car = 0; car < vehicles; car++) {
(function (params) {
try {
PDP.elementSelectCar.click();
PDP.elementCarList.get(car).click();
PDP.elementStatus.getAttribute("class").then(function (value) {
value = value.split("-").pop();
console.log(value);
if (value == "available" || value == "acquired") GoOn();
}, function (err) {
console.log("Error detecting status: " + err);
});
} catch (err) {
console.log("Error detecting status: " + err);
}
})(car);
console.log(car);
}
}
else if (vehicles == 1) {
//this user has only one vehicle, so nothing has to be done :)
}
};
I know that the "GoOn" function will now rise more than one time, because each list has more than one valid entry. But how can i fix this?
Aucun commentaire:
Enregistrer un commentaire