selectByAttribute
Select option with a specific value.
Usage
browser.selectByAttribute(attribute, value)
Parameters
Param | Type | Details |
---|---|---|
attribute optional | param | attribute of option element to get selected |
value optional | param | value of option element to get selected |
Example
<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>
it('Should demonstrate the selectByAttribute command', function () {
const selectBox = $('#selectbox');
const 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"
});