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

Method waitCurrentPathEquals

lib/helper/WebDriver.js:2572–2595  ·  view source on GitHub ↗

* {{> waitCurrentPathEquals }}

(path, sec = null)

Source from the content-addressed store, hash-verified

2570 * {{> waitCurrentPathEquals }}
2571 */
2572 async waitCurrentPathEquals(path, sec = null) {
2573 const aSec = sec || this.options.waitForTimeoutInSeconds
2574 const normalizedPath = normalizePath(path)
2575 const baseUrl = this.options.url || 'http://localhost'
2576 let actualPath = ''
2577
2578 return this.browser
2579 .waitUntil(
2580 async () => {
2581 const currUrl = await this.browser.getUrl()
2582 const url = new URL(currUrl, baseUrl)
2583 actualPath = url.pathname
2584 return normalizePath(actualPath) === normalizedPath
2585 },
2586 { timeout: aSec * 1000 },
2587 )
2588 .catch(e => {
2589 e = wrapError(e)
2590 if (e.message.indexOf('timeout')) {
2591 throw new Error(`expected path to be ${normalizedPath}, but found ${normalizePath(actualPath)}`)
2592 }
2593 throw e
2594 })
2595 }
2596
2597 /**
2598 * {{> waitForText }}

Callers

nothing calls this directly

Calls 2

normalizePathFunction · 0.90
wrapErrorFunction · 0.70

Tested by

no test coverage detected