{
  "doc": {
    "id": "api/commands/scrollto",
    "title": "scrollTo | Cypress Documentation",
    "description": "Scroll to a specific position in the window or element in Cypress.",
    "section": "api",
    "source_path": "/llm/markdown/api/commands/scrollto.md",
    "version": "a8fd16711bdda4c7b5645b9717e588ae99ec2470",
    "updated_at": "2026-05-18T17:21:32.047Z",
    "headings": [
      {
        "id": "api/commands/scrollto#scrollto",
        "text": "scrollTo",
        "level": 1
      },
      {
        "id": "api/commands/scrollto#syntax",
        "text": "Syntax",
        "level": 2
      },
      {
        "id": "api/commands/scrollto#usage",
        "text": "Usage",
        "level": 3
      },
      {
        "id": "api/commands/scrollto#arguments",
        "text": "Arguments",
        "level": 3
      },
      {
        "id": "api/commands/scrollto#yields-learn-about-subject-management",
        "text": "Yields Learn about subject management",
        "level": 3
      },
      {
        "id": "api/commands/scrollto#examples",
        "text": "Examples",
        "level": 2
      },
      {
        "id": "api/commands/scrollto#position",
        "text": "Position",
        "level": 3
      },
      {
        "id": "api/commands/scrollto#scroll-to-the-bottom-of-the-window",
        "text": "Scroll to the bottom of the window",
        "level": 4
      },
      {
        "id": "api/commands/scrollto#scroll-to-the-center-of-the-list",
        "text": "Scroll to the center of the list",
        "level": 4
      },
      {
        "id": "api/commands/scrollto#coordinates",
        "text": "Coordinates",
        "level": 3
      },
      {
        "id": "api/commands/scrollto#scroll-500px-down-the-list",
        "text": "Scroll 500px down the list",
        "level": 4
      },
      {
        "id": "api/commands/scrollto#scroll-the-window-500px-to-the-right",
        "text": "Scroll the window 500px to the right",
        "level": 4
      },
      {
        "id": "api/commands/scrollto#scroll-25-down-the-elements-height",
        "text": "Scroll 25% down the element's height",
        "level": 4
      },
      {
        "id": "api/commands/scrollto#options",
        "text": "Options",
        "level": 3
      },
      {
        "id": "api/commands/scrollto#use-linear-easing-animation-to-scroll",
        "text": "Use linear easing animation to scroll",
        "level": 4
      },
      {
        "id": "api/commands/scrollto#scroll-to-the-right-over-2000ms",
        "text": "Scroll to the right over 2000ms",
        "level": 4
      },
      {
        "id": "api/commands/scrollto#do-not-error-if-element-is-not-scrollable",
        "text": "Do not error if element is not scrollable",
        "level": 4
      },
      {
        "id": "api/commands/scrollto#notes",
        "text": "Notes",
        "level": 2
      },
      {
        "id": "api/commands/scrollto#actionability",
        "text": "Actionability",
        "level": 3
      },
      {
        "id": "api/commands/scrollto#scopes",
        "text": "Scopes",
        "level": 3
      },
      {
        "id": "api/commands/scrollto#when-starting-a-series-of-commands",
        "text": "When starting a series of commands:",
        "level": 4
      },
      {
        "id": "api/commands/scrollto#when-chained-to-an-existing-series-of-commands",
        "text": "When chained to an existing series of commands:",
        "level": 4
      },
      {
        "id": "api/commands/scrollto#snapshots",
        "text": "Snapshots",
        "level": 3
      },
      {
        "id": "api/commands/scrollto#snapshots-do-not-reflect-scroll-behavior",
        "text": "Snapshots do not reflect scroll behavior",
        "level": 4
      },
      {
        "id": "api/commands/scrollto#rules",
        "text": "Rules",
        "level": 2
      },
      {
        "id": "api/commands/scrollto#requirements-learn-about-chaining-commands",
        "text": "Requirements Learn about chaining commands",
        "level": 3
      },
      {
        "id": "api/commands/scrollto#timeouts-learn-about-timeouts",
        "text": "Timeouts Learn about timeouts",
        "level": 3
      },
      {
        "id": "api/commands/scrollto#command-log",
        "text": "Command Log",
        "level": 2
      },
      {
        "id": "api/commands/scrollto#history",
        "text": "History",
        "level": 2
      },
      {
        "id": "api/commands/scrollto#see-also",
        "text": "See also",
        "level": 2
      }
    ]
  },
  "chunks": [
    {
      "id": "api/commands/scrollto#syntax",
      "doc_id": "api/commands/scrollto",
      "heading": "Syntax",
      "heading_level": 2,
      "content_markdown": "## Syntax\n\n```\ncy.scrollTo(position)cy.scrollTo(x, y)cy.scrollTo(position, options)cy.scrollTo(x, y, options)  // ---or---  .scrollTo(position)  .scrollTo(x, y)  .scrollTo(position, options)  .scrollTo(x, y, options)\n```\n\n### Usage\n\n**Correct Usage**\n\n```\ncy.scrollTo(0, 500) // Scroll the window 500px downcy.get('.sidebar').scrollTo('bottom') // Scroll 'sidebar' to its bottom\n```\n\n**Incorrect Usage**\n\n```\ncy.title().scrollTo('My App') // Errors, 'title' does not yield DOM element\n```\n\n### Arguments\n\n**position _(String)_**\n\nA specified position to scroll the window or element to. Valid positions are `topLeft`, `top`, `topRight`, `left`, `center`, `right`, `bottomLeft`, `bottom`, and `bottomRight`.\n\n**x _(Number, String)_**\n\nThe distance in pixels from window/element's left or percentage of the window/element's width to scroll to.\n\n**y _(Number, String)_**\n\nThe distance in pixels from window/element's top or percentage of the window/element's height to scroll to.\n\n**options _(Object)_**\n\nPass in an options object to change the default behavior of `cy.scrollTo()`.\n\n| Option | Default | Description |\n| --- | --- | --- |\n| `duration` | `0` | Scrolls over the duration (in ms) |\n| `easing` | `swing` | Will scroll with the easing animation |\n| `ensureScrollable` | `true` | Ensure element is scrollable. Error if element cannot scroll. |\n| `log` | `true` | Displays the command in the [Command log](/llm/markdown/app/core-concepts/open-mode.md#Command-Log) |\n| `timeout` | [`defaultCommandTimeout`](/llm/markdown/app/references/configuration.md#Timeouts) | Time to wait for `.scrollTo()` to resolve before [timing out](#Timeouts) |\n\n### Yields [Learn about subject management](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Subject-Management)\n\n*   `.scrollTo()` yields the same subject it was given.\n*   It is [unsafe](/llm/markdown/app/core-concepts/retry-ability.md#Only-queries-are-retried) to chain further commands that rely on the subject after `.scrollTo()`.\n",
      "section": "api",
      "anchors": [
        "syntax"
      ],
      "path": "/llm/json/chunked/api/commands/scrollto.json",
      "token_estimate": 325
    },
    {
      "id": "api/commands/scrollto#usage",
      "doc_id": "api/commands/scrollto",
      "heading": "Usage",
      "heading_level": 3,
      "content_markdown": "### Usage\n\n**Correct Usage**\n\n```\ncy.scrollTo(0, 500) // Scroll the window 500px downcy.get('.sidebar').scrollTo('bottom') // Scroll 'sidebar' to its bottom\n```\n\n**Incorrect Usage**\n\n```\ncy.title().scrollTo('My App') // Errors, 'title' does not yield DOM element\n```\n",
      "section": "api",
      "anchors": [
        "usage"
      ],
      "path": "/llm/json/chunked/api/commands/scrollto.json",
      "token_estimate": 45
    },
    {
      "id": "api/commands/scrollto#arguments",
      "doc_id": "api/commands/scrollto",
      "heading": "Arguments",
      "heading_level": 3,
      "content_markdown": "### Arguments\n\n**position _(String)_**\n\nA specified position to scroll the window or element to. Valid positions are `topLeft`, `top`, `topRight`, `left`, `center`, `right`, `bottomLeft`, `bottom`, and `bottomRight`.\n\n**x _(Number, String)_**\n\nThe distance in pixels from window/element's left or percentage of the window/element's width to scroll to.\n\n**y _(Number, String)_**\n\nThe distance in pixels from window/element's top or percentage of the window/element's height to scroll to.\n\n**options _(Object)_**\n\nPass in an options object to change the default behavior of `cy.scrollTo()`.\n\n| Option | Default | Description |\n| --- | --- | --- |\n| `duration` | `0` | Scrolls over the duration (in ms) |\n| `easing` | `swing` | Will scroll with the easing animation |\n| `ensureScrollable` | `true` | Ensure element is scrollable. Error if element cannot scroll. |\n| `log` | `true` | Displays the command in the [Command log](/llm/markdown/app/core-concepts/open-mode.md#Command-Log) |\n| `timeout` | [`defaultCommandTimeout`](/llm/markdown/app/references/configuration.md#Timeouts) | Time to wait for `.scrollTo()` to resolve before [timing out](#Timeouts) |\n",
      "section": "api",
      "anchors": [
        "arguments"
      ],
      "path": "/llm/json/chunked/api/commands/scrollto.json",
      "token_estimate": 215
    },
    {
      "id": "api/commands/scrollto#yields-learn-about-subject-management",
      "doc_id": "api/commands/scrollto",
      "heading": "Yields Learn about subject management",
      "heading_level": 3,
      "content_markdown": "### Yields [Learn about subject management](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Subject-Management)\n\n*   `.scrollTo()` yields the same subject it was given.\n*   It is [unsafe](/llm/markdown/app/core-concepts/retry-ability.md#Only-queries-are-retried) to chain further commands that rely on the subject after `.scrollTo()`.\n",
      "section": "api",
      "anchors": [
        "yields-learn-about-subject-management"
      ],
      "path": "/llm/json/chunked/api/commands/scrollto.json",
      "token_estimate": 40
    },
    {
      "id": "api/commands/scrollto#examples",
      "doc_id": "api/commands/scrollto",
      "heading": "Examples",
      "heading_level": 2,
      "content_markdown": "## Examples\n\n### Position\n\n#### Scroll to the bottom of the window\n\n```\ncy.scrollTo('bottom')\n```\n\n#### Scroll to the center of the list\n\n```\ncy.get('#movies-list').scrollTo('center')\n```\n\n### Coordinates\n\n#### Scroll 500px down the list\n\n```\ncy.get('#infinite-scroll-list').scrollTo(0, 500)\n```\n\n#### Scroll the window 500px to the right\n\n```\ncy.scrollTo('500px')\n```\n\n#### Scroll 25% down the element's height\n\n```\ncy.get('.user-photo').scrollTo('0%', '25%')\n```\n\n### Options\n\n#### Use linear easing animation to scroll\n\n```\ncy.get('.documentation').scrollTo('top', { easing: 'linear' })\n```\n\n#### Scroll to the right over 2000ms\n\n```\ncy.get('#slider').scrollTo('right', { duration: 2000 })\n```\n\n#### Do not error if element is not scrollable\n\nLet's say we do not know whether our `table` element is scrollable. Sometimes the `table` may be scrollable (with 2,000 rows) and sometimes the `table` may not be scrollable (with 5 rows). You can ignore the error checking to ensure the element is scrollable by passing `ensureScrollable: false`.\n\n```\n// will move on to next command even if table is not scrollablecy.get('table').scrollTo('bottom', { ensureScrollable: false })cy.get('table').find('tr:last-child').should('be.visible')\n```\n",
      "section": "api",
      "anchors": [
        "examples"
      ],
      "path": "/llm/json/chunked/api/commands/scrollto.json",
      "token_estimate": 221
    },
    {
      "id": "api/commands/scrollto#coordinates",
      "doc_id": "api/commands/scrollto",
      "heading": "Coordinates",
      "heading_level": 3,
      "content_markdown": "### Coordinates\n\n#### Scroll 500px down the list\n\n```\ncy.get('#infinite-scroll-list').scrollTo(0, 500)\n```\n\n#### Scroll the window 500px to the right\n\n```\ncy.scrollTo('500px')\n```\n\n#### Scroll 25% down the element's height\n\n```\ncy.get('.user-photo').scrollTo('0%', '25%')\n```\n",
      "section": "api",
      "anchors": [
        "coordinates"
      ],
      "path": "/llm/json/chunked/api/commands/scrollto.json",
      "token_estimate": 45
    },
    {
      "id": "api/commands/scrollto#options",
      "doc_id": "api/commands/scrollto",
      "heading": "Options",
      "heading_level": 3,
      "content_markdown": "### Options\n\n#### Use linear easing animation to scroll\n\n```\ncy.get('.documentation').scrollTo('top', { easing: 'linear' })\n```\n\n#### Scroll to the right over 2000ms\n\n```\ncy.get('#slider').scrollTo('right', { duration: 2000 })\n```\n\n#### Do not error if element is not scrollable\n\nLet's say we do not know whether our `table` element is scrollable. Sometimes the `table` may be scrollable (with 2,000 rows) and sometimes the `table` may not be scrollable (with 5 rows). You can ignore the error checking to ensure the element is scrollable by passing `ensureScrollable: false`.\n\n```\n// will move on to next command even if table is not scrollablecy.get('table').scrollTo('bottom', { ensureScrollable: false })cy.get('table').find('tr:last-child').should('be.visible')\n```\n",
      "section": "api",
      "anchors": [
        "options"
      ],
      "path": "/llm/json/chunked/api/commands/scrollto.json",
      "token_estimate": 141
    },
    {
      "id": "api/commands/scrollto#do-not-error-if-element-is-not-scrollable",
      "doc_id": "api/commands/scrollto",
      "heading": "Do not error if element is not scrollable",
      "heading_level": 4,
      "content_markdown": "#### Do not error if element is not scrollable\n\nLet's say we do not know whether our `table` element is scrollable. Sometimes the `table` may be scrollable (with 2,000 rows) and sometimes the `table` may not be scrollable (with 5 rows). You can ignore the error checking to ensure the element is scrollable by passing `ensureScrollable: false`.\n\n```\n// will move on to next command even if table is not scrollablecy.get('table').scrollTo('bottom', { ensureScrollable: false })cy.get('table').find('tr:last-child').should('be.visible')\n```\n",
      "section": "api",
      "anchors": [
        "do-not-error-if-element-is-not-scrollable"
      ],
      "path": "/llm/json/chunked/api/commands/scrollto.json",
      "token_estimate": 101
    },
    {
      "id": "api/commands/scrollto#notes",
      "doc_id": "api/commands/scrollto",
      "heading": "Notes",
      "heading_level": 2,
      "content_markdown": "## Notes\n\n### Actionability\n\n`cy.scrollTo()` is an \"action command\" that follows all the rules of [Actionability](/llm/markdown/app/core-concepts/interacting-with-elements.md).\n\n### Scopes\n\n`cy.scrollTo()` acts differently whether it's starting a series of commands or being chained off of an existing.\n\n#### When starting a series of commands:\n\nThis scrolls the `window`.\n\n```\ncy.scrollTo('bottom')\n```\n\n#### When chained to an existing series of commands:\n\nThis will scroll the `<#checkout-items>` element.\n\n```\ncy.get('#checkout-items').scrollTo('right')\n```\n\n### Snapshots\n\n#### Snapshots do not reflect scroll behavior\n\n_Cypress does not reflect the accurate scroll positions of any elements within snapshots._ If you want to see the actual scrolling behavior in action, we recommend using [`.pause()`](/llm/markdown/api/commands/pause.md) to walk through each command or [watching the video of the test run](/llm/markdown/app/guides/screenshots-and-videos.md#Videos).\n",
      "section": "api",
      "anchors": [
        "notes"
      ],
      "path": "/llm/json/chunked/api/commands/scrollto.json",
      "token_estimate": 156
    },
    {
      "id": "api/commands/scrollto#scopes",
      "doc_id": "api/commands/scrollto",
      "heading": "Scopes",
      "heading_level": 3,
      "content_markdown": "### Scopes\n\n`cy.scrollTo()` acts differently whether it's starting a series of commands or being chained off of an existing.\n\n#### When starting a series of commands:\n\nThis scrolls the `window`.\n\n```\ncy.scrollTo('bottom')\n```\n\n#### When chained to an existing series of commands:\n\nThis will scroll the `<#checkout-items>` element.\n\n```\ncy.get('#checkout-items').scrollTo('right')\n```\n",
      "section": "api",
      "anchors": [
        "scopes"
      ],
      "path": "/llm/json/chunked/api/commands/scrollto.json",
      "token_estimate": 68
    },
    {
      "id": "api/commands/scrollto#snapshots",
      "doc_id": "api/commands/scrollto",
      "heading": "Snapshots",
      "heading_level": 3,
      "content_markdown": "### Snapshots\n\n#### Snapshots do not reflect scroll behavior\n\n_Cypress does not reflect the accurate scroll positions of any elements within snapshots._ If you want to see the actual scrolling behavior in action, we recommend using [`.pause()`](/llm/markdown/api/commands/pause.md) to walk through each command or [watching the video of the test run](/llm/markdown/app/guides/screenshots-and-videos.md#Videos).\n",
      "section": "api",
      "anchors": [
        "snapshots"
      ],
      "path": "/llm/json/chunked/api/commands/scrollto.json",
      "token_estimate": 67
    },
    {
      "id": "api/commands/scrollto#snapshots-do-not-reflect-scroll-behavior",
      "doc_id": "api/commands/scrollto",
      "heading": "Snapshots do not reflect scroll behavior",
      "heading_level": 4,
      "content_markdown": "#### Snapshots do not reflect scroll behavior\n\n_Cypress does not reflect the accurate scroll positions of any elements within snapshots._ If you want to see the actual scrolling behavior in action, we recommend using [`.pause()`](/llm/markdown/api/commands/pause.md) to walk through each command or [watching the video of the test run](/llm/markdown/app/guides/screenshots-and-videos.md#Videos).\n",
      "section": "api",
      "anchors": [
        "snapshots-do-not-reflect-scroll-behavior"
      ],
      "path": "/llm/json/chunked/api/commands/scrollto.json",
      "token_estimate": 64
    },
    {
      "id": "api/commands/scrollto#rules",
      "doc_id": "api/commands/scrollto",
      "heading": "Rules",
      "heading_level": 2,
      "content_markdown": "## Rules\n\n### Requirements [Learn about chaining commands](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Chains-of-Commands)\n\n*   `.scrollTo()` requires being chained off a command that yields DOM element(s).\n*   `.scrollTo()` requires the element to be scrollable.\n\n### Timeouts [Learn about timeouts](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Timeouts)\n\n*   `.scrollTo()` can time out waiting for assertions you've added to pass.\n",
      "section": "api",
      "anchors": [
        "rules"
      ],
      "path": "/llm/json/chunked/api/commands/scrollto.json",
      "token_estimate": 60
    },
    {
      "id": "api/commands/scrollto#command-log",
      "doc_id": "api/commands/scrollto",
      "heading": "Command Log",
      "heading_level": 2,
      "content_markdown": "## Command Log\n\n**_Scroll to the bottom of the window then scroll the element to the \"right\"_**\n\n```\ncy.scrollTo('bottom')cy.get('#scrollable-horizontal').scrollTo('right')\n```\n\nThe commands above will display in the Command Log as:\n\nWhen clicking on `scrollTo` within the command log, the console outputs the following:\n",
      "section": "api",
      "anchors": [
        "command-log"
      ],
      "path": "/llm/json/chunked/api/commands/scrollto.json",
      "token_estimate": 57
    }
  ]
}