* {{> waitUrlEquals }}
(urlPart, sec = null)
| 2526 | * {{> waitUrlEquals }} |
| 2527 | */ |
| 2528 | async waitUrlEquals(urlPart, sec = null) { |
| 2529 | const waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout |
| 2530 | const expectedUrl = resolveUrl(urlPart, this.options.url) |
| 2531 | |
| 2532 | return this.page |
| 2533 | .waitForFunction( |
| 2534 | url => { |
| 2535 | const currUrl = decodeURIComponent(window.location.href) |
| 2536 | return currUrl === url |
| 2537 | }, |
| 2538 | { timeout: waitTimeout }, |
| 2539 | expectedUrl, |
| 2540 | ) |
| 2541 | .catch(async e => { |
| 2542 | const currUrl = await this._getPageUrl() |
| 2543 | if (/Waiting failed/i.test(e.message) || /failed: timeout/i.test(e.message)) { |
| 2544 | throw new Error(`expected url to be ${expectedUrl}, but found ${currUrl}`) |
| 2545 | } else { |
| 2546 | throw e |
| 2547 | } |
| 2548 | }) |
| 2549 | } |
| 2550 | |
| 2551 | /** |
| 2552 | * {{> waitCurrentPathEquals }} |
no test coverage detected