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

Method waitInUrl

lib/helper/Playwright.js:3424–3445  ·  view source on GitHub ↗

* {{> waitInUrl }}

(urlPart, sec = null)

Source from the content-addressed store, hash-verified

3422 * {{> waitInUrl }}
3423 */
3424 async waitInUrl(urlPart, sec = null) {
3425 const waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout
3426 const expectedUrl = resolveUrl(urlPart, this.options.url)
3427
3428 return this.page
3429 .waitForFunction(
3430 urlPart => {
3431 const currUrl = decodeURIComponent(decodeURIComponent(decodeURIComponent(window.location.href)))
3432 return currUrl.indexOf(urlPart) > -1
3433 },
3434 expectedUrl,
3435 { timeout: waitTimeout },
3436 )
3437 .catch(async e => {
3438 const currUrl = await this._getPageUrl()
3439 if (/Timeout/i.test(e.message)) {
3440 throw new Error(`expected url to include ${expectedUrl}, but found ${currUrl}`)
3441 } else {
3442 throw e
3443 }
3444 })
3445 }
3446
3447 /**
3448 * {{> waitUrlEquals }}

Callers

nothing calls this directly

Calls 3

_getPageUrlMethod · 0.95
resolveUrlFunction · 0.90
waitForFunctionMethod · 0.45

Tested by

no test coverage detected