I have an IF statement in my test script that verifies the value from GlobalVariable.
if (GlobalVariable.currentText != “abc” || GlobalVariable.currentText != “xyz”) {
–Perform some steps here.
}
In my global variable, currentText is set 123.
But when I run the script, even though current text is 123, it still goes within the IF block and fails my test.
Do someone know why that should be happening?
You are using the OR symbol in your statement, so since “123” does not equal “abc”, that makes the condition true so no more processing needs to take place and into the if block it goes. If you mean to state an AND condition, then you want to use the symbol, &&
if (GlobalVariable.currentText != "abc" && GlobalVariable.currentText != "xyz") {
Or you can change the evaluation to ==
(equal) instead of !=
(not-equal) and keep the OR.
Yes, sorry I was using the correct code but not calling it for the webpage i was using. It was a mistake on my end.
thank you though