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.

  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.

Last updated

Was this helpful?