simple JavaScript counter is not working.
I am using JavaScript within protractor (angular testing framework) but I don't think it's the protractor issues but JavaScript issues.
I thought that I can do this: (pseudo code actual code is the one below)
var counter = 0
foreach (smallitems in bigitems){
function(smallitems){foreach (item in smaillitems){
if(item == "somevalue") counter++ }
}
}
but counter never grows evenwhen there's matching values.
Actual codes are:
'use strict';
describe('list page ', function () {
it('should list page', function() {
var counter = 0;
element.all(by.repeater('page in pages')).each(function (page) {
element.all(by.repeater('item in items')).each(function (item) {
if (item.getText() == ("A+")) {
counter++;
}
})
})
})
})
counter always 0. Do you see the problem here?
thank you!