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