---
id: api/commands/document
title: document | Cypress Documentation
description: Get the `window.document` of the page that is currently active.
section: api
source_path: docs/api/commands/document.mdx
version: 29b099a83033817a9072f7deec58409720b52bc4
updated_at: '2026-05-03T15:21:58.370Z'
---
# document

Get the `window.document` of the page that is currently active.

## Syntax

```
cy.document()cy.document(options)
```

### Usage

**Correct Usage**

```
cy.document() // yield the window.document object
```

### Arguments

**options _(Object)_**

Pass in an options object to change the default behavior of `cy.document()`.

| Option | Default | Description |
| --- | --- | --- |
| `log` | `true` | Displays the command in the [Command log](/llm/markdown/app/core-concepts/open-mode.md#Command-Log) |
| `timeout` | [`defaultCommandTimeout`](/llm/markdown/app/references/configuration.md#Timeouts) | Time to wait for `cy.document()` to resolve before [timing out](#Timeouts) |

### Yields [Learn about subject management](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Subject-Management)

*   `cy.document()` 'yields the `window.document` object.
*   `cy.document()` is a query, and it is _safe_ to chain further commands.

## Examples

### No Args

#### Get document and do some work

```
cy.document().then((doc) => {  // work with document element})
```

#### Make an assertion about the document

```
cy.document().its('contentType').should('eq', 'text/html')
```

## Rules

### Requirements [Learn about chaining commands](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Chains-of-Commands)

*   `cy.document()` requires being chained off of `cy`.

### Assertions [Learn about assertions](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Assertions)

*   `cy.document()` will automatically [retry](/llm/markdown/app/core-concepts/retry-ability.md) until all chained assertions have passed

### Timeouts [Learn about timeouts](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Timeouts)

*   `cy.document()` can time out waiting for assertions you've added to pass.

## Command Log

**_Get the document_**

```
cy.document()
```

The command above will display in the Command Log as:

When clicking on `document` within the command log, the console outputs the following:

## See also

*   [`cy.window()`](/llm/markdown/api/commands/window.md)
