I am trying to compare values with the following piece of code :
for (i = 0; i < dataElements.length; i++) {
var a = selenium.getText(elements[i]);
var b = selenium.getText(dataElements[i]);
a.then(function (value) {
console.log("a: " + value);
b.then(function (dataValue) {
console.log("b : " + dataValue);
if (value == dataValue) {
console.log("The screen legends KPI: " + value + " matches the Data table KPI : " + dataValue);
assert.isTrue(true);
} else {
assert.isTrue(false, "Screen legends KPI and Data table KPI mismatch");
}
});
});
}
The values returned should be : a: xyz b: xyz a: abc b: abc
Instead I am getting : a: xyz a: abc b: abc b: abc
What am I missing here?