selectByIndex
Select option with a specific index.
Usage
$(selector).selectByIndex(index)
Parameters
Name | Type | Details |
---|---|---|
index | Number | option index |
Examples
<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>
it('Should demonstrate the selectByIndex command', () => {
const selectBox = $('#selectbox');
console.log(selectBox.getValue()); // returns "someValue0"
selectBox.selectByIndex(4);
console.log(selectBox.getValue()); // returns "someValue4"
});