Get the window.document of the page that is currently active.
cy.document()
cy.document(options)
Correct Usage
cy.document() // yield the window.document object
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 |
timeout |
defaultCommandTimeout |
Time to wait for cy.document() to resolve before timing out
|
cy.document() 'yields the window.document object' cy.document().then((doc) => {
// work with document element
})
cy.document().its('contentType').should('eq', 'text/html')
cy.document() requires being chained off of cy . cy.document() will automatically retry until all chained assertions have passed cy.document() can time out waiting for assertions you've added to pass. 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:
© 2017 Cypress.io
Licensed under the MIT License.
https://docs.cypress.io/api/commands/document