Skip to main content
No Result Found

Record Conditional flows with If-else

Testing an application involves navigating various scenarios. Each scenario often represents a different workflow or path a user might take when interacting with the application. For example, on an e-commerce website, a test scenario might involve checking for the presence of a Promo Code input field during checkout. If the Promo Code field is present, the test applies a discount code and proceeds to validate the updated total amount. However, if the Promo Code field is not present (e.g., during certain promotions or simplified checkouts), the test skips applying the discount code and directly verifies the standard total amount.

This type of conditional flow helps ensure that your test can handle different checkout page variations, making your test adaptable and comprehensive across multiple user journeys.

The Add conditional flow option lets you run multiple scenarios in a single test by using if-else blocks. It allows you to take specific set of actions based on various conditions. When a condition is met, it executes a specific set of steps, else, it skips to the next set of steps. This allows your tests to adapt to various outcomes depending on the application’s behavior.

Supported conditional blocks

Low Code Automation provides the following conditional blocks:

  • If: Executes a defined set of steps when a specified condition is met.
  • Else-If: Allows for additional conditions to be checked if the previous If or Else-If conditions are not met. Multiple Else-If blocks can be used to manage various test scenarios.
  • Else: Follows an If or Else-if block. Executes a set of steps if none of the preceding conditions are met.
  • End if: Concludes the conditional flow to ensure proper test closure.

Adding a conditional flow

  1. In the Low Code Automation recorder, click the three-dot icon and select Add conditional flow. Add conditional flow This will add a new step with an If block, an Else block, and an End If block to your steps. If-Else Blocks
  2. In the If block, click add condition. You can check for following three supported conditions:
  3. Select the desired webpage element and set the validation criteria. For instance, if you selected Element presence, specify whether the element should be present or not.
  4. Add the steps that should be executed if the condition in Step 2 is met.
  5. In the Else block, define the steps that should be executed if the condition defined in the Step 2 is not met.
  6. You can change the Else block to Else If if you want to add additional conditions. Alternatively, you can also add a else-if block by hovering on the last if, or else-if block step. Else if
  7. Click Save and run.

Use cases for conditional flow

This section provides key use cases for conditional flows. These examples show how to implement if-else logic for element presence, text validation, and variables.

Add conditional flow based on Element’s presence

A condition can be added to execute a block of steps if an element is present on the webpage and if not present skip those steps and execute another block of steps.

In this use case, an If logic is included to determine whether the demo form element appears on the webpage. If the popup appears, additional steps will be added to fill out and submit the demo form.

Conditional Flow using Element Presence

Add conditional flow based on Element’s text

This feature allows you to check the text content of an element on the webpage. You can set a condition to execute a block of steps based on whether the element’s text matches a specified value. If the text matches, the defined steps will run; if not, the test can move to a different set of steps.

In this scenario, a conditional check is included to verify if the webpage contains the text Low Code Automation, and if so, click Get started free.

Conditional Flow using Text Presence

Add conditional flow based on a Variable’s value

Executes a specified set of steps based on the variable values. Learn more about Variables.

In the below use case, a conditional logic is added to the login process based on the webpage URL, which acts as a variable.

Conditional Flow using Variable

Deleting if-else conditional flow

To remove conditional steps, click Remove conditional steps at the end of the flow. You can also select the if-else steps and click the Delete icon at the top. A confirmation dialog appears, click Delete.

Delete Conditional Flow

  • Deleting an If block affects the following:
    • If there is also an Else if block, it is promoted to an If.
    • If there is only an Else block, it is converted into regular steps

Points to remember

  • A test can have multiple if, else-if, and else blocks but nested if-else conditions are not allowed.
  • If the condition is not met, the step will show an error and move on to the next block. This does not affect the overall test execution status. However, if there is an error while validating the condition for the step, the execution will stop.
  • After completing the steps on a specific page for a condition block, return to the page to record the steps for the next block. To facilitate this, the recording is paused, allowing for a smooth navigation back. To again start recording, unpause the recorder.

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked





Thank you for your valuable feedback

Is this page helping you?

Yes
No

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked





Thank you for your valuable feedback!

Talk to an Expert
Download Copy Check Circle