MCPcopy
hub / github.com/codeceptjs/CodeceptJS / waitForEnabled

Method waitForEnabled

lib/helper/WebDriver.js:2459–2479  ·  view source on GitHub ↗

* {{> waitForEnabled }}

(locator, sec = null)

Source from the content-addressed store, hash-verified

2457 * {{> waitForEnabled }}
2458 */
2459 async waitForEnabled(locator, sec = null) {
2460 const aSec = sec || this.options.waitForTimeoutInSeconds
2461
2462 return this.browser.waitUntil(
2463 async () => {
2464 const res = await this._res(locator)
2465 if (!res || res.length === 0) {
2466 return false
2467 }
2468 const selected = await forEachAsync(res, async el => this.browser.isElementEnabled(getElementId(el)))
2469 if (Array.isArray(selected)) {
2470 return selected.filter(val => val === true).length > 0
2471 }
2472 return selected
2473 },
2474 {
2475 timeout: aSec * 1000,
2476 timeoutMsg: `element (${new Locator(locator)}) still not enabled after ${aSec} sec`,
2477 },
2478 )
2479 }
2480
2481 /**
2482 * {{> waitForElement }}

Callers

nothing calls this directly

Calls 4

_resMethod · 0.95
forEachAsyncFunction · 0.85
getElementIdFunction · 0.85
filterMethod · 0.80

Tested by

no test coverage detected