Skip to content

Switch

The Switch block in Leapwork helps your automation decide what to do next by checking an input value against different options and following the first one that matches. It works like a simple “if this happens, do that” rule. You can set up multiple cases, choose how the values should be compared, and let the block pick the correct path automatically. If nothing matches, the No match path is used instead. This makes your flows flexible and smart, so they can react to different situations without extra work.


The Block Header (“Switch”)

The green input connector in the header is used to trigger the block to start executing.

Each case has a green output connector triggered if the comparison method specified was met.

The title of the block (“Switch”) can be changed by double-clicking on it and typing in a new title.

Switch

Input

The value to use in the comparison. It can be typed in the field or fed as input from the previous block.

Add case

Add case (branch) to compare to the input field. LEAPWORK will execute the first case branch that meets the comparison method specified.

No match

Triggers when the comparison results in an unsuccessful or false outcome, when none of the cases meet the comparison method.

Comparison method

Select which comparison method to use (Equal, Not equal, Greater than, Greater than or equal, Less than or Less than or equal).

Comparison type

Select which data type to use for the comparison. Values are automatically converted to appropriate data types, but in certain cases it can make sense to select which type to use.

Choosing the wrong comparison type can have unforeseen consequences, so choose carefully. For instance, comparing the text “200,200” with the position 200,50 results in false, but comparing position 200,200 with position 200,50 results in true.


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:

Switch

  • 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.


Updated December 2025.