Select

new Select(element)

Create an Select Element

Parameters:
NameTypeDescription
elementWebElement

Select WebElement.

Implements

Methods

(async) deselectAll() → {Promise.<void>}

Deselects all selected options

Returns:
Type: 
Promise.<void>

(async) deselectByIndex(index) → {Promise.<void>}

Parameters:
NameTypeDescription
indexNumber

index of option element to deselect Deselect the option at the given index. This is done by examining the "index" attribute of an element, and not merely by counting.

Returns:
Type: 
Promise.<void>

(async) deselectByValue(value) → {Promise.<void>}

Parameters:
NameTypeDescription
valueString

value of an option to deselect

Returns:
Type: 
Promise.<void>

(async) deselectByVisibleText(text) → {Promise.<void>}

Parameters:
NameTypeDescription
textstring | Number

text of option to deselect

Returns:
Type: 
Promise.<void>

(async) getAllSelectedOptions() → {Promise.<void>}

Returns a list of all selected options belonging to this select tag

Returns:
Type: 
Promise.<void>

(async) getFirstSelectedOption() → {Promise.<Element>}

Returns first Selected Option

Returns:
Type: 
Promise.<Element>

(async) getOptions() → (non-null) {Promise.<!Array.<!WebElement>>}

Returns a list of all options belonging to this select tag

Returns:
Type: 
Promise.<!Array.<!WebElement>>

(async) isMultiple() → {Promise.<boolean>}

Returns a boolean value if the select tag is multiple

Returns:
Type: 
Promise.<boolean>

(async) selectByIndex(index)

Select option with specified index.

const selectBox = await driver.findElement(By.id("selectbox")); await selectObject.selectByIndex(1);
Parameters:
NameTypeDescription
index

(async) selectByValue(value)

Select option by specific value.

const selectBox = await driver.findElement(By.id("selectbox")); await selectObject.selectByVisibleText("Option 2");
Parameters:
NameTypeDescription
valuestring

value of option element to be selected

(async) selectByVisibleText(text)

Select option with displayed text matching the argument.

const selectBox = await driver.findElement(By.id("selectbox")); await selectObject.selectByVisibleText("Option 2");
Parameters:
NameTypeDescription
textString | Number

text of option element to get selected