title |
---|
document |
Get the window.document
of the page that is currently active.
cy.document()
cy.document(options)
{% fa fa-check-circle green %} Correct Usage
cy.document() // yield the window.document object
{% fa fa-angle-right %} options (Object)
Pass in an options object to change the default behavior of cy.document()
.
Option | Default | Description |
---|---|---|
log |
true |
{% usage_options log %} |
timeout |
{% url defaultCommandTimeout configuration#Timeouts %} |
{% usage_options timeout cy.document %} |
{% yields sets_subject cy.document 'yields the window.document
object' %}
cy.document().then((doc) => {
// work with document element
})
cy.document().its('contentType').should('eq', 'text/html')
{% requirements parent cy.document %}
{% assertions retry cy.document %}
{% timeouts assertions cy.document %}
Get the document
cy.document()
The command above will display in the Command Log as:
{% imgTag /img/api/document/get-document-of-application-in-command-log.png "Command log document" %}
When clicking on document
within the command log, the console outputs the following:
{% imgTag /img/api/document/console-yields-the-document-of-aut.png "console.log document" %}
- {% url
cy.window()
window %} - {% url 'Cypress
should
callback' https://glebbahmutov.com/blog/cypress-should-callback/ %}