caution
DeprecatedAfter
.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:
cy.get('#user-cheryl').click().end().get('#user-charles').click()
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 ​
.end()yieldsnull.
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 ​
.end()requires being chained off a previous command.
Assertions ​
.end()cannot have any assertions chained.
Timeouts ​
.end()cannot time out.
Command Log​
.end()does not log in the Command Log