---
id: api/commands/document
title: cy.document()
description: Get the window.document of the page that is currently active.
section: api
source_path: docs/api/commands/document.mdx
version: 3163d68b20e695f2c76d40c85c3f3b956dd19a3b
updated_at: '2026-08-21T20:59:04.402Z'
---
# 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

*   `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

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

### Assertions

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

### 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)
