Skip to content

IF ELSE

IF ELSE functionality is used to handle the conditional scenarios where the output is not certain. We have four commands to achieve IF ELSE functionality in HuLoop.

  • IF Command
  • ELSEIF Command
  • ELSE Command
  • ENDIF Command

IF Command: IF command takes screen name, element key and parameter values to evaluate the truth-value. It is mandatory to use ENDIF command to mark the end of the IF block.

ELSEIF Command: This command takes screen name, element key and parameter values to evaluate the truth-value. This command can only be used between IF and ELSE/ENDIF.

ELSE Command: This command executes or skips all consecutive steps until ENDIF is encountered depending upon the parent IF/ENDIF condition.

ENDIF Command: This command marks the end of immediate IF block. This command is mandatory for IF blocks.

IF Statement: The Huloop if statement tests the condition. It executes the if block if condition is true otherwise executes the else condition. (It also executes elseif condition before else statement if it is present)

Tabular View : 

Card View :

 

Note: It is mandatory to close the IF statement with ENDIF statement.

Tabular View :

Card View :

 

ELSE Statement: The HuLoop if-else statement also tests the condition. It executes the if block if condition is true otherwise else block will be executed.

Tabular View:

Here, in the given example if Candidate Name is equal to HuLoopUser then step 4 will be executed otherwise step 6 executed and in that case step 4 will be skipped.

Note: The block, which does not execute based on the condition, will be skipped during the execution.

Card View:

 

ELSEIF Statement: The if-else-if ladder statement executes one condition from multiple statements.

Syntax:

Tabular View:

Card View:

 

Here, in the above example if IF statement returns false then ELSEIF block will execute and IF and ELSE block will be skipped.

We can have multiple ELSEIF statements inside IF & ENDIF statements, depending upon the condition, which we are trying to accomplish.

 

ENDIF Statement: The ENDIF statement is used to define the termination if a single IF Statement. It is mandatory to use an ENDIF statement with an IF statement. ENDIF is treated as a mark of termination for the IF statement.

Syntax:

Tabular View:

 

Card View:

 

Standard Conditional Parameters in IF ELSE Functionality

We can use IF ELSE functionality to achieve multiple conditions like is element present, is checkbox checked, are two values equal etc. To achieve these conditions the user has to pass a standard keyword depending upon the type of condition. Here is the list of standard conditions name that is supported in HuLoop.

 STD_EQUALS
 STD_EQUAL
 STD_EQUALSIGNORECASE
 STD_EQUALIGNORECASE
 STD_NOTEQUAL
 STD_NOTEQUALS
 STD_ALLEQUAL
 STD_ALLNOTEQUAL
 STD_CONTAINS
 STD_CONTAINSIGNORECASE
 STD_NOTCONTAINS
 STD_ALLCONTAINS
 STD_ALLNOTCONTAINS
 STD_ON
 STD_ENABLED
 STD_OFF
 STD_DISABLED
 STD_SELECTED
 STD_NOTSELECTED
 STD_CHECKED
 STD_UNCHECKED
 STD_PRESENT
 STD_NOTPRESENT
 STD_LESSTHAN
 STD_GREATERTHAN

Here are a few examples from the above list.

Equals Not Equals Condition: When user wants to check whether two values are equal or not.

User must give the first value in the Element key and second value in parameter section after STD_EQUALS separated by comma (,)

Syntax for STD_EQUALS:

 

 

Syntax for STD_NOTEQUALS:

 

 

Selected for Not Selected Condition: When user wants to check whether some option is selected from the dropdown or not.

User has to give the option value in the parameter section after STD_SELECTED separated by comma (,)

Syntax for STD_SELECTED :

 

 

Syntax STD_NOTSELECTED :

 

 

Present Not Present Condition: When user wants to check whether the web element is present on the screen or not.

Syntax for STD_PRESENT:

 

 

Syntax for STD_NOTPRESENT:

 

 

Greater Than Less Than Condition: When user wants to check whether the first value is greater/less than from the second value.

User has to give the first value in the Element key and second value in parameter section after STD_GREATERTHAN separated by comma (,)

Syntax for STD_GREATERTHAN:

 

 

Syntax for STD_LESSTHAN:

 

 

Checked Unchecked Condition: When user wants to check whether  some check box is checked or not.

Syntax for STD_CHECKED:

 

 

Syntax for STD_UNCHECKED:

 

 

Contains Not Contains Condition: When user wants to check, whether some locator or some string consist of some sub-string of that string.

User has to give the first value(complete string) in the Element key and second value (sub-string) in parameter section after STD_CONTAINS separated by comma (,)

Syntax STD_CONTAINS :

 

 

Syntax STD_NOTCONTAINS :

 

 

All Equal All Not Equal Condition: When user wants to check, whether all the matching web elements are equal to a certain value or not.

User has to give value to be checked in the parameter section after STD_ALLEQUAL separated by comma (,)

Syntax for STD_ALLEQUAL :

 

Syntax for STD_ALLNOTEQUAL :

 

 

 

All Contain All Not Contain Condition: When user wants to check, whether all the matching web elements contain certain value (string) or not.

User has to give value to be checked in the parameter section after STD_ALLCONTAINS separated by comma (,)

Syntax for STD_ALLCONTAINS :

 

Syntax for STD_ALLNOTCONTAINS :

 

 

Points to remember:

1.It is mandatory to close the IF statement with ENDIF statement.

2.User must write standard parameter in the parameter’s section as per the condition.

3.We can use string, numbers and locators to check the IF, ELSEIF condition.

4.We can use all types of variables in IF, ELSEIF condition.

5.The block, which does not execute based on the condition, will be skipped during the execution.

6.We should always follow the hierarchy of IF  ELSEIF  ELSE and ENDIF blocks.

Back To Top