* * @param {String} value value of an option to deselect * @returns {Promise }
(value)
| 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())) { |
nothing calls this directly
no test coverage detected