isSelected

The given selector will return true or false whether or not an <option> or <input> element of type checkbox or radio is currently selected.

Usage

1
browser.isSelected(selector);

Parameters

Param Type Details
selector String option element or input of type checkbox or radio

Example

index.html
1
2
3
4
5
<select name="selectbox" id="selectbox">
<option value="John Doe">John Doe</option>
<option value="Layla Terry" selected="selected">Layla Terry</option>
<option value="Bill Gilbert">Bill Gilbert"</option>
</select>
isSelected.js
1
2
3
4
5
6
7
it('should detect if an element is selected', function () {
var element = $('[value="Layla Terry"]');
console.log(element.isSelected()); // outputs: true

browser.selectByValue('#selectbox', 'Bill Gilbert');
console.log(element.isSelected()); // outputs: false
});

Returns

  • <Boolean/Boolean[]>: true if element is selected

Uses