Appearance
I.deselect()
Unchecks a checkbox.
If the checkbox is already unchecked, this does nothing.
Checkboxes Only
I.deselect() is exclusively designed for <input type="checkbox"> elements.
- Radio buttons: Cannot be deselected directly in HTML. To change a radio selection, use
I.select()on another option in the same group. - Dropdowns: Single-select
<select>elements always require one active option. To change the selection, useI.select()to choose a different option.
Attempting to run I.deselect() on a radio button or dropdown will throw an error.
Usage
javascript
// uncheck a uniquely identifiable checkbox
I.deselect(option: string)
// uncheck a checkbox within a specific group
I.deselect(list: string, option: string)Parameters
| Parameter | Type | Description |
|---|---|---|
list | string | (optional) The group containing the checkbox — by visible text or by name attribute |
option | string | The checkbox to uncheck — by visible label, value, CSS or XPath selector |
Examples
Uncheck a checkbox
Here's a checkbox for illustration:
Demo: Checkbox Options
UI
HTML
Uncheck the checkbox using its label text, option value, CSS or XPath selector:
js
// using visible label (recommended)
I.deselect("Chocolate")
// using option value
I.deselect("flavor2")
// using CSS selector (visible inputs only)
I.deselect("input[value='flavor2']")Hidden or Custom-Styled Checkboxes
If your application hides the native <input type="checkbox"> (e.g. using opacity: 0 or display: none) and styles an associated <label>, always target the visible label text (such as I.deselect("Chocolate")). Targeting a hidden <input> directly via CSS or XPath will fail because hidden DOM elements cannot receive click interactions.
Uncheck a checkbox in a group
Here are two groups of checkboxes that share similar option names:
Demo: Checkbox Groups
UI
HTML
Uncheck the checkbox within a specific group by specifying the group's visible heading or name attribute:
js
// specify group using visible text
I.deselect("Choose topping(s)", "Chocolate")
// specify group using name attribute
I.deselect("toppings", "Chocolate")Related Commands
| Command | Description |
|---|---|
I.select() | Check a checkbox or radio button, or select a dropdown option |
I.selected() | Assert that an option, checkbox, or radio button is selected |
I.deselected() | Assert that an option, checkbox, or radio button is NOT selected |