* {{> waitNumberOfVisibleElements }}
(locator, num, sec = null)
| 2671 | * {{> waitNumberOfVisibleElements }} |
| 2672 | */ |
| 2673 | async waitNumberOfVisibleElements(locator, num, sec = null) { |
| 2674 | const aSec = sec || this.options.waitForTimeoutInSeconds |
| 2675 | |
| 2676 | return this.browser |
| 2677 | .waitUntil( |
| 2678 | async () => { |
| 2679 | const res = await this._res(locator) |
| 2680 | if (!res || res.length === 0) return false |
| 2681 | let selected = await forEachAsync(res, async el => el.isDisplayed()) |
| 2682 | |
| 2683 | if (!Array.isArray(selected)) selected = [selected] |
| 2684 | selected = selected.filter(val => val === true) |
| 2685 | return selected.length === num |
| 2686 | }, |
| 2687 | { |
| 2688 | timeout: aSec * 1000, |
| 2689 | timeoutMsg: `The number of elements (${new Locator(locator)}) is not ${num} after ${aSec} sec`, |
| 2690 | }, |
| 2691 | ) |
| 2692 | .catch(e => { |
| 2693 | throw wrapError(e) |
| 2694 | }) |
| 2695 | } |
| 2696 | |
| 2697 | /** |
| 2698 | * {{> waitForInvisible }} |
nothing calls this directly
no test coverage detected