Skip to main content

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

  • `cy.title()` 'yields the `document.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 of `cy`.

Assertions

  • `cy.title()` will automatically [retry](/guides/core-concepts/retry-ability) 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:

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