My script involves an if-else condition to compare expected and actual values. If they do not match, it should go to the else block and print "StepFailed". However, it always executes the if block and the output is "step passed" even when expected does not equal actual. Here is my code:
var expected = ['Select training program using Index', 'Selenium','A','UFT/QTP','Loadrunner'];
var els = element.all(by.xpath("//select[@id='dropdown1']/option"));
for (var i = 0; i < expected.length; ++i) {
if(expect(els.get(i).getText()).to.eventually.equals(expected[i])){
console.log('' +'Steppassed'+ '');
}else{
console.log('' +'Stepfailed'+ '');
}
});
The dropdown values are: 'Select training program using Index', 'Selenium', 'Appium','UFT/QTP','Loadrunner'. I have mistakenly used 'A' instead of "Appium' which means the step should fail, but that's not what's happening.
Please provide suggestions on how to resolve this issue. Thank you.