* {{> waitForDisabled }}
(locator, sec)
| 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 }} |
no test coverage detected