IF ELSE

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

  • 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 BeatBlip if statement tests the condition. It executes the if block if condition is true otherwise it executes else condition. (It also executes elseif condition before else statement if it is present)

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

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

Syntax:

Here, in the above example if 8 is equal to 8 then step 3 will execute otherwise step 5 will execute and step 3 will be skipped.

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

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

Syntax:

Here, in the above example if IF statement returns false then ELSEIF block will execute and IF and ELSE bock 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.

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 vales equal etc. To achieve these conditions 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 BeatBlip.

 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 has to give the first value in the Element key and second value in parameter section after STD_EQUALS separated by comma (,)

Syntax 1:

Syntax 2:

Syntax 3:

Selected 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 1:

Syntax 2:

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

Syntax 1:

Syntax 2:

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 1:

Syntax 2:

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

Syntax 1:

Syntax 2:

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 1:

Syntax 2:

Syntax 3:

Syntax 4:

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_ALLEQUALS separated by comma (,)

Syntax 1:

Syntax 2:

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 1:

Syntax 2:

Points to remember:

==> It is mandatory to close the IF statement with ENDIF statement.
==> User has to write standard parameter in the parameter’s section as per the condition.
==> We can use string, numbers and locators to check the IF, ELSEIF condition.
==> We can use all types of variables in IF ELSEIF condition.
==> The block, which does not execute based on the condition, will be skipped during the execution.
==> We should always follow the hierarchy of IF ELSEIF ELSE and ENDIF blocks.
==> A sample hierarchy for these blocks has been given below.

Was this page helpful?