selectByVisibleText

Select option that display text matching the argument.

Usage

1
client.selectByVisibleText(selectElem,text).then(callback);

Parameters

Param Type Details
selectElem String select element that contains the options
text String text 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>
selectByVisibleText.js
1
2
3
4
5
6
7
8
9
10
client
.getText('#selectbox option:checked').then(function(value) {
console.log(value);
// returns "uno"
})
.selectByVisibleText('#selectbox', 'cuatro')
.getText('#selectbox option:checked').then(function(value) {
console.log(value);
// returns "cuatro"
});

Uses