{
  "doc": {
    "id": "api/commands/go",
    "title": "go | Cypress Documentation",
    "description": "Navigate back or forward to the previous or next URL in the browser's history in Cypress.",
    "section": "api",
    "source_path": "/llm/markdown/api/commands/go.md",
    "version": "e6988a974973e9090ce70406c38cb2b9e0eac9fa",
    "updated_at": "2026-05-15T15:50:22.536Z",
    "headings": [
      {
        "id": "api/commands/go#go",
        "text": "go",
        "level": 1
      },
      {
        "id": "api/commands/go#syntax",
        "text": "Syntax",
        "level": 2
      },
      {
        "id": "api/commands/go#usage",
        "text": "Usage",
        "level": 3
      },
      {
        "id": "api/commands/go#arguments",
        "text": "Arguments",
        "level": 3
      },
      {
        "id": "api/commands/go#yields-learn-about-subject-management",
        "text": "Yields Learn about subject management",
        "level": 3
      },
      {
        "id": "api/commands/go#examples",
        "text": "Examples",
        "level": 2
      },
      {
        "id": "api/commands/go#direction",
        "text": "Direction",
        "level": 3
      },
      {
        "id": "api/commands/go#go-back-in-browsers-history",
        "text": "Go back in browser's history",
        "level": 4
      },
      {
        "id": "api/commands/go#go-forward-in-browsers-history",
        "text": "Go forward in browser's history",
        "level": 4
      },
      {
        "id": "api/commands/go#number",
        "text": "Number",
        "level": 3
      },
      {
        "id": "api/commands/go#go-back-in-browsers-history",
        "text": "Go back in browser's history",
        "level": 4
      },
      {
        "id": "api/commands/go#go-forward-in-browsers-history",
        "text": "Go forward in browser's history",
        "level": 4
      },
      {
        "id": "api/commands/go#notes",
        "text": "Notes",
        "level": 2
      },
      {
        "id": "api/commands/go#refreshing-and-loading-the-page",
        "text": "Refreshing and loading the page",
        "level": 3
      },
      {
        "id": "api/commands/go#rules",
        "text": "Rules",
        "level": 2
      },
      {
        "id": "api/commands/go#requirements-learn-about-chaining-commands",
        "text": "Requirements Learn about chaining commands",
        "level": 3
      },
      {
        "id": "api/commands/go#assertions-learn-about-assertions",
        "text": "Assertions Learn about assertions",
        "level": 3
      },
      {
        "id": "api/commands/go#timeouts-learn-about-timeouts",
        "text": "Timeouts Learn about timeouts",
        "level": 3
      },
      {
        "id": "api/commands/go#command-log",
        "text": "Command Log",
        "level": 2
      },
      {
        "id": "api/commands/go#see-also",
        "text": "See also",
        "level": 2
      }
    ]
  },
  "chunks": [
    {
      "id": "api/commands/go#syntax",
      "doc_id": "api/commands/go",
      "heading": "Syntax",
      "heading_level": 2,
      "content_markdown": "## Syntax\n\n```\ncy.go(direction)cy.go(direction, options)\n```\n\n### Usage\n\n**Correct Usage**\n\n```\ncy.go('back')\n```\n\n### Arguments\n\n**direction _(String, Number)_**\n\nThe direction to navigate.\n\nYou can use `back` or `forward` to go one step back or forward. You could also navigate to a specific history position (`-1` goes back one page, `1` goes forward one page, etc).\n\n**options _(Object)_**\n\nPass in an options object to change the default behavior of `cy.go()`.\n\n| Option | Default | Description |\n| --- | --- | --- |\n| `log` | `true` | Displays the command in the [Command log](/llm/markdown/app/core-concepts/open-mode.md#Command-Log) |\n| `timeout` | [`pageLoadTimeout`](/llm/markdown/app/references/configuration.md#Timeouts) | Time to wait for `cy.go()` 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*   `cy.go()` yields the `window` object after the page finishes loading.\n*   It is [unsafe](/llm/markdown/app/core-concepts/retry-ability.md#Only-queries-are-retried) to chain further commands that rely on the yielded `window` after `cy.go()`.\n",
      "section": "api",
      "anchors": [
        "syntax"
      ],
      "path": "/llm/json/chunked/api/commands/go.json",
      "token_estimate": 193
    },
    {
      "id": "api/commands/go#arguments",
      "doc_id": "api/commands/go",
      "heading": "Arguments",
      "heading_level": 3,
      "content_markdown": "### Arguments\n\n**direction _(String, Number)_**\n\nThe direction to navigate.\n\nYou can use `back` or `forward` to go one step back or forward. You could also navigate to a specific history position (`-1` goes back one page, `1` goes forward one page, etc).\n\n**options _(Object)_**\n\nPass in an options object to change the default behavior of `cy.go()`.\n\n| Option | Default | Description |\n| --- | --- | --- |\n| `log` | `true` | Displays the command in the [Command log](/llm/markdown/app/core-concepts/open-mode.md#Command-Log) |\n| `timeout` | [`pageLoadTimeout`](/llm/markdown/app/references/configuration.md#Timeouts) | Time to wait for `cy.go()` to resolve before [timing out](#Timeouts) |\n",
      "section": "api",
      "anchors": [
        "arguments"
      ],
      "path": "/llm/json/chunked/api/commands/go.json",
      "token_estimate": 132
    },
    {
      "id": "api/commands/go#yields-learn-about-subject-management",
      "doc_id": "api/commands/go",
      "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*   `cy.go()` yields the `window` object after the page finishes loading.\n*   It is [unsafe](/llm/markdown/app/core-concepts/retry-ability.md#Only-queries-are-retried) to chain further commands that rely on the yielded `window` after `cy.go()`.\n",
      "section": "api",
      "anchors": [
        "yields-learn-about-subject-management"
      ],
      "path": "/llm/json/chunked/api/commands/go.json",
      "token_estimate": 44
    },
    {
      "id": "api/commands/go#examples",
      "doc_id": "api/commands/go",
      "heading": "Examples",
      "heading_level": 2,
      "content_markdown": "## Examples\n\n### Direction\n\n#### Go back in browser's history\n\n```\ncy.go('back') // equivalent to clicking back button\n```\n\n#### Go forward in browser's history\n\n```\ncy.go('forward') // equivalent to clicking forward button\n```\n\n### Number\n\n#### Go back in browser's history\n\n```\ncy.go(-1) // equivalent to clicking back button\n```\n\n#### Go forward in browser's history\n\n```\ncy.go(1) // equivalent to clicking forward button\n```\n",
      "section": "api",
      "anchors": [
        "examples"
      ],
      "path": "/llm/json/chunked/api/commands/go.json",
      "token_estimate": 88
    },
    {
      "id": "api/commands/go#direction",
      "doc_id": "api/commands/go",
      "heading": "Direction",
      "heading_level": 3,
      "content_markdown": "### Direction\n\n#### Go back in browser's history\n\n```\ncy.go('back') // equivalent to clicking back button\n```\n\n#### Go forward in browser's history\n\n```\ncy.go('forward') // equivalent to clicking forward button\n```\n",
      "section": "api",
      "anchors": [
        "direction"
      ],
      "path": "/llm/json/chunked/api/commands/go.json",
      "token_estimate": 43
    },
    {
      "id": "api/commands/go#number",
      "doc_id": "api/commands/go",
      "heading": "Number",
      "heading_level": 3,
      "content_markdown": "### Number\n\n#### Go back in browser's history\n\n```\ncy.go(-1) // equivalent to clicking back button\n```\n\n#### Go forward in browser's history\n\n```\ncy.go(1) // equivalent to clicking forward button\n```\n",
      "section": "api",
      "anchors": [
        "number"
      ],
      "path": "/llm/json/chunked/api/commands/go.json",
      "token_estimate": 43
    },
    {
      "id": "api/commands/go#notes",
      "doc_id": "api/commands/go",
      "heading": "Notes",
      "heading_level": 2,
      "content_markdown": "## Notes\n\n### Refreshing and loading the page\n\nIf going forward or back causes a full page refresh, Cypress will wait for the new page to load before moving on to new commands.\n\nCypress additionally handles situations where a page load was not caused (such as hash routing) and will resolve immediately.\n",
      "section": "api",
      "anchors": [
        "notes"
      ],
      "path": "/llm/json/chunked/api/commands/go.json",
      "token_estimate": 69
    },
    {
      "id": "api/commands/go#refreshing-and-loading-the-page",
      "doc_id": "api/commands/go",
      "heading": "Refreshing and loading the page",
      "heading_level": 3,
      "content_markdown": "### Refreshing and loading the page\n\nIf going forward or back causes a full page refresh, Cypress will wait for the new page to load before moving on to new commands.\n\nCypress additionally handles situations where a page load was not caused (such as hash routing) and will resolve immediately.\n",
      "section": "api",
      "anchors": [
        "refreshing-and-loading-the-page"
      ],
      "path": "/llm/json/chunked/api/commands/go.json",
      "token_estimate": 67
    },
    {
      "id": "api/commands/go#rules",
      "doc_id": "api/commands/go",
      "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*   `cy.go()` requires being chained off of `cy`.\n*   `cy.go()` requires the response to be `content-type: text/html`.\n*   `cy.go()` requires the response code to be `2xx` after following redirects.\n*   `cy.go()` requires the load `load` event to eventually fire.\n\n### Assertions [Learn about assertions](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Assertions)\n\n*   `cy.go()` will automatically wait for assertions you have chained to pass.\n\n### Timeouts [Learn about timeouts](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Timeouts)\n\n*   `cy.go()` can time out waiting for the page to fire its `load` event.\n*   `cy.go()` can time out waiting for assertions you've added to pass.\n",
      "section": "api",
      "anchors": [
        "rules"
      ],
      "path": "/llm/json/chunked/api/commands/go.json",
      "token_estimate": 127
    },
    {
      "id": "api/commands/go#requirements-learn-about-chaining-commands",
      "doc_id": "api/commands/go",
      "heading": "Requirements Learn about chaining commands",
      "heading_level": 3,
      "content_markdown": "### Requirements [Learn about chaining commands](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Chains-of-Commands)\n\n*   `cy.go()` requires being chained off of `cy`.\n*   `cy.go()` requires the response to be `content-type: text/html`.\n*   `cy.go()` requires the response code to be `2xx` after following redirects.\n*   `cy.go()` requires the load `load` event to eventually fire.\n",
      "section": "api",
      "anchors": [
        "requirements-learn-about-chaining-commands"
      ],
      "path": "/llm/json/chunked/api/commands/go.json",
      "token_estimate": 60
    },
    {
      "id": "api/commands/go#timeouts-learn-about-timeouts",
      "doc_id": "api/commands/go",
      "heading": "Timeouts Learn about timeouts",
      "heading_level": 3,
      "content_markdown": "### Timeouts [Learn about timeouts](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Timeouts)\n\n*   `cy.go()` can time out waiting for the page to fire its `load` event.\n*   `cy.go()` can time out waiting for assertions you've added to pass.\n",
      "section": "api",
      "anchors": [
        "timeouts-learn-about-timeouts"
      ],
      "path": "/llm/json/chunked/api/commands/go.json",
      "token_estimate": 41
    },
    {
      "id": "api/commands/go#command-log",
      "doc_id": "api/commands/go",
      "heading": "Command Log",
      "heading_level": 2,
      "content_markdown": "## Command Log\n\n**_Go back in browser's history_**\n\n```\ncy.visit('http://localhost:8000/folders').go('back')\n```\n\nThe commands above will display in the Command Log as:\n\nWhen clicking on the `go` command within the command log, the console outputs the following:\n",
      "section": "api",
      "anchors": [
        "command-log"
      ],
      "path": "/llm/json/chunked/api/commands/go.json",
      "token_estimate": 48
    }
  ]
}