In my script, I need to include if-else condition to verify whether the expected=actual.If they are not matching it should go to the else block and print "StepFailed".But, always its executing the if block and the o/p is "step passed" although expected≠Actual.Below 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’+ ‘’);
}
}
Drop down values are:‘Select training program using Index’, ‘Selenium’, ‘Appium’,‘UFT/QTP’,‘Loadrunner’.If you would have observed I have given ‘A’ instead of "Appium’ and hence the step should fail but that’s not happening.
kindly suggest me how this can be resolved.Thank you.
#typescript #npm