> For the complete documentation index, see [llms.txt](https://gaffa.dev/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gaffa.dev/docs/features/browser-requests/actions/scroll.md).

# Scroll

**Type**: `scroll`

Request that the browser scrolls to a certain point on the page or, in the case of pages with infinite scrolling, scrolls for a particular amount of time.

<details>

<summary><strong>Tips for using <code>scroll</code> action</strong></summary>

* Use `wait_time` for pages that load more content when you reach the bottom. Gaffa will keep scrolling as the page grows.
* Use `max_scroll_time` to stop an infinite scroll after a set time. It stops the action without failing it.
* Match the speed to the site: `instant` when there's no rate limiting, `slow` when the site throttles fast scrolling, and `instant` with a large `interval` when limits are strict.
* Use [`selector`](/docs/features/browser-requests/selectors.md) to scroll inside a modal or side panel, since scrolling the page body won't move them.
* Add [`block_dom_removals`](/docs/features/browser-requests/actions/block-dom-removals.md) first if the site drops rows as you scroll past them.
* `percentage` is a position on the page, not a distance. 50 takes you halfway down, 100 to the bottom.
* Plan your `percentage` values in ascending order across a request. Once you've scrolled to `100%`, asking for `50%` won't take you back — there's no way to scroll up within a request.
* 0 and values lower than the current position are accepted but do nothing, because scroll only moves forward.

</details>

### Parameters

<table data-full-width="false"><thead><tr><th width="215">Name</th><th width="130">Type</th><th width="108" data-type="checkbox">Required</th><th>Description</th></tr></thead><tbody><tr><td><code>percentage</code></td><td><code>integer</code></td><td>true</td><td><p>How far down the page to scroll, as a target position rather than a distance. Scrolling only moves forward — see the tip above.</p><p><strong>Range: [0 - 100]</strong><br><strong>Default: 100 (% - scroll to bottom)</strong></p></td></tr><tr><td><code>wait_time</code></td><td>integer</td><td>false</td><td>After arriving at the desired scroll location, the time Gaffa should monitor for changes in the page height before marking the action as successful. Read more <a href="#wait-time">below</a>.<br><strong>Default: 0</strong></td></tr><tr><td><code>max_scroll_time</code></td><td><code>integer</code></td><td>false</td><td>The maximum amount of time the page should be scrolled for, in milliseconds. After this time passes, the action will be cancelled. This doesn't cause the action to fail.<br><strong>Default: 20,000 (20s)</strong><br></td></tr><tr><td><code>scroll_speed</code></td><td><code>string</code></td><td>false</td><td>The speed which the page should scroll to the desired point. You can read more about this <a href="#scroll-speed">below</a>.<br><strong>Default:</strong> <code>medium</code><br><strong>Accepted</strong>: [<code>slow</code>, <code>medium</code>, <code>instant</code>]</td></tr><tr><td><code>interval</code></td><td><code>integer</code></td><td>false</td><td>The amount of time, in milliseconds, that scrolling should pause between scroll events. Read more about this <a href="#scroll-speed-and-interval">below</a>.<br><strong>Default</strong>: 0</td></tr><tr><td><code>timeout</code></td><td><code>integer</code></td><td>false</td><td>The maximum amount of time Gaffa will wait for the page to become scrollable <br><strong>Default: 0</strong></td></tr><tr><td><code>selector</code></td><td><code>string</code></td><td>false</td><td>The <a href="/docs/features/browser-requests/selectors.md">selector</a> that identifies the element to scroll. If not provided, the page body will be scrolled.</td></tr></tbody></table>

See [universal parameters](/docs/features/browser-requests/actions.md#universal-parameters).

### Scroll Speed & Interval

Gaffa gives you flexibility over how fast you scroll down the page, which can be really useful to get around restrictions enforced by some sites that detect and limit fast scrolling. By experimenting with `scroll_speed` and `interval`, you will be able to create the perfect scrolling action for your scenario. The speed settings are as follows:

* `instant`- The page will smoothly scroll to the desired position immediately, useful for sites with no rate limits or loading events caused by scroll actions.
* `medium` - Human-like scrolling at a normal speed to the desired position. Gaffa will scroll in much the same way as you would using a mouse.
* `slow`- Human-like scrolling at a very slow speed to the desired position. The speed is comparable to scrolling while reading a page.

`interval`allows you to adjust the scroll speed further by inserting pauses between scroll events.

{% hint style="info" %}
We've found some sites with infinite scrolling and strict rate limits respond better to `instant` speed scroll events to the bottom of the page with large `intervals` between these scrolls to keep within rate limits.
{% endhint %}

### Wait Time

If `wait_time` is set to 0, and Gaffa arrives at the desired location, then Gaffa will immediately mark the action as succeeded. However, if another value is set, the page will be monitored for the specified duration to check for further expansions. If, during this period, the page expands again, then Gaffa will continue scrolling to the desired location, and the wait will reset.

{% hint style="info" %}
This can be really useful if you find that the site takes some time to load additional items when you reach the bottom of the page, and more items load after the action has succeeded.
{% endhint %}

### Usage

#### Scroll a particular percentage down the page

The following code will scroll halfway down the page.

```json
"actions": [
      {
        "type": "scroll",
        "percentage": 50
      }
]
```

#### Scroll an infinitely scrolling webpage

The following code will scroll to the bottom of the page and then keep scrolling when new content loads for a maximum of 25 seconds, waiting 1 second for new content and scrolling at a slow pace with 1 second between scroll actions.

```json
"actions": [
      {
        "type": "scroll",
        "percentage": 100,
        "scroll_speed": "slow",
        "max_scroll_time": 25000,
        "interval": 1000,
        "wait_time": 1000
      }
]
```

### Read more

<table data-view="cards"><thead><tr><th></th><th data-hidden data-card-target data-type="content-ref"></th><th data-hidden data-card-cover data-type="image">Cover image</th></tr></thead><tbody><tr><td>How to Handle Infinite Scrolling and Dynamic Loading with Gaffa’s Scroll Action</td><td><a href="https://gaffa.dev/blog/how-to-handle-infinite-scrolling-and-dynamic-loading-with-gaffas-scroll-action">https://gaffa.dev/blog/how-to-handle-infinite-scrolling-and-dynamic-loading-with-gaffas-scroll-action</a></td><td><a href="https://2341007864-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyUba6osOT5MkKiV0wmgr%2Fuploads%2F8CL05BsikQX2AP0xfEDT%2Fscroll_illustration_1920x1080_V4.jpg?alt=media&amp;token=893fae8e-abc6-45a7-863d-34b8a344f1ba">scroll_illustration_1920x1080_V4.jpg</a></td></tr></tbody></table>

### FAQs

#### When do I use scroll action?

Use it when content loads as you move down the page, when you need to reach something further down before clicking it, or when images only load once they're on screen.

#### How do I scrape an infinite scroll page?

Use a `scroll` action with `"percentage": 100`, a `wait_time` so Gaffa keeps going as new content loads, and a `max_scroll_time` to stop it after a set period.

#### What does wait\_time do?

After reaching the position you asked for, Gaffa watches the page for that duration to see if it grows. If it does, scrolling continues, and the wait starts again, until the page stops growing.

#### What does max\_scroll\_time do?

It sets the maximum duration the scroll can run, defaulting to 20 seconds. When that time is up, the action stops. It doesn't fail, so the rest of your actions still run.

#### Which scroll speed should I use?

Use `instant` when the site has no rate limits, `medium` for normal human-like scrolling, and `slow` for sites that throttle fast scrolling. For strict limits, use `instant` with a large `interval`.

#### Can I scroll back up a page with Gaffa?

No. `percentage` sets a target position, and scrolling only moves forward, so once you've reached a point, requesting a lower value does nothing. Order your `scroll` actions from smallest to largest across a request.

#### What does the percentage parameter actually scroll to?

It's a target position on the page, not a fixed point at the bottom. `"percentage": 50` scrolls to the halfway mark from wherever the page currently is, as long as that's further down than the current position.

#### How do I scroll inside a modal or side panel?

Set [`selector`](/docs/features/browser-requests/selectors.md) to the element that scrolls. Without it, Gaffa scrolls the page body, which does nothing when the scrollable part is a panel inside the page.

#### Why does my capture only show the last few rows?

The site is removing rows as they scroll out of view. Add a [`block_dom_removals`](/docs/features/browser-requests/actions/block-dom-removals.md) action before the scroll so every loaded row stays on the page.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://gaffa.dev/docs/features/browser-requests/actions/scroll.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
