mirror of
https://github.com/cypress-io/cypress.git
synced 2026-05-18 22:28:38 -05:00
2.5 KiB
2.5 KiB
title, comments, description
| title | comments | description |
|---|---|---|
| check | true |
Check the checkboxes or radios within the current subject.
The following events are fired during check: mousedown, focus, mouseup, click
| Returns | the new DOM element(s) found by the command. |
| Timeout | cy.check will retry for the duration of the defaultCommandTimeout or the duration of the timeout specified in the command's options. |
cy.check()
Checks checkboxes or radios.
cy.check( value )
Checks the checkbox or radio with the matching value.
cy.check( values )
Checks the checkboxes or radios with the matching values.
Options
Pass in an options object to change the default behavior of cy.check.
cy.check( options )
| Option | Default | Notes |
|---|---|---|
interval |
16 |
Interval which to retry a check |
timeout |
defaultCommandTimeout |
Total time to retry the check |
force |
false |
Forces check, disables error checking prior to check |
log |
true |
whether to display command in command log |
multiple |
false |
Enables serially checking multiple elements |
Usage
Check all checkboxes
cy.get('[type='checkbox']').check()
Check all radios
cy.get('[type='radio']').check()
Check the element with id of saveUserName and check it
cy.get('#saveUserName').check()
Value Usage
Check the checkbox with the value of "US"
cy.get('input[type='checkbox']').check('US')
Values Usage
Check the checkbox with the value of "ga" and "ca"
cy.get('input[type='checkbox']').check(['ga', 'ca'])
Command Log
check the element with name of emailUser
cy.get('form').find('[name='emailUser']').check()
The commands above will display in the command log as:
When clicking on check within the command log, the console outputs the following: