Files
cypress/docs/source/api/commands/within.md
2017-05-19 11:51:03 -04:00

1004 B

title: within comments: true

Reset the root scope to the current subject and pass that as an argument to the callback function.

Returns the new DOM element(s) found by the command.
Timeout cannot timeout

cy.within( function )

Set the root scope to the current subject

Options

Pass in an options object to change the default behavior of cy.within.

cy.within( options, function )

Option Default Notes
log false Display command in command log

Usage

Get inputs within a form and submit the form

<form>
  <input name="email" type="email">
  <input name="password" type="password">
  <button type="submit">Login</button>
</form>
cy.get("form").within(function(){
  cy
    .get("input[name='email']").type("john.doe@email.com")
    .get("input[name='password']").type("password")
    .root().submit()
})

Related