Files
cypress/docs/source/api/commands/uncheck.md
2017-05-31 12:15:28 -04:00

2.5 KiB

title, comments, description
title comments description
uncheck true

Uncheck checkbox(es).

Syntax

.uncheck()
.uncheck(value)
.uncheck(values)
.uncheck(options)
.uncheck(value, options)
.uncheck(values, options)

Usage

.uncheck() requires being chained off another cy command that yields a DOM element of type checkbox.

{% fa fa-check-circle green %} Valid Usage

cy.get('[type="checkbox"]').uncheck()       // Yields checkbox element

{% fa fa-exclamation-triangle red %} Invalid Usage

cy.uncheck('[type="checkbox"]') // Errors, cannot be chained off 'cy'
cy.get('p:first').uncheck()     // Errors, '.get()' does not yield checkbox

Arguments

{% fa fa-angle-right %} value (String)

Value of checkbox that should be unchecked.

{% fa fa-angle-right %} values (Array)

Values of checkboxes that should be unchecked.

{% fa fa-angle-right %} options (Object)

Pass in an options object to change the default behavior of .uncheck().

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

Examples

Uncheck

Uncheck all checkboxes

cy.get(':checkbox').uncheck()

Uncheck element with the id saveUserName

cy.get('#saveUserName').uncheck()

Value

Uncheck the checkbox with the value of 'ga'

cy.get('input[type="checkbox"]').uncheck(['ga'])

Values

Uncheck the checkboxes with the value of 'ga' and 'ca'

cy.get('[type="checkbox"]').uncheck(['ga', 'ca'])

Command Log

Uncheck the first checkbox

cy
  .get('[data-js="choose-all"]').click()
  .find('input[type="checkbox"]').first().uncheck()

The commands above will display in the command log as:

screen shot 2015-11-29 at 1 30 49 pm

When clicking on uncheck within the command log, the console outputs the following:

screen shot 2015-11-29 at 1 31 04 pm

See also