# Misc

Examples of miscellaneous commands in Cypress, for a full reference of commands, go to docs.cypress.io

#### cy.end()

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

#### cy.exec()

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)

#### cy.focused()

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')

Name
Description

#### cy.screenshot()

To take a screenshot, use the `cy.screenshot()` command.

    cy.screenshot('my-image')

`cypress/screenshots/my-image.png`

#### cy.wrap()

To wrap an object, use the `cy.wrap()` command.

    cy
      .wrap({foo: 'bar'})
        .should('have.property', 'foo')
        .and('include', 'bar')

`{foo: bar}`