Appearance
I.deselect()
Unchecks a checkbox.
This command ensures that a checkbox is unchecked. If the checkbox is already unchecked, this does nothing.
Usage
javascript
I.deselect(option: string)
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 |
Example
Uncheck a checkbox
Here's a checkbox for illustration:
Demo
UI
Choose ice cream flavor(s)
HTML
<!--[--> <div>
Choose ice cream flavor(s) <br>
<label><input type="checkbox" name="flavor" value="flavor1" checked="">Vanilla</label><br>
<label><input type="checkbox" name="flavor" value="flavor2" checked="">Chocolate</label>
</div>
<!--]-->Uncheck the checkbox using text, option value, CSS or XPath selector:
js
// using text
I.deselect("Chocolate")
// using option value
I.deselect("flavor2")
// using CSS
I.deselect("input[value='flavor2']")
// using XPath
I.deselect("//label[contains(., 'Chocolate')]/input")Uncheck a checkbox in a group
Here's two similar group of checkboxes for illustration:
Demo
UI
Choose ice cream flavor(s)
Choose topping(s)
HTML
<!--[--> <div>
Choose ice cream flavor(s) <br>
<label><input type="checkbox" name="flavor" value="vanilla" checked="">Vanilla</label><br>
<label><input type="checkbox" name="flavor" value="chocolate" checked="">Chocolate</label>
</div>
<br>
<div>
Choose topping(s) <br>
<label><input type="checkbox" name="toppings" value="chocolate" checked="">Chocolate</label> <br>
<label><input type="checkbox" name="toppings" value="strawberry" checked="">Strawberries</label>
</div>
<!--]-->Uncheck the checkbox in a specific group:
js
// specify group using text
I.deselect("Choose topping(s)", "Chocolate")
// specify group using `name` attribute
I.deselect("toppings", "Chocolate")