# Best Practices for Conditional Blocks

Conditional Blocks enable Drizz tests to adapt intelligently when an application presents multiple possible UI states. Modern mobile apps frequently display dynamic variations—such as optional popups, promotional banners, alternate CTAs, or platform-specific layouts. Using IF / ELSE IF / ELSE structures, Drizz evaluates the screen at runtime and executes the correct branch based on actual UI visibility. This ensures a single test flow can handle multiple real-world variations reliably, reducing test duplication, increasing resilience, and maintaining deterministic behavior even when the UI changes unpredictably.

### Recommended Best Practices for Writing Memory Commands:

1. **Use conditions only for real UI variations**\
   Apply IF/ELSE only when the app genuinely shows different screens (popups, alternate CTAs, onboarding changes).
2. **Check one clear UI element per condition**\
   Keep conditions simple and visibility-based for predictable evaluation.
3. **Order conditions by likelihood and stability**\
   Put the most common or most reliable UI state in the primary `IF`, alternates in `ELSE IF`, and a fallback in `ELSE`.
4. **Ensure each branch performs a complete action**\
   Every path should independently move the test forward without relying on previous branches.
5. **Use a final fallback (`ELSE`) for unexpected states**\
   Helps recover when promotions, alerts, or minor layout variations appear.
6. **Avoid redundant or nested conditions**\
   Keep logic readable; extract large blocks into modules if needed.
7. **Do not reuse commands across branches unnecessarily**\
   Move common actions outside the conditional to maintain clarity.


---

# 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/best-practices-for-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.
