* {{> selectOption }}
(select, option, context = null)
| 1309 | * {{> selectOption }} |
| 1310 | */ |
| 1311 | async selectOption(select, option, context = null) { |
| 1312 | const locateFn = prepareLocateFn.call(this, context) |
| 1313 | const matchedLocator = new Locator(select) |
| 1314 | |
| 1315 | // Strict locator |
| 1316 | if (!matchedLocator.isFuzzy()) { |
| 1317 | this.debugSection('SelectOption', `Strict: ${JSON.stringify(select)}`) |
| 1318 | const els = await locateFn(select) |
| 1319 | assertElementExists(els, select, 'Selectable element') |
| 1320 | return proceedSelectOption.call(this, selectElement(els, select, this), option) |
| 1321 | } |
| 1322 | |
| 1323 | // Fuzzy: try combobox |
| 1324 | this.debugSection('SelectOption', `Fuzzy: "${matchedLocator.value}"`) |
| 1325 | let els = await this._locateByRole({ role: 'combobox', text: matchedLocator.value }) |
| 1326 | if (els?.length) return proceedSelectOption.call(this, selectElement(els, select, this), option) |
| 1327 | |
| 1328 | // Fuzzy: try listbox |
| 1329 | els = await this._locateByRole({ role: 'listbox', text: matchedLocator.value }) |
| 1330 | if (els?.length) return proceedSelectOption.call(this, selectElement(els, select, this), option) |
| 1331 | |
| 1332 | // Fuzzy: try native select |
| 1333 | const res = await findFields.call(this, select, context) |
| 1334 | assertElementExists(res, select, 'Selectable field') |
| 1335 | return proceedSelectOption.call(this, selectElement(res, select, this), option) |
| 1336 | } |
| 1337 | |
| 1338 | /** |
| 1339 | * Appium: not tested |
nothing calls this directly
no test coverage detected