* {{> waitInUrl }}
(urlPart, sec = null)
| 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 }} |
nothing calls this directly
no test coverage detected