To end the command chain, use the cy.end() command.
cy
.get('.misc-table').within(function(){
cy
// ends the current chain and returns null
.contains("Cheryl").click().end()
// queries the entire table again
.contains("Charles").click()
})
| Table |
|---|
| User: Cheryl |
| User: Charles |
| User: Darryl |
To get the DOM element that has focus, use the cy.focused() command.
cy
.get('.misc-form').find('#name').click()
.focused().should('have.id', 'name')
.get('.misc-form').find('#description').click()
.focused().should('have.id', 'description')
To wrap an object, use the cy.wrap() command.
cy
.wrap({foo: 'bar'})
.should('have.property', 'foo')
.and('include', 'bar')
{foo: bar}