View Source Improve this doc

isSelected

Return true or false if an <option> element, or an <input> element of type checkbox or radio is currently selected found by given selector.

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
});

Uses