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

Function expectAnyElement

lib/els.js:87–108  ·  view source on GitHub ↗
(locator, fn)

Source from the content-addressed store, hash-verified

85}
86
87function expectAnyElement(locator, fn) {
88 const step = prepareStep('expect any element to be', locator, fn)
89 if (!step) return
90
91 return executeStep(step, async () => {
92 const els = await step.helper._locate(locator)
93 output.debug(`Found ${els.length} elements, at least one should pass the assertion`)
94
95 const assertion = truth(`any element of (${locator})`, fn.toString())
96
97 let found = false
98 for (const el of els) {
99 const wrapped = new WebElement(el, step.helper)
100 const result = await fn(wrapped)
101 if (result) {
102 found = true
103 break
104 }
105 }
106 if (!found) throw assertion.getException()
107 })
108}
109
110function expectAllElements(locator, fn) {
111 const step = prepareStep('expect all elements', locator, fn)

Callers 1

els_test.jsFile · 0.90

Calls 8

truthFunction · 0.90
prepareStepFunction · 0.85
executeStepFunction · 0.85
debugMethod · 0.80
fnFunction · 0.50
_locateMethod · 0.45
toStringMethod · 0.45
getExceptionMethod · 0.45

Tested by

no test coverage detected