(locator, fn)
| 85 | } |
| 86 | |
| 87 | function 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 | |
| 110 | function expectAllElements(locator, fn) { |
| 111 | const step = prepareStep('expect all elements', locator, fn) |
no test coverage detected