title
Get the document.title
property of the page that is currently active.
Syntax
cy.title()
cy.title(options)
Usage
Correct Usage
cy.title() // Yields the documents title as a string
Arguments
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 |
Yields
-
cy.title()
'yields thedocument.title
property of the current page'
Examples
No Args
Assert that the document's title is "My Awesome Application"
cy.title().should('eq', 'My Awesome Application')
Rules
Requirements
-
cy.title()
requires being chained off ofcy
.
Assertions
-
cy.title()
will automatically retry until all chained assertions have passed
Timeouts
-
cy.title()
can time out waiting for assertions you've added to pass.
Command Log
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:
History
Version | Changes |
---|---|
< 0.3.3 | cy.title() command added |