# Best Practices for Scroll & Scroll Until “X”

This section outlines the recommended best practices for writing stable, deterministic, and high-precision scroll commands in Drizz. These guidelines ensure that both **Scroll** and **Scroll Until “X”** actions behave consistently across varying layouts, content densities, and UI states. By providing clear direction, explicit targets, and contextual intent, teams can achieve highly reliable movement through screens, lists, sections, and dynamic content.

### Recommended Best Practices for Writing Scroll Commands:

1. **Always specify the scroll direction:** Scrolling must explicitly indicate down, up, left, or right, matching how a real user performs the gesture. The direction is determined based on natural thumb movement—for example, to move the screen upwards, a user swipes from bottom to top, which corresponds to “Scrolling Up”.<br>
2. **Use double quotes for all scroll targets:** Quoted targets ensure precise and deterministic matching.

&#x20;       **Example:** Scroll down until "Checkout" is visible

3. **Provide clear and unambiguous intent:**

&#x20;     Adding context strengthens AI understanding and reduces ambiguity.

\
&#x20;     **Example:** Scroll down until you find 4 product cards under "Beauty" header \ <br>

4. **Use section-level context when scrolling under headers:**

&#x20;      Header-based references guide Drizz to look within the correct grouping or category. Ideal for category pages, segmented sections, and grouped lists.

5. **Use container-level scrolling when multiple scrollable regions exist:**

&#x20;      Direct the scroll to the intended container to avoid unintended page movement.\
&#x20;      Example: Scroll down inside product list&#x20;

6. **Prefer Scroll Until “X” when the destination is known:**

&#x20;     It reduces blind scrolling, improves flow predictability and stabilizes navigation.

6. **Leverage Drizz’s self-heal mechanism:**

&#x20;     Drizz automatically adjusts scroll behavior when blocked by sticky headers, UI overlaps, or nested scroll views.\ <br>

> Avoid scrolling during UI transitions or loading states:\
> Wait for the interface to settle before issuing a scroll command to prevent inconsistent behavior.


---

# 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/action-commands/scroll-command/best-practices-for-scroll-and-scroll-until-x.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.
