A new version of Qualitia Automation Studio for Web and Mobile 7.2.x is now available. We highly recommend you upgrade. Find more details here.
Adding Conditional Structures
Inserting Conditional Blocks
Qualitia users can add conditional blocks using the If-Else button.
Task Level IF ELSE Blocks
Adding IF-ELSE Conditional Block to Task
Adding Expression for IF Step
Forming Expression for IF /ELSE IF:
Expressions can be entered for IF and ELSE IF conditional step. User can use stored variables, environment variables as expressions.
- You can use Numeric, Boolean comparisons, string values, and arithmetic operators.
- Environment variables and stored variables should be included in curly braces in expression.
- User can save the execution status of last executed step as $$_STATUS using the StoreVariable action, or can directly use $$_STATUS in expression.
- Using $$_STATUS directly in expression.
- Saving status of step ($$_STATUS) for use as an expression.
User can save the execution status of a step in variable. This status can later be used as an expression of IF step.
- Saving execution status for future reference.
For more information about $$_Status and more such variables, click here.
Examples of Expressions:
Following are some examples of valid/invalid expressions, assuming var1 and var2 as stored variables.
Note
- The static or dynamic string data used should always be enclosed within double quotes.
- The expression, having string as data, should always be enclosed within double quotes.
- Boolean values are case-sensitive and should be used in lower case.
Data type | Example | Valid/Invalid |
---|---|---|
Any |
| All are invalid as assignment operator is not allowed in expression |
String |
|
|
Integer |
|
|
Float |
|
|
Boolean |
|
|
Logical operators | (var1=true , var2=false)
|
|
Arithmetic |
|
|
Relational Operators |
|
|
Bitwise Operators | (var1=60 , var2=13)
|
|
Special Characters | Using Qualitia Special characters:
Always use escape character ~ before qualitia special characters ~,^,{,} |
|
Adding ELSE IF block after IF
Adding Multiple ELSE IF Blocks:
Adding ELSE Block After IF Step
Adding the Task Step on the TC Screen
You can add the task step using the Add button. After adding the task step, you can add conditional blocks with or without expressions to that step.
Test Case Level Step (TC step) on the Test Cases Screen
In case you want to avoid adding a task for single step, you can add TC step. You can then add object, action, and parameters to a TC step just like a task step.
The TC step can be added at any position, after or before a task or even as a first step of test case.
To add TC step:
- Focus on task and click the TC Step button. You can then use Up and Down buttons to move the step up or down.
Adding A TC Step and Task Step
Storing Execution Status of TC Step
The execution status of TC step can be stored same as task step.
IF ELSE Blocks on the Test Cases Screen
On the Test Cases screen you can add conditional blocks to task and Test Case. The Test Case level IF-ELSE blocks can contain tasks and the contained tasks in turn can have task level IF-ELSE blocks.
Adding IF-ELSE Blocks to Test Case
You can add the TC or Task condition using the If-Else button from the Testc ases screen.
To add TC or Task Condition:
- Select TC Step/Task after which you wish to add TC level conditional block.
- Click Condition >TC Condition > IF
- Select IF step of block, click the TC Step button to add TC step.
- Select recently added TC Step:
- click Condition >TC Condition >ELSE IF to add TC level ELSE IF block.
- click Condition >TC Condition > ELSE to add ELSE block.
Adding Tasks in Test Case Level IF-ELSE Blocks
You can add new tasks or import tasks from the existing library of tasks inside the conditional blocks.
To add tasks in TC level If-Else blocks:
- Select TC Step/Task after which you want to add TC level conditional block.
- Click Condition >TC Condition > IF.
- Select IF step of block and then click New to add new task or Import to add existing task to the conditional block.
- To add Tasks to ELSE-IF or ELSE blocks, select the ELSE-IF or ELSE step of the conditional block and then click New or Import.
Adding IF-ELSE Blocks to Task in TC
You can add the conditional blocks particularly for task.
To add conditional blocks to a task from the Test case:
- Create a new test case and add required tasks to it.
- Select the step after which the conditional block needs to be added, or the task row to which the block needs to be added.
- Click the If-Else button > Task Condition > IF.
- Once If block is added to task, ELSE IF or ELSE blocks can be added by selecting proper task step and using the If-Else button.
- For adding expression, double-click IF or ELSE IF.
- Use the syntax of expression is as described earlier.
Execution flow of conditional (IF-ELSE) blocks will be as follows:
- Qualitia validates expression entered by the user and checks if expression is empty or contains assignment (for example, if user entered a=b which is invalid). Expressions should not have assignment, users should use "==" operator instead. Hence {a}={b} is invalid expression.
- Rest of the syntax and semantics is checked during actual execution of test case.
- You must enclose stored variables, environment variables in curly braces (for eg: {a}=={b}, or {$$_Status}==0.
- Consider following test case level conditional block:
- OpenUrl
- IF {$$_Status}==0
Task1
Task2 - ELSE IF {$$_Status}==1
Task3 - ELSE
Task4 - END IF
If during execution, the step OpenUrl is successful, then Task1, Task2 is executed.
If the step OpenUrl fails, then Task3 is executed.
If the OpenUrl has execution status other than 0 or 1, Qualitia executes Task 4.
Qualitia's Behavior in case of Invalid Expression:
- If the expression is invalid, for example expression has stored variables referred but not declared, or the syntax of expression is invalid then the test case is considered to have an error and Qualitia will stop execution of test case.
- When execution is triggered using the Dry Run button from the Develop tab and if the expression is invalid, Qualitia stops execution of test case.
- When execution is triggered using the Run Now button from the Execute tab and if the expression is invalid, Qualitia executes next test case. If there is only one test case, execution will be stoppped.
In all such cases, Error log in reports will explain the reason of execution failure so that users can take corrective actions.