Conditional logic and loops
Conditional logic lets users define actions that execute when specific conditions are met, enhancing efficiency through automation. Users can integrate if-else, while, and loop statements into test scripts using Selenium, JavaScript, and standard steps.
When "Add Conditional Loop Steps" icon is clicked, a pop-up window appears, allowing users to select the desired conditional statements.
If-Else Condition:
The "if" statement evaluates a condition, executing the steps within its block only if the condition is true and else part won’t execute. Steps specified under the "else" block should execute when if condition is false.
When adding an if-else condition, users can choose between JavaScript or Selenium scripts, each opening a dedicated scripting window upon selection. Predefined scripts are available in presets, allowing for easy use and direct integration into workflows.
In the reports section, the if-else condition will be displayed as shown in the accompanying image. Here when an “if” condition is passed, the “else” condition will be marked as "not executed". This provides clear visibility into the flow of conditional logic within workflows. For normal steps the “if “condition will be displayed in reports section but for steps having JavaScript or Selenium scripts then it will not be displayed
While condition:
The while loop condition allows users to define a condition that controls the loop's execution. The steps within the "while" loop will repeatedly execute if the defined condition remains true. It's an essential feature for creating dynamic and responsive automation scripts that can handle repetitive processes based on real-time evaluations.
The while loop will iterate by default for five iterations. Here’s an example:
While (condition){
click on x;
}
This is how while condition will work
if condition is true ----- "click on x" will execute in the first iteration.
if condition remains true in all iteration ----- it will execute up to five times
if condition fails first time ------ "click on x" will not execute
if condition passes two times and fails in 3rd ------- "click on x" will execute twice.
In the reports section, the while loop will be displayed as shown in the accompanying image. Users can adjust iteration by clicking up and down arrows, while dynamic pass/fail status will be displays on the basis of conditions
Loop Functionality:
Loop functionality enables users to define a specific number of iterations for a loop, with a configurable maximum limit of 10 iterations. The steps within the loop will execute for the set number of iterations, ensuring controlled repetition of tasks.
This functionality supports both Selenium and JavaScript scripts, making it versatile for a wide range of automation needs.The number of iterations will be visibly displayed next to the loop icon, providing clear and immediate feedback on the loop's execution count.
In the reports section, loop functionality will be displayed as shown in the accompanying image. Users can adjust iteration by clicking up and down arrows, while dynamic pass/fail status will be displayed for the selected iteration.
Additional Functionality:
Users can add steps within a conditional block by simply dragging and dropping elements, streamlining the integration of actions into test scripts.
It provides robust support for nested conditional logic, enabling users to create complex workflows with multiple levels of if-else, while, and loop conditions.
It also offers detailed insights into workflow performance and outcomes through its comprehensive reports section.
Users can also add conditional logic blocks between steps, further enhancing the flexibility and control of their automation scripts. This allows for dynamic responses and adjustments based on real-time evaluations.