MCPcopy
hub / github.com/codeceptjs/CodeceptJS / _locateElement

Method _locateElement

lib/helper/Puppeteer.js:1009–1020  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

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:

Callers 7

_withinBeginMethod · 0.95
moveCursorToMethod · 0.95
focusMethod · 0.95
blurMethod · 0.95
scrollToMethod · 0.95
waitForClickableMethod · 0.95
proceedDragAndDropFunction · 0.45

Calls 1

selectElementFunction · 0.90

Tested by

no test coverage detected