MCPcopy Index your code
hub / github.com/SeleniumHQ/selenium / selectByValue

Method selectByValue

javascript/selenium-webdriver/lib/select.js:223–241  ·  view source on GitHub ↗

* * Select option by specific value. * * Option 1 Option 2 Option 3 const selectBox = await driver.findElement(By.id("selectbox")); await selectO

(value)

Source from the content-addressed store, hash-verified

221 * @param {string} value value of option element to be selected
222 */
223 async selectByValue(value) {
224 let matched = false
225 let isMulti = await this.isMultiple()
226
227 let options = await this.element.findElements(By.xpath('.//option[@value = ' + escapeQuotes(value) + ']'))
228
229 for (let option of options) {
230 await this.setSelected(option)
231
232 if (!isMulti) {
233 return
234 }
235 matched = true
236 }
237
238 if (!matched) {
239 throw new Error(`Cannot locate option with value: ${value}`)
240 }
241 }
242
243 /**
244 *

Callers

nothing calls this directly

Calls 5

isMultipleMethod · 0.95
setSelectedMethod · 0.95
escapeQuotesFunction · 0.85
findElementsMethod · 0.65
xpathMethod · 0.45

Tested by

no test coverage detected