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

Method waitForDisabled

lib/helper/Playwright.js:3190–3211  ·  view source on GitHub ↗

* {{> waitForDisabled }}

(locator, sec)

Source from the content-addressed store, hash-verified

3188 * {{> waitForDisabled }}
3189 */
3190 async waitForDisabled(locator, sec) {
3191 const waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout
3192 locator = new Locator(locator, 'css')
3193
3194 let waiter
3195 const context = await this._getContext()
3196 if (!locator.isXPath()) {
3197 const valueFn = function ([locator]) {
3198 return Array.from(document.querySelectorAll(locator)).filter(el => el.disabled).length > 0
3199 }
3200 waiter = context.waitForFunction(valueFn, [locator.value], { timeout: waitTimeout })
3201 } else {
3202 const disabledFn = function ([locator, $XPath]) {
3203 eval($XPath)
3204 return $XPath(null, locator).filter(el => el.disabled).length > 0
3205 }
3206 waiter = context.waitForFunction(disabledFn, [locator.value, $XPath.toString()], { timeout: waitTimeout })
3207 }
3208 return waiter.catch(err => {
3209 throw new Error(`element (${locator.toString()}) is still enabled after ${waitTimeout / 1000} sec\n${err.message}`)
3210 })
3211 }
3212
3213 /**
3214 * {{> waitForValue }}

Callers 1

Playwright_test.jsFile · 0.80

Calls 4

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

Tested by

no test coverage detected