* {{> waitForEnabled }}
(locator, sec)
| 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 }} |
nothing calls this directly
no test coverage detected