IF {condition1} and {condition2} or {condition3}

Can I test 2 or more conditions in a same IF?
How is it done?

If uses standard Javascript syntax.

From Quora: How can you specify multiple conditions in an if statement in Javascript?

Use either “&&” or “||” i.e. logical AND or logical OR operator to connect two or more conditions inside a if statement.

For eg; If you want to find the number which is divisible by both 5 and 7 , you need to use logical AND, which returns true only if both the conditions are true….
For example:
if(x%5==0 && x%7==0){

// this is called only if, both divisible by 5 and 7

}

OR,

If you need to find out, is the number divisible by either 5 or 7 ?
You need to use logical OR ,
i.e.

  1. if(x%5==0 || x%7 ==0){

// this is called if number is divisible by either of the 5 or 7

}

Another option is to use

“If…elseIf…elseIf…else…end” (depends on your task what works better)

2 Likes

Will it work for text condition, eg if${aa} == “Good” || “Great”

In which case I require either good or great to be the value of aa ?

Thanks

It will work, the syntax in UI.Vision is: if_v2 | ${aa} == 'Good' || ${aa} == 'Great'

3 Likes