* {{> waitForVisible }}
(locator, sec)
| 3300 | * {{> waitForVisible }} |
| 3301 | */ |
| 3302 | async waitForVisible(locator, sec) { |
| 3303 | const waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout |
| 3304 | locator = new Locator(locator, 'css') |
| 3305 | |
| 3306 | const context = await this._getContext() |
| 3307 | let count = 0 |
| 3308 | |
| 3309 | // we have this as https://github.com/microsoft/playwright/issues/26829 is not yet implemented |
| 3310 | let waiter |
| 3311 | if (this.frame) { |
| 3312 | do { |
| 3313 | waiter = await this.frame.locator(buildLocatorString(locator)).first().isVisible() |
| 3314 | await this.wait(1) |
| 3315 | count += 1000 |
| 3316 | if (waiter) break |
| 3317 | } while (count <= waitTimeout) |
| 3318 | |
| 3319 | if (!waiter) throw new Error(`element (${locator.toString()}) still not visible after ${waitTimeout / 1000} sec.`) |
| 3320 | } |
| 3321 | |
| 3322 | try { |
| 3323 | await context.locator(buildLocatorString(locator)).first().waitFor({ timeout: waitTimeout, state: 'visible' }) |
| 3324 | } catch (e) { |
| 3325 | throw new Error(`element (${locator.toString()}) still not visible after ${waitTimeout / 1000} sec\n${e.message}`) |
| 3326 | } |
| 3327 | } |
| 3328 | |
| 3329 | /** |
| 3330 | * {{> waitForInvisible }} |
nothing calls this directly
no test coverage detected