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

Method deselectByValue

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

* * @param {String} value value of an option to deselect * @returns {Promise }

(value)

Source from the content-addressed store, hash-verified

427 * @returns {Promise<void>}
428 */
429 async deselectByValue(value) {
430 if (!(await this.isMultiple())) {
431 throw new Error('You may only deselect options of a multi-select')
432 }
433
434 let matched = false
435
436 let options = await this.element.findElements(By.xpath('.//option[@value = ' + escapeQuotes(value) + ']'))
437
438 if (options.length === 0) {
439 throw new Error(`Cannot locate option with value: ${value}`)
440 }
441
442 for (let option of options) {
443 if (await option.isSelected()) {
444 await option.click()
445 }
446 matched = true
447 }
448
449 if (!matched) {
450 throw new Error(`Cannot locate option with value: ${value}`)
451 }
452 }
453
454 async setSelected(option) {
455 if (!(await option.isSelected())) {

Callers

nothing calls this directly

Calls 6

isMultipleMethod · 0.95
escapeQuotesFunction · 0.85
findElementsMethod · 0.65
isSelectedMethod · 0.65
clickMethod · 0.65
xpathMethod · 0.45

Tested by

no test coverage detected