Files
cypress/docs/source/api/commands/document.md
T
2017-05-24 16:56:23 -04:00

1.6 KiB

title, comments, description
title comments description
document true

Get the document.

Syntax

.document()
.document(options)

Usage

.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()    

Arguments

{% fa fa-angle-right %} options (Object)

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

Option Default Notes
log true whether to display command in command log

Yields

.as() yields the window.document object.

Timeout

.document() will retry for the duration of the defaultCommandTimeout

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:

screen shot 2015-11-29 at 2 00 09 pm

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

screen shot 2015-11-29 at 2 00 22 pm

See also