Get the document.title property of the page that is currently active.
cy.title()
cy.title(options)
Correct Usage
cy.title() // Yields the documents title as a string
options (Object)
Pass in an options object to change the default behavior of cy.title().
| Option | Default | Description |
|---|---|---|
log |
true |
Displays the command in the Command log |
timeout |
defaultCommandTimeout |
Time to wait for cy.title() to resolve before timing out
|
cy.title() 'yields the document.title property of the current page' cy.title().should('eq', 'My Awesome Application')
cy.title() requires being chained off of cy . cy.title() will automatically retry until all chained assertions have passed cy.title() can time out waiting for assertions you've added to pass. Assert that the document's title includes 'New User'
cy.title().should('include', 'New User')
The commands above will display in the Command Log as:
When clicking on title within the command log, the console outputs the following:
| Version | Changes |
|---|---|
| < 0.3.3 |
cy.title() command added |
© 2017 Cypress.io
Licensed under the MIT License.
https://docs.cypress.io/api/commands/title