> For the complete documentation index, see [llms.txt](https://docs.drizz.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.drizz.dev/commands-reference/conditional-blocks.md).

# Conditional Blocks

Conditional Blocks enable Drizz tests to intelligently adapt to multiple possible UI states during execution. Many real-world applications present dynamic or variant screens—such as optional popups, different onboarding flows, or context-specific layouts. Drizz’s IF / ELSE IF / ELSE structure ensures the test selects the correct action at runtime based on actual UI visibility, allowing a single test to handle multiple variations reliably. This mechanism increases test resilience, reduces branching test files, and ensures deterministic behavior across unpredictable UI paths.

When a screen can appear in multiple possible states, Drizz allows chaining conditions using:

* **IF** → primary condition
* **ELSE IF** → one or more intermediate conditions
* **ELSE** → final fallback when none of the above match

This structure is used when the app may atleast 2 or more UI variations and the test must reliably choose the correct action each time.

#### CASE 1: Having exact 2 variation condition

**Structure:**

```
IF <condition>
{
    <commands when true>
}
ELSE
{
    <commands when false>
}
```

**Example**&#x20;

```
IF Profile icon is visible
{
    Tap on Profile icon
}
ELSE
{
    Tap on Hamburger menu
}
```

#### CASE 2: Having more than 2 variation condition

**Structure:**&#x20;

```
IF <condition A>
{
    <commands for first condition>
}
ELSE IF <condition B>
{
    <commands for second condition>
}
ELSE
{
    <fallback commands when none match>
}
```

#### Example:&#x20;

```
IF Proceed to Pay is visible
{
    Tap on Proceed to Pay
}
ELSE IF Slide to pay is visible
{
    Drag the slider from left to right
}
ELSE
{
    Scroll down until "Proceed" CTA is visible
    Tap on Proceed
}
```
