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

Method waitNumberOfVisibleElements

lib/helper/WebDriver.js:2673–2695  ·  view source on GitHub ↗

* {{> waitNumberOfVisibleElements }}

(locator, num, sec = null)

Source from the content-addressed store, hash-verified

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 }}

Callers

nothing calls this directly

Calls 4

_resMethod · 0.95
forEachAsyncFunction · 0.85
filterMethod · 0.80
wrapErrorFunction · 0.70

Tested by

no test coverage detected