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

Method waitForDetached

lib/helper/Playwright.js:3743–3768  ·  view source on GitHub ↗

* {{> waitForDetached }}

(locator, sec)

Source from the content-addressed store, hash-verified

3741 * {{> waitForDetached }}
3742 */
3743 async waitForDetached(locator, sec) {
3744 const waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout
3745 locator = new Locator(locator, 'css')
3746
3747 let waiter
3748 const context = await this._getContext()
3749 if (!locator.isXPath()) {
3750 try {
3751 await context
3752 .locator(locator.simplify())
3753 .first()
3754 .waitFor({ timeout: waitTimeout, state: 'detached' })
3755 } catch (e) {
3756 throw new Error(`element (${locator.toString()}) still on page after ${waitTimeout / 1000} sec\n${e.message}`)
3757 }
3758 } else {
3759 const visibleFn = function ([locator, $XPath]) {
3760 eval($XPath)
3761 return $XPath(null, locator).length === 0
3762 }
3763 waiter = context.waitForFunction(visibleFn, [locator.value, $XPath.toString()], { timeout: waitTimeout })
3764 return waiter.catch(err => {
3765 throw new Error(`element (${locator.toString()}) still on page after ${waitTimeout / 1000} sec\n${err.message}`)
3766 })
3767 }
3768 }
3769
3770 /**
3771 * {{> waitForCookie }}

Callers 1

waitUntilExistsMethod · 0.95

Calls 6

_getContextMethod · 0.95
isXPathMethod · 0.80
simplifyMethod · 0.65
firstMethod · 0.45
toStringMethod · 0.45
waitForFunctionMethod · 0.45

Tested by

no test coverage detected