* {{> waitForInvisible }}
(locator, sec)
| 3330 | * {{> waitForInvisible }} |
| 3331 | */ |
| 3332 | async waitForInvisible(locator, sec) { |
| 3333 | const waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout |
| 3334 | locator = new Locator(locator, 'css') |
| 3335 | |
| 3336 | const context = await this._getContext() |
| 3337 | let waiter |
| 3338 | let count = 0 |
| 3339 | |
| 3340 | // we have this as https://github.com/microsoft/playwright/issues/26829 is not yet implemented |
| 3341 | if (this.frame) { |
| 3342 | do { |
| 3343 | waiter = await this.frame.locator(buildLocatorString(locator)).first().isHidden() |
| 3344 | await this.wait(1) |
| 3345 | count += 1000 |
| 3346 | if (waiter) break |
| 3347 | } while (count <= waitTimeout) |
| 3348 | |
| 3349 | if (!waiter) throw new Error(`element (${locator.toString()}) still visible after ${waitTimeout / 1000} sec.`) |
| 3350 | return |
| 3351 | } |
| 3352 | |
| 3353 | try { |
| 3354 | await context.locator(buildLocatorString(locator)).first().waitFor({ timeout: waitTimeout, state: 'hidden' }) |
| 3355 | } catch (e) { |
| 3356 | throw new Error(`element (${locator.toString()}) still visible after ${waitTimeout / 1000} sec\n${e.message}`) |
| 3357 | } |
| 3358 | } |
| 3359 | |
| 3360 | /** |
| 3361 | * {{> waitToHide }} |
nothing calls this directly
no test coverage detected