Currently, I am navigating the waters of protractor and JavaScript as a newcomer. The main challenge I am facing involves comparing a delimited string to an array.
My objective is to retrieve a collection of all elements and then iterate through each one, checking their text values against the delimited string. However, the delimited string's values are consistently displaying as 'undefined'.
element.all(by.css('.itemField')).then(function (allFieldItems) {
var toCompare = ["AGO", "9"]
for (var i = 0; i < toCompare.length; i++) {
var valueToCompare = toCompare[i]
allFieldItems[i].getText().then(function (text) {
if(text != valueToCompare){
console.log("Values don't match")
}
}.bind(i))
}
})
The issue lies in the line "if(text != valueToCompare)" where "valueToCompare" is always recognized as 'undefined'. I am seeking guidance on how to rectify this concern without relying on expect statements.