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

Method waitInUrl

lib/helper/Puppeteer.js:2502–2523  ·  view source on GitHub ↗

* {{> waitInUrl }}

(urlPart, sec = null)

Source from the content-addressed store, hash-verified

2500 * {{> waitInUrl }}
2501 */
2502 async waitInUrl(urlPart, sec = null) {
2503 const waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout
2504 const expectedUrl = resolveUrl(urlPart, this.options.url)
2505
2506 return this.page
2507 .waitForFunction(
2508 urlPart => {
2509 const currUrl = decodeURIComponent(decodeURIComponent(decodeURIComponent(window.location.href)))
2510 return currUrl.indexOf(urlPart) > -1
2511 },
2512 { timeout: waitTimeout },
2513 expectedUrl,
2514 )
2515 .catch(async e => {
2516 const currUrl = await this._getPageUrl()
2517 if (/Waiting failed:/i.test(e.message) || /failed: timeout/i.test(e.message)) {
2518 throw new Error(`expected url to include ${expectedUrl}, but found ${currUrl}`)
2519 } else {
2520 throw e
2521 }
2522 })
2523 }
2524
2525 /**
2526 * {{> waitUrlEquals }}

Callers 8

Playwright_test.jsFile · 0.45
WebDriver_test.jsFile · 0.45
Puppeteer_test.jsFile · 0.45
testsFunction · 0.45

Calls 3

_getPageUrlMethod · 0.95
resolveUrlFunction · 0.90
waitForFunctionMethod · 0.45

Tested by

no test coverage detected