# 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
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.drizz.dev/commands-reference/conditional-blocks.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
