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