* {{> waitForDetached }}
(locator, sec)
| 3741 | * {{> waitForDetached }} |
| 3742 | */ |
| 3743 | async waitForDetached(locator, sec) { |
| 3744 | const waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout |
| 3745 | locator = new Locator(locator, 'css') |
| 3746 | |
| 3747 | let waiter |
| 3748 | const context = await this._getContext() |
| 3749 | if (!locator.isXPath()) { |
| 3750 | try { |
| 3751 | await context |
| 3752 | .locator(locator.simplify()) |
| 3753 | .first() |
| 3754 | .waitFor({ timeout: waitTimeout, state: 'detached' }) |
| 3755 | } catch (e) { |
| 3756 | throw new Error(`element (${locator.toString()}) still on page after ${waitTimeout / 1000} sec\n${e.message}`) |
| 3757 | } |
| 3758 | } else { |
| 3759 | const visibleFn = function ([locator, $XPath]) { |
| 3760 | eval($XPath) |
| 3761 | return $XPath(null, locator).length === 0 |
| 3762 | } |
| 3763 | waiter = context.waitForFunction(visibleFn, [locator.value, $XPath.toString()], { timeout: waitTimeout }) |
| 3764 | return waiter.catch(err => { |
| 3765 | throw new Error(`element (${locator.toString()}) still on page after ${waitTimeout / 1000} sec\n${err.message}`) |
| 3766 | }) |
| 3767 | } |
| 3768 | } |
| 3769 | |
| 3770 | /** |
| 3771 | * {{> waitForCookie }} |
no test coverage detected