* {{> waitForDetached }}
(locator, sec)
| 2740 | * {{> waitForDetached }} |
| 2741 | */ |
| 2742 | async waitForDetached(locator, sec) { |
| 2743 | const waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout |
| 2744 | locator = new Locator(locator, 'css') |
| 2745 | |
| 2746 | let waiter |
| 2747 | const context = await this._getContext() |
| 2748 | if (locator.isCSS()) { |
| 2749 | const visibleFn = function (locator) { |
| 2750 | return document.querySelector(locator) === null |
| 2751 | } |
| 2752 | waiter = context.waitForFunction(visibleFn, { timeout: waitTimeout }, locator.value) |
| 2753 | } else { |
| 2754 | const visibleFn = function (locator, $XPath) { |
| 2755 | eval($XPath) |
| 2756 | return $XPath(null, locator).length === 0 |
| 2757 | } |
| 2758 | waiter = context.waitForFunction(visibleFn, { timeout: waitTimeout }, locator.value, $XPath.toString()) |
| 2759 | } |
| 2760 | return waiter.catch(err => { |
| 2761 | throw new Error(`element (${locator.toString()}) still on page after ${waitTimeout / 1000} sec\n${err.message}`) |
| 2762 | }) |
| 2763 | } |
| 2764 | |
| 2765 | async _waitForAction() { |
| 2766 | return this.wait(this.options.waitForAction / 1000) |
no test coverage detected