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

Method waitForEnabled

lib/helper/Playwright.js:3164–3185  ·  view source on GitHub ↗

* {{> waitForEnabled }}

(locator, sec)

Source from the content-addressed store, hash-verified

3162 * {{> waitForEnabled }}
3163 */
3164 async waitForEnabled(locator, sec) {
3165 const waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout
3166 locator = new Locator(locator, 'css')
3167
3168 let waiter
3169 const context = await this._getContext()
3170 if (!locator.isXPath()) {
3171 const valueFn = function ([locator]) {
3172 return Array.from(document.querySelectorAll(locator)).filter(el => !el.disabled).length > 0
3173 }
3174 waiter = context.waitForFunction(valueFn, [locator.value], { timeout: waitTimeout })
3175 } else {
3176 const enabledFn = function ([locator, $XPath]) {
3177 eval($XPath)
3178 return $XPath(null, locator).filter(el => !el.disabled).length > 0
3179 }
3180 waiter = context.waitForFunction(enabledFn, [locator.value, $XPath.toString()], { timeout: waitTimeout })
3181 }
3182 return waiter.catch(err => {
3183 throw new Error(`element (${locator.toString()}) still not enabled after ${waitTimeout / 1000} sec\n${err.message}`)
3184 })
3185 }
3186
3187 /**
3188 * {{> waitForDisabled }}

Callers

nothing calls this directly

Calls 4

_getContextMethod · 0.95
isXPathMethod · 0.80
waitForFunctionMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected