0

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?

Jaffer Wilson
  • 6,683
  • 7
  • 55
  • 125
Mainak
  • 181
  • 2
  • 14

0 Answers0