mirror of
https://github.com/cypress-io/cypress.git
synced 2026-02-21 14:41:00 -06:00
1004 B
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()
})