Skip to main content
Cypress App
caution
Deprecated

.end() was deprecated in Cypress 15.15.0 and will be removed in a future major version.

Instead of using .end() to break a chain, start a new chain of commands off of cy:

Before
cy.get('#user-cheryl').click().end().get('#user-charles').click()
After
cy.get('#user-cheryl').click()
cy.get('#user-charles').click()

end

End a chain of commands.

Syntax​

.end()

Usage​

Correct Usage

cy.get('ul').end() // Yield 'null' instead of 'ul' element

Incorrect Usage

cy.end()

Yields Learn about subject management​

  • .end() yields null.

Examples​

.end() is useful when you want to end a chain of commands and force the next command to not receive what was yielded in the previous command.

cy.get('#user-cheryl')
.click()
.end() // yield null
.get('#user-charles')
.click() // get looks for the element in the document now

Alternatively, you can always start a new chain of commands off of cy.

cy.get('#user-cheryl').click()
cy.get('#user-charles').click() // get looks for the element in the document now

Rules​

Requirements Learn about chaining commands​

  • .end() requires being chained off a previous command.

Assertions Learn about assertions​

  • .end() cannot have any assertions chained.

Timeouts Learn about timeouts​

  • .end() cannot time out.

Command Log​

  • .end() does not log in the Command Log

See also​