I'm testing some angularjs app using protractor and have encountered such a problem:
var counter = 0;
redButton.click();
allImages.each(function(element) {
element.isDisplayed().then(function(isDispl){
if(isDispl === true){
expect(element.getInnerHtml()).toContain('red');
counter++;
console.log("I'm here!")
}
});
});
console.log(counter);
The output is:
0
I'm here!
I'm here!
while I expected output:
I'm here!
I'm here!
2
Why so? Why variable counter does not equal 2 -- the number of times the condition isDispl === true is fullfiled?