So I have been trying to figure out on how to click a button x times depending on how many find All elements are. Meaning if there is 3 elements that is found by the same classn
The reason of your it
inside for loop not executed is those it
generated dynamically in run time and did not respected by the test framework, Jasmine, Mocha.
As I learned, Jasmine need to load and parse the static it
in test script files before executing them, dynamic it
generated behind the load and parse stage will be ignored. Thus you need remove dynamic it
.
Try below code
it('Click remove button', function (done) {
let allBtns = element.all(by.className('btn btn-remove btn-outlined'));
allBtns.count()
.then(function (cnt) {
console.log('Find buttons:', cnt)
for (let i = 0; i < cnt; i++) { // important to use let but var here.
console.log('Remove button - ' + i + '/' + cnt);
browser.executeScript("arguments[0].click();", allBtns.get(i).getWebElement())
browser.sleep(1000) // sleep 1s
}
})
.then(()=>{
done();
})
});