if - else - elseif - endif

The if statement executes a statement if a specified condition is true, If the condition is false, another statement can be executed.

The above example shows the syntax and usage of if, elseif, else, and endif from Test Designer.

The syntax follows the same structure as the one below.

if (condition1)

statement1

elseif (condition2)

statement2

else

statementN

endif

condition

An expression that is considered to be either true or false.

statement1

A statement that is executed if the condition is true. Can be any statement, including further nested if statements.

statement2

A statement that is executed if the condition is false and the else clause exists. Can be any statement, including block statements and further nested if statements.

endif

end of if else statement block.

Javascript example

Copy
navigateTo("https://www.apple.com/  ");
click(_link("iPhone"));
        
var x=3;
        
if (x<3){
        
click(_link("Watch"));
        
click(_link("Music"));
        
}
        
else if (x==3){
        
click(_link("TV"));
        
}
        
else {
        
click(_link("Music"));
        
click(_link("Watch"));
        
}
        
click(_link("TV"));