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

Function element

lib/els.js:11–37  ·  view source on GitHub ↗
(purpose, locator, fn)

Source from the content-addressed store, hash-verified

9import WebElement from './element/WebElement.js'
10
11function element(purpose, locator, fn) {
12 let stepConfig
13 if (StepConfig.isStepConfig(arguments[arguments.length - 1])) {
14 stepConfig = arguments[arguments.length - 1]
15 }
16
17 if (!fn || fn === stepConfig) {
18 fn = locator
19 locator = purpose
20 purpose = 'first element'
21 }
22
23 const step = prepareStep(purpose, locator, fn)
24 if (!step) return
25
26 return executeStep(
27 step,
28 async () => {
29 const els = await step.helper._locate(locator)
30 output.debug(`Found ${els.length} elements, using first element`)
31
32 const wrapped = new WebElement(els[0], step.helper)
33 return fn(wrapped)
34 },
35 stepConfig,
36 )
37}
38
39function eachElement(purpose, locator, fn) {
40 if (!fn) {

Callers 1

els_test.jsFile · 0.90

Calls 6

prepareStepFunction · 0.85
executeStepFunction · 0.85
isStepConfigMethod · 0.80
debugMethod · 0.80
fnFunction · 0.50
_locateMethod · 0.45

Tested by

no test coverage detected