mirror of
https://github.com/cypress-io/cypress.git
synced 2026-05-19 14:49:43 -05:00
f947e0c55d
# Conflicts: # docs/source/guides/getting-started/installing-cypress.md
1.6 KiB
1.6 KiB
title, comments
| title | comments |
|---|---|
| document | false |
Get the document.
Syntax
cy.document()
cy.document(options)
Usage
cy.document() cannot be chained off any other cy commands, so should be chained off of cy for clarity.
{% fa fa-check-circle green %} Valid Usage
cy.document() // yield the window.document object
Arguments
{% fa fa-angle-right %} options (Object)
Pass in an options object to change the default behavior of cy.document().
| Option | Default | Notes |
|---|---|---|
log |
true |
Whether to display command in Command Log |
Yields
cy.document() yields the window.document object.
Timeout
cy.document() will retry for the duration of the {% url defaultCommandTimeout configuration#Timeouts %}.
Examples
Document
Get document and do some work
cy.document().then(function(document) {
// work with document element
})
Make an assertion about the document
cy.document().its('contentType').should('eq', 'text/html')
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
- {% url
cy.window()window %}