View Source Improve this doc

selectByAttribute

Select option with a specific value.

Usage

1
browser.selectByAttribute(selector,attribute,value);

Parameters

Param Type Details
selector String select element that contains the options
attribute String attribute of option element to get selected
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 name="someName5" value="someValue5">seis</option>
</select>
selectByAttribute.js
1
2
3
4
5
6
7
8
9
10
11
12
it('should demonstrate the selectByAttribute command', function () {
var selectBox = $('#selectbox');

var value = selectBox.getValue();
console.log(value); // returns "someValue0"

selectBox.selectByAttribute('value', 'someValue3');
console.log(selectBox.getValue()); // returns "someValue3"

selectBox.selectByAttribute('name', 'someName5');
console.log(selectBox.getValue()); // returns "someValue5"
});

Uses