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

Method waitToHide

lib/helper/Playwright.js:3363–3391  ·  view source on GitHub ↗

* {{> waitToHide }}

(locator, sec)

Source from the content-addressed store, hash-verified

3361 * {{> waitToHide }}
3362 */
3363 async waitToHide(locator, sec) {
3364 const waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout
3365 locator = new Locator(locator, 'css')
3366
3367 const context = await this._getContext()
3368 let waiter
3369 let count = 0
3370
3371 // we have this as https://github.com/microsoft/playwright/issues/26829 is not yet implemented
3372 if (this.frame) {
3373 do {
3374 waiter = await this.frame.locator(buildLocatorString(locator)).first().isHidden()
3375 await this.wait(1)
3376 count += 1000
3377 if (waiter) break
3378 } while (count <= waitTimeout)
3379
3380 if (!waiter) throw new Error(`element (${locator.toString()}) still not hidden after ${waitTimeout / 1000} sec.`)
3381 return
3382 }
3383
3384 return context
3385 .locator(buildLocatorString(locator))
3386 .first()
3387 .waitFor({ timeout: waitTimeout, state: 'hidden' })
3388 .catch(err => {
3389 throw new Error(`element (${locator.toString()}) still not hidden after ${waitTimeout / 1000} sec\n${err.message}`)
3390 })
3391 }
3392
3393 /**
3394 * {{> waitForNumberOfTabs }}

Callers

nothing calls this directly

Calls 5

_getContextMethod · 0.95
waitMethod · 0.95
buildLocatorStringFunction · 0.85
firstMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected