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

Method waitInUrl

lib/helper/WebDriver.js:2521–2544  ·  view source on GitHub ↗

* {{> waitInUrl }}

(urlPart, sec = null)

Source from the content-addressed store, hash-verified

2519 * {{> waitInUrl }}
2520 */
2521 async waitInUrl(urlPart, sec = null) {
2522 const client = this.browser
2523 const aSec = sec || this.options.waitForTimeoutInSeconds
2524 const expectedUrl = resolveUrl(urlPart, this.options.url)
2525 let currUrl = ''
2526
2527 return client
2528 .waitUntil(
2529 function () {
2530 return this.getUrl().then(res => {
2531 currUrl = decodeUrl(res)
2532 return currUrl.indexOf(expectedUrl) > -1
2533 })
2534 },
2535 { timeout: aSec * 1000 },
2536 )
2537 .catch(e => {
2538 e = wrapError(e)
2539 if (e.message.indexOf('timeout')) {
2540 throw new Error(`expected url to include ${expectedUrl}, but found ${currUrl}`)
2541 }
2542 throw e
2543 })
2544 }
2545
2546 /**
2547 * {{> waitUrlEquals }}

Callers

nothing calls this directly

Calls 3

resolveUrlFunction · 0.90
decodeUrlFunction · 0.90
wrapErrorFunction · 0.70

Tested by

no test coverage detected