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 execute a system command, use the cy.exec()
command.
cy
.exec('echo Jane Lane')
.its('stdout').should('contain', 'Jane Lane')
.exec('cat cypress.json')
.its('stderr').should('be.empty')
.exec('pwd')
.its('code').should('eq', 0)
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')
cypress/screenshots/my-image.png
To wrap an object, use the cy.wrap()
command.
cy
.wrap({foo: 'bar'})
.should('have.property', 'foo')
.and('include', 'bar')
{foo: bar}