{
  "doc": {
    "id": "api/commands/document",
    "title": "document | Cypress Documentation",
    "description": "Get the `window.document` of the page that is currently active.",
    "section": "api",
    "source_path": "/llm/markdown/api/commands/document.md",
    "version": "e6988a974973e9090ce70406c38cb2b9e0eac9fa",
    "updated_at": "2026-05-15T15:50:22.536Z",
    "headings": [
      {
        "id": "api/commands/document#document",
        "text": "document",
        "level": 1
      },
      {
        "id": "api/commands/document#syntax",
        "text": "Syntax",
        "level": 2
      },
      {
        "id": "api/commands/document#usage",
        "text": "Usage",
        "level": 3
      },
      {
        "id": "api/commands/document#arguments",
        "text": "Arguments",
        "level": 3
      },
      {
        "id": "api/commands/document#yields-learn-about-subject-management",
        "text": "Yields Learn about subject management",
        "level": 3
      },
      {
        "id": "api/commands/document#examples",
        "text": "Examples",
        "level": 2
      },
      {
        "id": "api/commands/document#no-args",
        "text": "No Args",
        "level": 3
      },
      {
        "id": "api/commands/document#get-document-and-do-some-work",
        "text": "Get document and do some work",
        "level": 4
      },
      {
        "id": "api/commands/document#make-an-assertion-about-the-document",
        "text": "Make an assertion about the document",
        "level": 4
      },
      {
        "id": "api/commands/document#rules",
        "text": "Rules",
        "level": 2
      },
      {
        "id": "api/commands/document#requirements-learn-about-chaining-commands",
        "text": "Requirements Learn about chaining commands",
        "level": 3
      },
      {
        "id": "api/commands/document#assertions-learn-about-assertions",
        "text": "Assertions Learn about assertions",
        "level": 3
      },
      {
        "id": "api/commands/document#timeouts-learn-about-timeouts",
        "text": "Timeouts Learn about timeouts",
        "level": 3
      },
      {
        "id": "api/commands/document#command-log",
        "text": "Command Log",
        "level": 2
      },
      {
        "id": "api/commands/document#see-also",
        "text": "See also",
        "level": 2
      }
    ]
  },
  "chunks": [
    {
      "id": "api/commands/document#syntax",
      "doc_id": "api/commands/document",
      "heading": "Syntax",
      "heading_level": 2,
      "content_markdown": "## Syntax\n\n```\ncy.document()cy.document(options)\n```\n\n### Usage\n\n**Correct Usage**\n\n```\ncy.document() // yield the window.document object\n```\n\n### Arguments\n\n**options _(Object)_**\n\nPass in an options object to change the default behavior of `cy.document()`.\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` | [`defaultCommandTimeout`](/llm/markdown/app/references/configuration.md#Timeouts) | Time to wait for `cy.document()` 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.document()` 'yields the `window.document` object.\n*   `cy.document()` is a query, and it is _safe_ to chain further commands.\n",
      "section": "api",
      "anchors": [
        "syntax"
      ],
      "path": "/llm/json/chunked/api/commands/document.json",
      "token_estimate": 135
    },
    {
      "id": "api/commands/document#arguments",
      "doc_id": "api/commands/document",
      "heading": "Arguments",
      "heading_level": 3,
      "content_markdown": "### Arguments\n\n**options _(Object)_**\n\nPass in an options object to change the default behavior of `cy.document()`.\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` | [`defaultCommandTimeout`](/llm/markdown/app/references/configuration.md#Timeouts) | Time to wait for `cy.document()` to resolve before [timing out](#Timeouts) |\n",
      "section": "api",
      "anchors": [
        "arguments"
      ],
      "path": "/llm/json/chunked/api/commands/document.json",
      "token_estimate": 79
    },
    {
      "id": "api/commands/document#examples",
      "doc_id": "api/commands/document",
      "heading": "Examples",
      "heading_level": 2,
      "content_markdown": "## Examples\n\n### No Args\n\n#### Get document and do some work\n\n```\ncy.document().then((doc) => {  // work with document element})\n```\n\n#### Make an assertion about the document\n\n```\ncy.document().its('contentType').should('eq', 'text/html')\n```\n",
      "section": "api",
      "anchors": [
        "examples"
      ],
      "path": "/llm/json/chunked/api/commands/document.json",
      "token_estimate": 44
    },
    {
      "id": "api/commands/document#no-args",
      "doc_id": "api/commands/document",
      "heading": "No Args",
      "heading_level": 3,
      "content_markdown": "### No Args\n\n#### Get document and do some work\n\n```\ncy.document().then((doc) => {  // work with document element})\n```\n\n#### Make an assertion about the document\n\n```\ncy.document().its('contentType').should('eq', 'text/html')\n```\n",
      "section": "api",
      "anchors": [
        "no-args"
      ],
      "path": "/llm/json/chunked/api/commands/document.json",
      "token_estimate": 41
    },
    {
      "id": "api/commands/document#rules",
      "doc_id": "api/commands/document",
      "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.document()` requires being chained off of `cy`.\n\n### Assertions [Learn about assertions](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Assertions)\n\n*   `cy.document()` will automatically [retry](/llm/markdown/app/core-concepts/retry-ability.md) until all chained assertions have passed\n\n### Timeouts [Learn about timeouts](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Timeouts)\n\n*   `cy.document()` can time out waiting for assertions you've added to pass.\n",
      "section": "api",
      "anchors": [
        "rules"
      ],
      "path": "/llm/json/chunked/api/commands/document.json",
      "token_estimate": 65
    },
    {
      "id": "api/commands/document#command-log",
      "doc_id": "api/commands/document",
      "heading": "Command Log",
      "heading_level": 2,
      "content_markdown": "## Command Log\n\n**_Get the document_**\n\n```\ncy.document()\n```\n\nThe command above will display in the Command Log as:\n\nWhen clicking on `document` within the command log, the console outputs the following:\n",
      "section": "api",
      "anchors": [
        "command-log"
      ],
      "path": "/llm/json/chunked/api/commands/document.json",
      "token_estimate": 43
    }
  ]
}