selectByValue

Select option with a specific value.

Usage

1
browser.selectByValue(selector,value);

Parameters

Param Type Details
selector String select element that contains the options
value String value of option element to get selected

Example

example.html
1
2
3
4
5
6
7
8
<select id="selectbox">
<option value="someValue0">uno</option>
<option value="someValue1">dos</option>
<option value="someValue2">tres</option>
<option value="someValue3">cuatro</option>
<option value="someValue4">cinco</option>
<option value="someValue5">seis</option>
</select>
selectByValue.js
1
2
3
4
5
6
7
it('should demonstrate the selectByValue command', function () {
var selectBox = $('#selectbox');
console.log(selectBox.getValue()); // returns "someValue0"

selectBox.selectByValue('someValue3');
console.log(selectBox.getValue()); // returns "someValue3"
});

Uses