codeceptjs 4.0.1-beta.16 → 4.0.1-beta.18
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/lib/command/definitions.js +1 -1
- package/lib/helper/Playwright.js +5 -0
- package/lib/locator.js +53 -1
- package/package.json +11 -11
- package/typings/promiseBasedTypes.d.ts +3823 -5557
- package/typings/types.d.ts +4013 -5991
|
@@ -41,7 +41,7 @@ const getDefinitionsFileContent = ({ hasCustomHelper, hasCustomStepsFile, helper
|
|
|
41
41
|
|
|
42
42
|
const importPathsFragment = importPaths.join('\n')
|
|
43
43
|
const supportObjectsTypeFragment = convertMapToType(supportObject)
|
|
44
|
-
const methodsTypeFragment = helperNames.length > 0 ? `interface Methods extends ${helperNames.join(', ')} {}` : ''
|
|
44
|
+
const methodsTypeFragment = helperNames.length > 0 ? `interface Methods extends ${helperNames.join(', ')} {}` : 'interface Methods {}'
|
|
45
45
|
const translatedActionsFragment = JSON.stringify(translations.vocabulary.actions, null, 2)
|
|
46
46
|
|
|
47
47
|
return generateDefinitionsContent({
|
package/lib/helper/Playwright.js
CHANGED
|
@@ -4306,6 +4306,11 @@ function buildLocatorString(locator) {
|
|
|
4306
4306
|
if (locator.isXPath()) {
|
|
4307
4307
|
return `xpath=${locator.value}`
|
|
4308
4308
|
}
|
|
4309
|
+
if (locator.isJson()) {
|
|
4310
|
+
// For JSON locators, pass the entire object to Playwright
|
|
4311
|
+
// Playwright natively supports role locator objects
|
|
4312
|
+
return locator.value
|
|
4313
|
+
}
|
|
4309
4314
|
return locator.simplify()
|
|
4310
4315
|
}
|
|
4311
4316
|
|
package/lib/locator.js
CHANGED
|
@@ -5,7 +5,7 @@ import { createRequire } from 'module'
|
|
|
5
5
|
const require = createRequire(import.meta.url)
|
|
6
6
|
let cssToXPath
|
|
7
7
|
|
|
8
|
-
const locatorTypes = ['css', 'by', 'xpath', 'id', 'name', 'fuzzy', 'frame', 'shadow', 'pw', 'role']
|
|
8
|
+
const locatorTypes = ['css', 'by', 'xpath', 'id', 'name', 'fuzzy', 'frame', 'shadow', 'pw', 'role', 'json']
|
|
9
9
|
/** @class */
|
|
10
10
|
class Locator {
|
|
11
11
|
/**
|
|
@@ -40,6 +40,11 @@ class Locator {
|
|
|
40
40
|
return
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
// Try to parse JSON strings that look like objects
|
|
44
|
+
if (this.parsedJsonAsString(locator)) {
|
|
45
|
+
return
|
|
46
|
+
}
|
|
47
|
+
|
|
43
48
|
this.type = defaultType || 'fuzzy'
|
|
44
49
|
this.output = locator
|
|
45
50
|
this.value = locator
|
|
@@ -80,6 +85,8 @@ class Locator {
|
|
|
80
85
|
return { pw: this.value }
|
|
81
86
|
case 'role':
|
|
82
87
|
return `[role="${this.value}"]`
|
|
88
|
+
case 'json':
|
|
89
|
+
return { json: this.value }
|
|
83
90
|
}
|
|
84
91
|
return this.value
|
|
85
92
|
}
|
|
@@ -89,6 +96,44 @@ class Locator {
|
|
|
89
96
|
return { [this.type]: this.value }
|
|
90
97
|
}
|
|
91
98
|
|
|
99
|
+
parsedJsonAsString(locator) {
|
|
100
|
+
if (typeof locator !== 'string') {
|
|
101
|
+
return false
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const trimmed = locator.trim()
|
|
105
|
+
if (!trimmed.startsWith('{') || !trimmed.endsWith('}')) {
|
|
106
|
+
return false
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
try {
|
|
110
|
+
const parsed = JSON.parse(trimmed)
|
|
111
|
+
if (typeof parsed === 'object' && parsed !== null && !Array.isArray(parsed)) {
|
|
112
|
+
this.locator = parsed
|
|
113
|
+
|
|
114
|
+
// Check if this is a multi-property JSON (like aria locators)
|
|
115
|
+
const keys = Object.keys(parsed)
|
|
116
|
+
if (keys.length > 1) {
|
|
117
|
+
// For multi-property objects, treat the entire JSON as the value
|
|
118
|
+
// with a special type to preserve all properties
|
|
119
|
+
this.type = 'json'
|
|
120
|
+
this.value = parsed
|
|
121
|
+
} else {
|
|
122
|
+
// Single property - use existing logic
|
|
123
|
+
this.type = keys[0]
|
|
124
|
+
this.value = parsed[keys[0]]
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
this.strict = true
|
|
128
|
+
Locator.filters.forEach(f => f(parsed, this))
|
|
129
|
+
return true
|
|
130
|
+
}
|
|
131
|
+
} catch (e) {
|
|
132
|
+
// continue with normal string processing
|
|
133
|
+
}
|
|
134
|
+
return false
|
|
135
|
+
}
|
|
136
|
+
|
|
92
137
|
/**
|
|
93
138
|
* @returns {string}
|
|
94
139
|
*/
|
|
@@ -138,6 +183,13 @@ class Locator {
|
|
|
138
183
|
return this.type === 'role'
|
|
139
184
|
}
|
|
140
185
|
|
|
186
|
+
/**
|
|
187
|
+
* @returns {boolean}
|
|
188
|
+
*/
|
|
189
|
+
isJson() {
|
|
190
|
+
return this.type === 'json'
|
|
191
|
+
}
|
|
192
|
+
|
|
141
193
|
/**
|
|
142
194
|
* @returns {boolean}
|
|
143
195
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codeceptjs",
|
|
3
|
-
"version": "4.0.1-beta.
|
|
3
|
+
"version": "4.0.1-beta.18",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Supercharged End 2 End Testing Framework for NodeJS",
|
|
6
6
|
"keywords": [
|
|
@@ -88,13 +88,13 @@
|
|
|
88
88
|
"@codeceptjs/configure": "1.0.6",
|
|
89
89
|
"@codeceptjs/helper": "2.0.4",
|
|
90
90
|
"@cucumber/cucumber-expressions": "18",
|
|
91
|
-
"@cucumber/gherkin": "
|
|
92
|
-
"@cucumber/messages": "
|
|
91
|
+
"@cucumber/gherkin": "37.0.0",
|
|
92
|
+
"@cucumber/messages": "31.0.0",
|
|
93
93
|
"@xmldom/xmldom": "0.9.8",
|
|
94
94
|
"acorn": "8.15.0",
|
|
95
95
|
"ai": "^5.0.60",
|
|
96
96
|
"arrify": "3.0.0",
|
|
97
|
-
"axios": "1.
|
|
97
|
+
"axios": "1.13.2",
|
|
98
98
|
"chalk": "4.1.2",
|
|
99
99
|
"cheerio": "^1.0.0",
|
|
100
100
|
"chokidar": "^4.0.3",
|
|
@@ -108,11 +108,11 @@
|
|
|
108
108
|
"fn-args": "4.0.0",
|
|
109
109
|
"fs-extra": "11.3.2",
|
|
110
110
|
"fuse.js": "^7.0.0",
|
|
111
|
-
"glob": ">=9.0.0 <
|
|
111
|
+
"glob": ">=9.0.0 <14",
|
|
112
112
|
"html-minifier-terser": "7.2.0",
|
|
113
113
|
"inquirer": "^8.2.7",
|
|
114
114
|
"invisi-data": "^1.0.0",
|
|
115
|
-
"joi": "18.0.
|
|
115
|
+
"joi": "18.0.2",
|
|
116
116
|
"js-beautify": "1.15.4",
|
|
117
117
|
"lodash.clonedeep": "4.5.0",
|
|
118
118
|
"lodash.merge": "4.6.2",
|
|
@@ -149,7 +149,7 @@
|
|
|
149
149
|
"@types/node": "^24.9.2",
|
|
150
150
|
"@wdio/sauce-service": "9.12.5",
|
|
151
151
|
"@wdio/selenium-standalone-service": "8.15.0",
|
|
152
|
-
"@wdio/utils": "9.
|
|
152
|
+
"@wdio/utils": "9.21.0",
|
|
153
153
|
"@xmldom/xmldom": "0.9.8",
|
|
154
154
|
"bunosh": "latest",
|
|
155
155
|
"chai": "^6.2.1",
|
|
@@ -162,8 +162,8 @@
|
|
|
162
162
|
"eslint-plugin-mocha": "11.1.0",
|
|
163
163
|
"expect": "30.2.0",
|
|
164
164
|
"express": "^5.1.0",
|
|
165
|
-
"globals": "16.
|
|
166
|
-
"graphql": "16.
|
|
165
|
+
"globals": "16.5.0",
|
|
166
|
+
"graphql": "16.12.0",
|
|
167
167
|
"graphql-tag": "^2.12.6",
|
|
168
168
|
"husky": "9.1.7",
|
|
169
169
|
"jsdoc": "^3.6.11",
|
|
@@ -172,7 +172,7 @@
|
|
|
172
172
|
"mochawesome": "^7.1.3",
|
|
173
173
|
"playwright": "1.55.1",
|
|
174
174
|
"prettier": "^3.3.2",
|
|
175
|
-
"puppeteer": "24.
|
|
175
|
+
"puppeteer": "24.33.0",
|
|
176
176
|
"qrcode-terminal": "0.12.0",
|
|
177
177
|
"rosie": "2.1.1",
|
|
178
178
|
"runok": "^0.9.3",
|
|
@@ -184,7 +184,7 @@
|
|
|
184
184
|
"tsd": "^0.33.0",
|
|
185
185
|
"tsd-jsdoc": "2.5.0",
|
|
186
186
|
"tsx": "^4.19.2",
|
|
187
|
-
"typedoc": "0.28.
|
|
187
|
+
"typedoc": "0.28.15",
|
|
188
188
|
"typedoc-plugin-markdown": "4.9.0",
|
|
189
189
|
"typescript": "5.8.3",
|
|
190
190
|
"wdio-docker-service": "3.2.1",
|