MCPcopy Index your code
hub / github.com/codeceptjs/CodeceptJS / _locate

Method _locate

lib/helper/Playwright.js:1749–1770  ·  view source on GitHub ↗

* Get elements by different locator types, including strict locator * Should be used in custom helpers: * * ```js * const elements = await this.helpers['Playwright']._locate({name: 'password'}); * ```

(locator)

Source from the content-addressed store, hash-verified

1747 * ```
1748 */
1749 async _locate(locator) {
1750 const context = await this._getContext()
1751
1752 if (this.frame) return findElements.call(this, this.frame, locator)
1753
1754 const els = await findElements.call(this, context, locator)
1755
1756 if (store.debugMode) {
1757 const previewElements = els.slice(0, 3)
1758 let htmls = await Promise.all(previewElements.map(el => elToString(el, previewElements.length)))
1759 if (els.length > 3) htmls.push('...')
1760 if (els.length > 1) {
1761 this.debugSection(`Elements (${els.length})`, htmls.join('|').trim())
1762 } else if (els.length === 1) {
1763 this.debugSection('Element', htmls.join('|').trim())
1764 } else {
1765 this.debug(`No elements found by ${JSON.stringify(locator).slice(0, 50)}....`)
1766 }
1767 }
1768
1769 return els
1770 }
1771
1772 /**
1773 * Get the first element by different locator types, including strict locator

Callers 15

moveCursorToMethod · 0.95
grabWebElementsMethod · 0.95
seeElementMethod · 0.95
dontSeeElementMethod · 0.95
seeElementInDOMMethod · 0.95
dontSeeElementInDOMMethod · 0.95
attachFileMethod · 0.95
selectOptionMethod · 0.95
seeNumberOfElementsMethod · 0.95
grabTextFromAllMethod · 0.95
grabHTMLFromAllMethod · 0.95

Calls 4

_getContextMethod · 0.95
elToStringFunction · 0.85
pushMethod · 0.80
debugMethod · 0.80

Tested by

no test coverage detected