* Get single element by different locator types, including strict locator * Should be used in custom helpers: * * ```js * const element = await this.helpers['Puppeteer']._locateElement({name: 'password'}); * ``` *
(locator)
| 1007 | * |
| 1008 | */ |
| 1009 | async _locateElement(locator) { |
| 1010 | const context = await this.context |
| 1011 | const elementIndex = store.currentStep?.opts?.elementIndex |
| 1012 | if (this.options.strict || elementIndex) { |
| 1013 | const elements = await findElements.call(this, context, locator) |
| 1014 | if (elements.length === 0) { |
| 1015 | throw new ElementNotFound(locator, 'Element', 'was not found') |
| 1016 | } |
| 1017 | return selectElement(elements, locator, this) |
| 1018 | } |
| 1019 | return findElement.call(this, context, locator) |
| 1020 | } |
| 1021 | |
| 1022 | /** |
| 1023 | * Find a checkbox by providing human-readable text: |
no test coverage detected