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

Method waitForDetached

lib/helper/Puppeteer.js:2742–2763  ·  view source on GitHub ↗

* {{> waitForDetached }}

(locator, sec)

Source from the content-addressed store, hash-verified

2740 * {{> waitForDetached }}
2741 */
2742 async waitForDetached(locator, sec) {
2743 const waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout
2744 locator = new Locator(locator, 'css')
2745
2746 let waiter
2747 const context = await this._getContext()
2748 if (locator.isCSS()) {
2749 const visibleFn = function (locator) {
2750 return document.querySelector(locator) === null
2751 }
2752 waiter = context.waitForFunction(visibleFn, { timeout: waitTimeout }, locator.value)
2753 } else {
2754 const visibleFn = function (locator, $XPath) {
2755 eval($XPath)
2756 return $XPath(null, locator).length === 0
2757 }
2758 waiter = context.waitForFunction(visibleFn, { timeout: waitTimeout }, locator.value, $XPath.toString())
2759 }
2760 return waiter.catch(err => {
2761 throw new Error(`element (${locator.toString()}) still on page after ${waitTimeout / 1000} sec\n${err.message}`)
2762 })
2763 }
2764
2765 async _waitForAction() {
2766 return this.wait(this.options.waitForAction / 1000)

Callers 5

waitUntilExistsMethod · 0.95
testsFunction · 0.45

Calls 4

_getContextMethod · 0.95
isCSSMethod · 0.80
waitForFunctionMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected