Skip to main content
Cypress App

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

OptionDefaultDescription
logtrueDisplays the command in the Command log
timeoutdefaultCommandTimeoutTime to wait for cy.title() to resolve before timing out

Yields Learn about subject management​

  • cy.title() 'yields the document.title property of the current page.
  • cy.title() is a query, and it is safe to chain further commands.

Examples​

No Args​

Assert that the document's title is "My Awesome Application"​

cy.title().should('eq', 'My Awesome Application')

Rules​

Requirements Learn about chaining commands​

  • cy.title() requires being chained off of cy.

Assertions Learn about assertions​

  • cy.title() will automatically retry until all chained assertions have passed

Timeouts Learn about 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:

Command Log title

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

Console Log title

History​

VersionChanges
< 0.3.3cy.title() command added

See also​