I am new to protractor and JavaScript and struggling trying to compare a delimited string to an array.
What I am trying to do is to find a list of all elements and then from each element, loop through the arrays to compare the text values to the delimited string but the delimited string values are '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[i]){
console.log("Values don't match")
}
}.bind( i))
}
})
The problem is that the line "if(text != valueToCompare[i]) the "valueToCompare[i]" is always 'undefined' and I am looking for help on how to resolve this without using expect statements.
Aucun commentaire:
Enregistrer un commentaire