codeceptjs 4.0.0-beta.5 → 4.0.0-beta.7.esm-aria
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -45
- package/bin/codecept.js +46 -57
- package/lib/actor.js +15 -11
- package/lib/ai.js +6 -5
- package/lib/assert/empty.js +9 -8
- package/lib/assert/equal.js +15 -17
- package/lib/assert/error.js +2 -2
- package/lib/assert/include.js +9 -11
- package/lib/assert/throws.js +1 -1
- package/lib/assert/truth.js +8 -5
- package/lib/assert.js +18 -18
- package/lib/codecept.js +66 -107
- package/lib/colorUtils.js +48 -50
- package/lib/command/check.js +32 -27
- package/lib/command/configMigrate.js +11 -10
- package/lib/command/definitions.js +16 -10
- package/lib/command/dryRun.js +16 -16
- package/lib/command/generate.js +29 -26
- package/lib/command/gherkin/init.js +36 -38
- package/lib/command/gherkin/snippets.js +14 -14
- package/lib/command/gherkin/steps.js +21 -18
- package/lib/command/info.js +8 -8
- package/lib/command/init.js +34 -31
- package/lib/command/interactive.js +11 -10
- package/lib/command/list.js +10 -9
- package/lib/command/run-multiple/chunk.js +5 -5
- package/lib/command/run-multiple/collection.js +5 -5
- package/lib/command/run-multiple/run.js +3 -3
- package/lib/command/run-multiple.js +16 -13
- package/lib/command/run-rerun.js +6 -7
- package/lib/command/run-workers.js +10 -24
- package/lib/command/run.js +8 -8
- package/lib/command/utils.js +20 -18
- package/lib/command/workers/runTests.js +117 -269
- package/lib/config.js +111 -49
- package/lib/container.js +299 -102
- package/lib/data/context.js +6 -5
- package/lib/data/dataScenarioConfig.js +1 -1
- package/lib/data/dataTableArgument.js +1 -1
- package/lib/data/table.js +1 -1
- package/lib/effects.js +94 -10
- package/lib/els.js +11 -9
- package/lib/event.js +11 -10
- package/lib/globals.js +141 -0
- package/lib/heal.js +12 -12
- package/lib/helper/AI.js +1 -1
- package/lib/helper/ApiDataFactory.js +16 -13
- package/lib/helper/FileSystem.js +32 -12
- package/lib/helper/GraphQL.js +1 -1
- package/lib/helper/GraphQLDataFactory.js +1 -1
- package/lib/helper/JSONResponse.js +19 -30
- package/lib/helper/Mochawesome.js +9 -28
- package/lib/helper/Playwright.js +668 -265
- package/lib/helper/Puppeteer.js +284 -169
- package/lib/helper/REST.js +29 -12
- package/lib/helper/WebDriver.js +192 -71
- package/lib/helper/errors/ConnectionRefused.js +6 -6
- package/lib/helper/errors/ElementAssertion.js +11 -16
- package/lib/helper/errors/ElementNotFound.js +5 -9
- package/lib/helper/errors/RemoteBrowserConnectionRefused.js +5 -5
- package/lib/helper/extras/Console.js +11 -11
- package/lib/helper/extras/PlaywrightLocator.js +110 -0
- package/lib/helper/extras/PlaywrightPropEngine.js +18 -18
- package/lib/helper/extras/PlaywrightRestartOpts.js +23 -23
- package/lib/helper/extras/Popup.js +1 -1
- package/lib/helper/extras/React.js +29 -30
- package/lib/helper/network/actions.js +33 -48
- package/lib/helper/network/utils.js +76 -83
- package/lib/helper/scripts/blurElement.js +6 -6
- package/lib/helper/scripts/focusElement.js +6 -6
- package/lib/helper/scripts/highlightElement.js +9 -9
- package/lib/helper/scripts/isElementClickable.js +34 -34
- package/lib/helper.js +2 -1
- package/lib/history.js +23 -20
- package/lib/hooks.js +10 -10
- package/lib/html.js +90 -100
- package/lib/index.js +48 -21
- package/lib/listener/config.js +8 -9
- package/lib/listener/emptyRun.js +6 -7
- package/lib/listener/exit.js +4 -3
- package/lib/listener/globalRetry.js +5 -5
- package/lib/listener/globalTimeout.js +11 -10
- package/lib/listener/helpers.js +33 -14
- package/lib/listener/mocha.js +3 -4
- package/lib/listener/result.js +4 -5
- package/lib/listener/steps.js +7 -18
- package/lib/listener/store.js +3 -3
- package/lib/locator.js +213 -192
- package/lib/mocha/asyncWrapper.js +108 -75
- package/lib/mocha/bdd.js +99 -13
- package/lib/mocha/cli.js +60 -27
- package/lib/mocha/factory.js +75 -19
- package/lib/mocha/featureConfig.js +1 -1
- package/lib/mocha/gherkin.js +57 -25
- package/lib/mocha/hooks.js +12 -3
- package/lib/mocha/index.js +13 -4
- package/lib/mocha/inject.js +22 -5
- package/lib/mocha/scenarioConfig.js +2 -2
- package/lib/mocha/suite.js +9 -2
- package/lib/mocha/test.js +10 -13
- package/lib/mocha/ui.js +28 -31
- package/lib/output.js +11 -9
- package/lib/parser.js +44 -44
- package/lib/pause.js +15 -16
- package/lib/plugin/analyze.js +19 -12
- package/lib/plugin/auth.js +20 -21
- package/lib/plugin/autoDelay.js +12 -8
- package/lib/plugin/coverage.js +12 -8
- package/lib/plugin/customLocator.js +3 -3
- package/lib/plugin/customReporter.js +3 -2
- package/lib/plugin/heal.js +14 -9
- package/lib/plugin/pageInfo.js +10 -10
- package/lib/plugin/pauseOnFail.js +4 -3
- package/lib/plugin/retryFailedStep.js +47 -5
- package/lib/plugin/screenshotOnFail.js +75 -37
- package/lib/plugin/stepByStepReport.js +14 -14
- package/lib/plugin/stepTimeout.js +4 -3
- package/lib/plugin/subtitles.js +6 -5
- package/lib/recorder.js +33 -23
- package/lib/rerun.js +69 -26
- package/lib/result.js +4 -4
- package/lib/secret.js +18 -17
- package/lib/session.js +95 -89
- package/lib/step/base.js +6 -6
- package/lib/step/config.js +1 -1
- package/lib/step/func.js +3 -3
- package/lib/step/helper.js +3 -3
- package/lib/step/meta.js +4 -4
- package/lib/step/record.js +11 -11
- package/lib/step/retry.js +3 -3
- package/lib/step/section.js +3 -3
- package/lib/step.js +7 -10
- package/lib/steps.js +9 -5
- package/lib/store.js +1 -1
- package/lib/timeout.js +1 -7
- package/lib/transform.js +8 -8
- package/lib/translation.js +32 -18
- package/lib/utils.js +68 -97
- package/lib/workerStorage.js +16 -17
- package/lib/workers.js +145 -171
- package/package.json +58 -55
- package/translations/de-DE.js +2 -2
- package/translations/fr-FR.js +2 -2
- package/translations/index.js +23 -10
- package/translations/it-IT.js +2 -2
- package/translations/ja-JP.js +2 -2
- package/translations/nl-NL.js +2 -2
- package/translations/pl-PL.js +2 -2
- package/translations/pt-BR.js +2 -2
- package/translations/ru-RU.js +2 -2
- package/translations/utils.js +4 -3
- package/translations/zh-CN.js +2 -2
- package/translations/zh-TW.js +2 -2
- package/typings/index.d.ts +7 -18
- package/typings/promiseBasedTypes.d.ts +3769 -5450
- package/typings/types.d.ts +3953 -5778
- package/bin/test-server.js +0 -53
- package/lib/element/WebElement.js +0 -327
- package/lib/helper/Nightmare.js +0 -1486
- package/lib/helper/Protractor.js +0 -1840
- package/lib/helper/TestCafe.js +0 -1391
- package/lib/helper/clientscripts/nightmare.js +0 -213
- package/lib/helper/extras/PlaywrightReactVueLocator.js +0 -43
- package/lib/helper/testcafe/testControllerHolder.js +0 -42
- package/lib/helper/testcafe/testcafe-utils.js +0 -61
- package/lib/listener/retryEnhancer.js +0 -85
- package/lib/plugin/allure.js +0 -15
- package/lib/plugin/autoLogin.js +0 -5
- package/lib/plugin/commentStep.js +0 -141
- package/lib/plugin/eachElement.js +0 -127
- package/lib/plugin/fakerTransform.js +0 -49
- package/lib/plugin/htmlReporter.js +0 -1947
- package/lib/plugin/retryTo.js +0 -16
- package/lib/plugin/selenoid.js +0 -364
- package/lib/plugin/standardActingHelpers.js +0 -6
- package/lib/plugin/tryTo.js +0 -16
- package/lib/plugin/wdio.js +0 -247
- package/lib/test-server.js +0 -323
- package/lib/within.js +0 -90
package/bin/test-server.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Standalone test server script to replace json-server
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
const path = require('path')
|
|
8
|
-
const TestServer = require('../lib/test-server')
|
|
9
|
-
|
|
10
|
-
// Parse command line arguments
|
|
11
|
-
const args = process.argv.slice(2)
|
|
12
|
-
let dbFile = path.join(__dirname, '../test/data/rest/db.json')
|
|
13
|
-
let port = 8010
|
|
14
|
-
let host = '0.0.0.0'
|
|
15
|
-
|
|
16
|
-
// Simple argument parsing
|
|
17
|
-
for (let i = 0; i < args.length; i++) {
|
|
18
|
-
const arg = args[i]
|
|
19
|
-
|
|
20
|
-
if (arg === '-p' || arg === '--port') {
|
|
21
|
-
port = parseInt(args[++i])
|
|
22
|
-
} else if (arg === '--host') {
|
|
23
|
-
host = args[++i]
|
|
24
|
-
} else if (!arg.startsWith('-')) {
|
|
25
|
-
dbFile = path.resolve(arg)
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// Create and start server
|
|
30
|
-
const server = new TestServer({ port, host, dbFile })
|
|
31
|
-
|
|
32
|
-
console.log(`Starting test server with db file: ${dbFile}`)
|
|
33
|
-
|
|
34
|
-
server
|
|
35
|
-
.start()
|
|
36
|
-
.then(() => {
|
|
37
|
-
console.log(`Test server is ready and listening on http://${host}:${port}`)
|
|
38
|
-
})
|
|
39
|
-
.catch(err => {
|
|
40
|
-
console.error('Failed to start test server:', err)
|
|
41
|
-
process.exit(1)
|
|
42
|
-
})
|
|
43
|
-
|
|
44
|
-
// Graceful shutdown
|
|
45
|
-
process.on('SIGINT', () => {
|
|
46
|
-
console.log('\nShutting down test server...')
|
|
47
|
-
server.stop().then(() => process.exit(0))
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
process.on('SIGTERM', () => {
|
|
51
|
-
console.log('\nShutting down test server...')
|
|
52
|
-
server.stop().then(() => process.exit(0))
|
|
53
|
-
})
|
|
@@ -1,327 +0,0 @@
|
|
|
1
|
-
const assert = require('assert')
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Unified WebElement class that wraps native element instances from different helpers
|
|
5
|
-
* and provides a consistent API across all supported helpers (Playwright, WebDriver, Puppeteer).
|
|
6
|
-
*/
|
|
7
|
-
class WebElement {
|
|
8
|
-
constructor(element, helper) {
|
|
9
|
-
this.element = element
|
|
10
|
-
this.helper = helper
|
|
11
|
-
this.helperType = this._detectHelperType(helper)
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
_detectHelperType(helper) {
|
|
15
|
-
if (!helper) return 'unknown'
|
|
16
|
-
|
|
17
|
-
const className = helper.constructor.name
|
|
18
|
-
if (className === 'Playwright') return 'playwright'
|
|
19
|
-
if (className === 'WebDriver') return 'webdriver'
|
|
20
|
-
if (className === 'Puppeteer') return 'puppeteer'
|
|
21
|
-
|
|
22
|
-
return 'unknown'
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Get the native element instance
|
|
27
|
-
* @returns {ElementHandle|WebElement|ElementHandle} Native element
|
|
28
|
-
*/
|
|
29
|
-
getNativeElement() {
|
|
30
|
-
return this.element
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Get the helper instance
|
|
35
|
-
* @returns {Helper} Helper instance
|
|
36
|
-
*/
|
|
37
|
-
getHelper() {
|
|
38
|
-
return this.helper
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Get text content of the element
|
|
43
|
-
* @returns {Promise<string>} Element text content
|
|
44
|
-
*/
|
|
45
|
-
async getText() {
|
|
46
|
-
switch (this.helperType) {
|
|
47
|
-
case 'playwright':
|
|
48
|
-
return this.element.textContent()
|
|
49
|
-
case 'webdriver':
|
|
50
|
-
return this.element.getText()
|
|
51
|
-
case 'puppeteer':
|
|
52
|
-
return this.element.evaluate(el => el.textContent)
|
|
53
|
-
default:
|
|
54
|
-
throw new Error(`Unsupported helper type: ${this.helperType}`)
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Get attribute value of the element
|
|
60
|
-
* @param {string} name Attribute name
|
|
61
|
-
* @returns {Promise<string|null>} Attribute value
|
|
62
|
-
*/
|
|
63
|
-
async getAttribute(name) {
|
|
64
|
-
switch (this.helperType) {
|
|
65
|
-
case 'playwright':
|
|
66
|
-
return this.element.getAttribute(name)
|
|
67
|
-
case 'webdriver':
|
|
68
|
-
return this.element.getAttribute(name)
|
|
69
|
-
case 'puppeteer':
|
|
70
|
-
return this.element.evaluate((el, attrName) => el.getAttribute(attrName), name)
|
|
71
|
-
default:
|
|
72
|
-
throw new Error(`Unsupported helper type: ${this.helperType}`)
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Get property value of the element
|
|
78
|
-
* @param {string} name Property name
|
|
79
|
-
* @returns {Promise<any>} Property value
|
|
80
|
-
*/
|
|
81
|
-
async getProperty(name) {
|
|
82
|
-
switch (this.helperType) {
|
|
83
|
-
case 'playwright':
|
|
84
|
-
return this.element.evaluate((el, propName) => el[propName], name)
|
|
85
|
-
case 'webdriver':
|
|
86
|
-
return this.element.getProperty(name)
|
|
87
|
-
case 'puppeteer':
|
|
88
|
-
return this.element.evaluate((el, propName) => el[propName], name)
|
|
89
|
-
default:
|
|
90
|
-
throw new Error(`Unsupported helper type: ${this.helperType}`)
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Get innerHTML of the element
|
|
96
|
-
* @returns {Promise<string>} Element innerHTML
|
|
97
|
-
*/
|
|
98
|
-
async getInnerHTML() {
|
|
99
|
-
switch (this.helperType) {
|
|
100
|
-
case 'playwright':
|
|
101
|
-
return this.element.innerHTML()
|
|
102
|
-
case 'webdriver':
|
|
103
|
-
return this.element.getProperty('innerHTML')
|
|
104
|
-
case 'puppeteer':
|
|
105
|
-
return this.element.evaluate(el => el.innerHTML)
|
|
106
|
-
default:
|
|
107
|
-
throw new Error(`Unsupported helper type: ${this.helperType}`)
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Get value of the element (for input elements)
|
|
113
|
-
* @returns {Promise<string>} Element value
|
|
114
|
-
*/
|
|
115
|
-
async getValue() {
|
|
116
|
-
switch (this.helperType) {
|
|
117
|
-
case 'playwright':
|
|
118
|
-
return this.element.inputValue()
|
|
119
|
-
case 'webdriver':
|
|
120
|
-
return this.element.getValue()
|
|
121
|
-
case 'puppeteer':
|
|
122
|
-
return this.element.evaluate(el => el.value)
|
|
123
|
-
default:
|
|
124
|
-
throw new Error(`Unsupported helper type: ${this.helperType}`)
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* Check if element is visible
|
|
130
|
-
* @returns {Promise<boolean>} True if element is visible
|
|
131
|
-
*/
|
|
132
|
-
async isVisible() {
|
|
133
|
-
switch (this.helperType) {
|
|
134
|
-
case 'playwright':
|
|
135
|
-
return this.element.isVisible()
|
|
136
|
-
case 'webdriver':
|
|
137
|
-
return this.element.isDisplayed()
|
|
138
|
-
case 'puppeteer':
|
|
139
|
-
return this.element.evaluate(el => {
|
|
140
|
-
const style = window.getComputedStyle(el)
|
|
141
|
-
return style.display !== 'none' && style.visibility !== 'hidden' && style.opacity !== '0'
|
|
142
|
-
})
|
|
143
|
-
default:
|
|
144
|
-
throw new Error(`Unsupported helper type: ${this.helperType}`)
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* Check if element is enabled
|
|
150
|
-
* @returns {Promise<boolean>} True if element is enabled
|
|
151
|
-
*/
|
|
152
|
-
async isEnabled() {
|
|
153
|
-
switch (this.helperType) {
|
|
154
|
-
case 'playwright':
|
|
155
|
-
return this.element.isEnabled()
|
|
156
|
-
case 'webdriver':
|
|
157
|
-
return this.element.isEnabled()
|
|
158
|
-
case 'puppeteer':
|
|
159
|
-
return this.element.evaluate(el => !el.disabled)
|
|
160
|
-
default:
|
|
161
|
-
throw new Error(`Unsupported helper type: ${this.helperType}`)
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* Check if element exists in DOM
|
|
167
|
-
* @returns {Promise<boolean>} True if element exists
|
|
168
|
-
*/
|
|
169
|
-
async exists() {
|
|
170
|
-
try {
|
|
171
|
-
switch (this.helperType) {
|
|
172
|
-
case 'playwright':
|
|
173
|
-
// For Playwright, if we have the element, it exists
|
|
174
|
-
return await this.element.evaluate(el => !!el)
|
|
175
|
-
case 'webdriver':
|
|
176
|
-
// For WebDriver, if we have the element, it exists
|
|
177
|
-
return true
|
|
178
|
-
case 'puppeteer':
|
|
179
|
-
// For Puppeteer, if we have the element, it exists
|
|
180
|
-
return await this.element.evaluate(el => !!el)
|
|
181
|
-
default:
|
|
182
|
-
throw new Error(`Unsupported helper type: ${this.helperType}`)
|
|
183
|
-
}
|
|
184
|
-
} catch (e) {
|
|
185
|
-
return false
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* Get bounding box of the element
|
|
191
|
-
* @returns {Promise<Object>} Bounding box with x, y, width, height properties
|
|
192
|
-
*/
|
|
193
|
-
async getBoundingBox() {
|
|
194
|
-
switch (this.helperType) {
|
|
195
|
-
case 'playwright':
|
|
196
|
-
return this.element.boundingBox()
|
|
197
|
-
case 'webdriver':
|
|
198
|
-
const rect = await this.element.getRect()
|
|
199
|
-
return {
|
|
200
|
-
x: rect.x,
|
|
201
|
-
y: rect.y,
|
|
202
|
-
width: rect.width,
|
|
203
|
-
height: rect.height,
|
|
204
|
-
}
|
|
205
|
-
case 'puppeteer':
|
|
206
|
-
return this.element.boundingBox()
|
|
207
|
-
default:
|
|
208
|
-
throw new Error(`Unsupported helper type: ${this.helperType}`)
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
/**
|
|
213
|
-
* Click the element
|
|
214
|
-
* @param {Object} options Click options
|
|
215
|
-
* @returns {Promise<void>}
|
|
216
|
-
*/
|
|
217
|
-
async click(options = {}) {
|
|
218
|
-
switch (this.helperType) {
|
|
219
|
-
case 'playwright':
|
|
220
|
-
return this.element.click(options)
|
|
221
|
-
case 'webdriver':
|
|
222
|
-
return this.element.click()
|
|
223
|
-
case 'puppeteer':
|
|
224
|
-
return this.element.click(options)
|
|
225
|
-
default:
|
|
226
|
-
throw new Error(`Unsupported helper type: ${this.helperType}`)
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
/**
|
|
231
|
-
* Type text into the element
|
|
232
|
-
* @param {string} text Text to type
|
|
233
|
-
* @param {Object} options Type options
|
|
234
|
-
* @returns {Promise<void>}
|
|
235
|
-
*/
|
|
236
|
-
async type(text, options = {}) {
|
|
237
|
-
switch (this.helperType) {
|
|
238
|
-
case 'playwright':
|
|
239
|
-
return this.element.type(text, options)
|
|
240
|
-
case 'webdriver':
|
|
241
|
-
return this.element.setValue(text)
|
|
242
|
-
case 'puppeteer':
|
|
243
|
-
return this.element.type(text, options)
|
|
244
|
-
default:
|
|
245
|
-
throw new Error(`Unsupported helper type: ${this.helperType}`)
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
/**
|
|
250
|
-
* Find first child element matching the locator
|
|
251
|
-
* @param {string|Object} locator Element locator
|
|
252
|
-
* @returns {Promise<WebElement|null>} WebElement instance or null if not found
|
|
253
|
-
*/
|
|
254
|
-
async $(locator) {
|
|
255
|
-
let childElement
|
|
256
|
-
|
|
257
|
-
switch (this.helperType) {
|
|
258
|
-
case 'playwright':
|
|
259
|
-
childElement = await this.element.$(this._normalizeLocator(locator))
|
|
260
|
-
break
|
|
261
|
-
case 'webdriver':
|
|
262
|
-
try {
|
|
263
|
-
childElement = await this.element.$(this._normalizeLocator(locator))
|
|
264
|
-
} catch (e) {
|
|
265
|
-
return null
|
|
266
|
-
}
|
|
267
|
-
break
|
|
268
|
-
case 'puppeteer':
|
|
269
|
-
childElement = await this.element.$(this._normalizeLocator(locator))
|
|
270
|
-
break
|
|
271
|
-
default:
|
|
272
|
-
throw new Error(`Unsupported helper type: ${this.helperType}`)
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
return childElement ? new WebElement(childElement, this.helper) : null
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
/**
|
|
279
|
-
* Find all child elements matching the locator
|
|
280
|
-
* @param {string|Object} locator Element locator
|
|
281
|
-
* @returns {Promise<WebElement[]>} Array of WebElement instances
|
|
282
|
-
*/
|
|
283
|
-
async $$(locator) {
|
|
284
|
-
let childElements
|
|
285
|
-
|
|
286
|
-
switch (this.helperType) {
|
|
287
|
-
case 'playwright':
|
|
288
|
-
childElements = await this.element.$$(this._normalizeLocator(locator))
|
|
289
|
-
break
|
|
290
|
-
case 'webdriver':
|
|
291
|
-
childElements = await this.element.$$(this._normalizeLocator(locator))
|
|
292
|
-
break
|
|
293
|
-
case 'puppeteer':
|
|
294
|
-
childElements = await this.element.$$(this._normalizeLocator(locator))
|
|
295
|
-
break
|
|
296
|
-
default:
|
|
297
|
-
throw new Error(`Unsupported helper type: ${this.helperType}`)
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
return childElements.map(el => new WebElement(el, this.helper))
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
/**
|
|
304
|
-
* Normalize locator for element search
|
|
305
|
-
* @param {string|Object} locator Locator to normalize
|
|
306
|
-
* @returns {string} Normalized CSS selector
|
|
307
|
-
* @private
|
|
308
|
-
*/
|
|
309
|
-
_normalizeLocator(locator) {
|
|
310
|
-
if (typeof locator === 'string') {
|
|
311
|
-
return locator
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
if (typeof locator === 'object') {
|
|
315
|
-
// Handle CodeceptJS locator objects
|
|
316
|
-
if (locator.css) return locator.css
|
|
317
|
-
if (locator.xpath) return locator.xpath
|
|
318
|
-
if (locator.id) return `#${locator.id}`
|
|
319
|
-
if (locator.name) return `[name="${locator.name}"]`
|
|
320
|
-
if (locator.className) return `.${locator.className}`
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
return locator.toString()
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
module.exports = WebElement
|