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

Method waitForElement

lib/helper/Puppeteer.js:2401–2415  ·  view source on GitHub ↗

* {{> waitForElement }}

(locator, sec)

Source from the content-addressed store, hash-verified

2399 * {{> waitForElement }}
2400 */
2401 async waitForElement(locator, sec) {
2402 const waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout
2403 locator = new Locator(locator, 'css')
2404
2405 let waiter
2406 const context = await this._getContext()
2407 if (locator.isCSS()) {
2408 waiter = context.waitForSelector(locator.simplify(), { timeout: waitTimeout })
2409 } else {
2410 waiter = _waitForElement.call(this, locator, { timeout: waitTimeout })
2411 }
2412 return waiter.catch(err => {
2413 throw new Error(`element (${locator.toString()}) still not present on page after ${waitTimeout / 1000} sec\n${err.message}`)
2414 })
2415 }
2416
2417 /**
2418 * {{> waitForVisible }}

Callers

nothing calls this directly

Calls 4

_getContextMethod · 0.95
isCSSMethod · 0.80
simplifyMethod · 0.65
toStringMethod · 0.45

Tested by

no test coverage detected