Switch

The Switch block routes your automation based on an Input value. It checks the input against multiple cases and continues through the first case that matches, using the selected Comparison method and Comparison type. If no cases match, the flow continues through No match (default).

Fully expanded, the Switch block shows the following properties:

image-20251222-135741.png

Note: The screenshot on this page uses the Elegance Design, introduced in 2025.3. If you are using an earlier version, your layout may look different.

Quick-start

  1. Drag Switch onto the canvas.

  2. Connect the block in the flow and optionally specify the basic parameters required for this block to operate, listed by their exact UI labels in one line: Input, Add case, Comparison method, Comparison type.

  3. Run the flow when it’s ready.

Building block parameters

Parameters
  • Block header: Shows the current name of the Compare block. You can rename it by double-clicking the header and typing a new title.

  • Value A: Specifies the first value used in the comparison. This can be typed directly in the field or provided from another block through an input connection.

  • Value B: Specifies the second value used in the comparison. This can be typed directly in the field or provided from another block through an input connection.

  • Incorrect: Triggers when the comparison evaluates to false. For example, if Value A is 100, Value B is 200, and Comparison method is Greater than, then Incorrect triggers.

  • Comparison method: Defines how Value A and Value B are compared. Available options are:

    • Equal

    • Not equal

    • Greater than

    • Greater than or equal

    • Less than

    • Less than or equal.

  • Comparison type: Selects which data type is used for the comparison. Values are automatically converted to appropriate data types, but in some cases it makes sense to choose the type explicitly. Choosing the wrong comparison type can have unforeseen consequences.
    For example, comparing the text 200,200 with the position 200,50 results in false, but comparing the position 200,200 with the position 200,50 results in true.
    The dropdown includes the following options:

    • As Input Value: Uses the type of Input.

    • Area

    • Boolean

    • Date

    • DateTime

    • Number

    • Position

    • SapElement

    • Signal

    • Text

    • TextBuilder

    • Time

    • TextBase

Let’s understand this using an example:

Scenario: Routing Actions Based on Text Value

The Set Text block sets the text value to “Completed.” This value is sent into the Switch block as Input. The Switch block checks what the value is:

image-20251222-140405.png


  • If it is Completed → Case 1 will be executed, leading to run Pass block.

  • If it is Not started → Case 2 will be executed, leading to run Fail block.

  • If it is Initiated → Case 3 will be executed, leading to run Done block.

  • If it is anything else → the flow will go to Close Windows, which means all current windows will be closed.

Since the value is Completed, the flow always goes to the Pass block.


Resources

Topic

Description

Flows FAQ

Common questions about creating, running, and managing flows in Leapwork.

Flows Troubleshooting

Guidelines and solutions for identifying and fixing issues that occur when building or running flows in Leapwork.