* * Select option by specific value. * * Option 1 Option 2 Option 3 const selectBox = await driver.findElement(By.id("selectbox")); await selectO
(value)
| 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 | * |
nothing calls this directly
no test coverage detected