MCPcopy Index your code
hub / github.com/codeceptjs/CodeceptJS / waitForVisible

Method waitForVisible

lib/helper/Playwright.js:3302–3327  ·  view source on GitHub ↗

* {{> waitForVisible }}

(locator, sec)

Source from the content-addressed store, hash-verified

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 }}

Callers

nothing calls this directly

Calls 6

_getContextMethod · 0.95
waitMethod · 0.95
buildLocatorStringFunction · 0.85
isVisibleMethod · 0.80
firstMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected