(context, el, option)
| 4444 | } |
| 4445 | |
| 4446 | async function proceedSelect(context, el, option) { |
| 4447 | const role = await el.getAttribute('role') |
| 4448 | const options = Array.isArray(option) ? option : [option] |
| 4449 | |
| 4450 | if (role === 'combobox') { |
| 4451 | this.debugSection('SelectOption', 'Expanding combobox') |
| 4452 | await highlightActiveElement.call(this, el) |
| 4453 | const [ariaOwns, ariaControls] = await Promise.all([el.getAttribute('aria-owns'), el.getAttribute('aria-controls')]) |
| 4454 | await el.click() |
| 4455 | await this._waitForAction() |
| 4456 | |
| 4457 | const listboxId = ariaOwns || ariaControls |
| 4458 | let listbox = listboxId ? context.locator(`#${listboxId}`).first() : null |
| 4459 | if (!listbox || !(await listbox.count())) listbox = context.getByRole('listbox').first() |
| 4460 | |
| 4461 | for (const opt of options) { |
| 4462 | const optEl = listbox.getByRole('option', { name: opt }).first() |
| 4463 | this.debugSection('SelectOption', `Clicking: "${opt}"`) |
| 4464 | await highlightActiveElement.call(this, optEl) |
| 4465 | await optEl.click() |
| 4466 | } |
| 4467 | return this._waitForAction() |
| 4468 | } |
| 4469 | |
| 4470 | if (role === 'listbox') { |
| 4471 | for (const opt of options) { |
| 4472 | const optEl = el.getByRole('option', { name: opt }).first() |
| 4473 | this.debugSection('SelectOption', `Clicking: "${opt}"`) |
| 4474 | await highlightActiveElement.call(this, optEl) |
| 4475 | await optEl.click() |
| 4476 | } |
| 4477 | return this._waitForAction() |
| 4478 | } |
| 4479 | |
| 4480 | await highlightActiveElement.call(this, el) |
| 4481 | let optionToSelect = option |
| 4482 | try { |
| 4483 | optionToSelect = (await el.locator('option', { hasText: option }).textContent()).trim() |
| 4484 | } catch (e) { |
| 4485 | optionToSelect = option |
| 4486 | } |
| 4487 | if (!Array.isArray(option)) option = [optionToSelect] |
| 4488 | await el.selectOption(option) |
| 4489 | return this._waitForAction() |
| 4490 | } |
| 4491 | |
| 4492 | async function proceedSeeInField(assertType, field, value, context) { |
| 4493 | const els = await findFields.call(this, field, context) |
nothing calls this directly
no test coverage detected