Appearance
I.deselected()
Asserts that a dropdown option, checkbox, or radio button is NOT selected.
If the matching element is selected, the command fails the test.
Usage
javascript
I.deselected(option: string)
I.deselected(list: string, option: string)Parameters
| Parameter | Type | Description |
|---|---|---|
list | string | (optional) The group containing the option — by visible text, name attribute, CSS or XPath selector |
option | string | The option element to assert — by visible text, value, CSS or XPath selector |
Examples
Simple checkbox
Here's a simple checkbox for illustration:
Demo: Simple Checkbox
UI
HTML
To assert that the checkbox is unchecked, use I.deselected(option):
js
// using text
I.deselected("I agree")
// using option value
I.deselected("agree")
// using css
I.deselected("#agree-checkbox")
// using xpath
I.deselected("//input[@name='terms']")Radio button group
Here's a group of radio buttons for illustration:
Demo: Radio Button Group
UI
HTML
To assert that the option in a specific group is NOT selected, use I.deselected(list, option):
js
// using group text
I.deselected("Door color", "Blue")
// using name attribute
I.deselected("door-color", "Blue")Select dropdown
Here's a <select> dropdown for illustration:
Demo: Select Dropdown
UI
HTML
To assert that an option in a <select> group is NOT selected, use I.deselected(list, option):
js
// using labels
I.deselected("Country", "Singapore")
// target option - by its `value` attribute
I.deselected("Country", "SG")
// target dropdown - by `name` attribute
I.deselected("country", "Singapore")
// target dropdown - by CSS or XPath
I.deselected("#country-field", "Singapore")
I.deselected("//select[@name='country']", "Singapore")