@dev-blinq/cucumber_client 1.0.1694-dev → 1.0.1695-dev
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.
|
@@ -86,6 +86,30 @@ const parseDataSource = (paramNode, stepParams) => {
|
|
|
86
86
|
// }
|
|
87
87
|
throw new Error("Unknown parameter type");
|
|
88
88
|
};
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
const parseOptions = (optionsNode) => {
|
|
92
|
+
const properties = optionsNode.properties;
|
|
93
|
+
const options = {}
|
|
94
|
+
for (const prop of properties) {
|
|
95
|
+
let key = "";
|
|
96
|
+
if (prop.key.type === 'Identifier') {
|
|
97
|
+
key = prop.key.name;
|
|
98
|
+
} else if (prop.key.type === 'StringLiteral') {
|
|
99
|
+
key = prop.key.value;
|
|
100
|
+
}
|
|
101
|
+
if (key === 'context') continue;
|
|
102
|
+
options[key] = prop.value.value;
|
|
103
|
+
}
|
|
104
|
+
return options;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const parseOptionsFromCallNode = (call, index) => {
|
|
108
|
+
if (call.arguments[index] && call.arguments[index].type === "ObjectExpression") {
|
|
109
|
+
return parseOptions(call.arguments[index]);
|
|
110
|
+
}
|
|
111
|
+
return null
|
|
112
|
+
}
|
|
89
113
|
const invertStableCommand = (call, elements, stepParams) => {
|
|
90
114
|
const methodName = call.callee.property.name;
|
|
91
115
|
const step = { type: null, parameters: [], element: null, locators: null };
|
|
@@ -104,6 +128,7 @@ const invertStableCommand = (call, elements, stepParams) => {
|
|
|
104
128
|
step.dataSource = inputParam.dataSource;
|
|
105
129
|
step.dataKey = inputParam.dataKey;
|
|
106
130
|
}
|
|
131
|
+
step.options = parseOptionsFromCallNode(call, 3);
|
|
107
132
|
break;
|
|
108
133
|
}
|
|
109
134
|
|
|
@@ -130,6 +155,8 @@ const invertStableCommand = (call, elements, stepParams) => {
|
|
|
130
155
|
step.count = clickCountProp.value.value;
|
|
131
156
|
}
|
|
132
157
|
}
|
|
158
|
+
|
|
159
|
+
step.options = parseOptionsFromCallNode(call, 2);
|
|
133
160
|
break;
|
|
134
161
|
|
|
135
162
|
case "setDateTime": {
|
|
@@ -147,6 +174,7 @@ const invertStableCommand = (call, elements, stepParams) => {
|
|
|
147
174
|
step.dataKey = dateParam.dataKey;
|
|
148
175
|
step.parameters = [toVariableName(dateParam.dataKey), format, enterParam];
|
|
149
176
|
}
|
|
177
|
+
step.options = parseOptionsFromCallNode(call, 5);
|
|
150
178
|
break;
|
|
151
179
|
}
|
|
152
180
|
|
|
@@ -163,6 +191,7 @@ const invertStableCommand = (call, elements, stepParams) => {
|
|
|
163
191
|
step.dataKey = selectParam.dataKey;
|
|
164
192
|
step.parameters = [toVariableName(selectParam.dataKey)];
|
|
165
193
|
}
|
|
194
|
+
step.options = parseOptionsFromCallNode(call, 3);
|
|
166
195
|
break;
|
|
167
196
|
}
|
|
168
197
|
|
|
@@ -176,6 +205,7 @@ const invertStableCommand = (call, elements, stepParams) => {
|
|
|
176
205
|
step.dataKey = text.dataKey;
|
|
177
206
|
step.parameters = [toVariableName(text.dataKey)];
|
|
178
207
|
}
|
|
208
|
+
step.options = parseOptionsFromCallNode(call, 2);
|
|
179
209
|
break;
|
|
180
210
|
}
|
|
181
211
|
case "waitForTextToDisappear": {
|
|
@@ -188,6 +218,7 @@ const invertStableCommand = (call, elements, stepParams) => {
|
|
|
188
218
|
step.dataKey = text.dataKey;
|
|
189
219
|
step.parameters = [toVariableName(text.dataKey)];
|
|
190
220
|
}
|
|
221
|
+
step.options = parseOptionsFromCallNode(call, 2);
|
|
191
222
|
break;
|
|
192
223
|
}
|
|
193
224
|
|
|
@@ -203,6 +234,7 @@ const invertStableCommand = (call, elements, stepParams) => {
|
|
|
203
234
|
step.dataKey = text.dataKey;
|
|
204
235
|
step.parameters = [toVariableName(text.dataKey), climb ?? null];
|
|
205
236
|
}
|
|
237
|
+
step.options = parseOptionsFromCallNode(call, 4);
|
|
206
238
|
break;
|
|
207
239
|
}
|
|
208
240
|
case "extractAttribute": {
|
|
@@ -233,6 +265,7 @@ const invertStableCommand = (call, elements, stepParams) => {
|
|
|
233
265
|
step.regex = "";
|
|
234
266
|
step.trimSpaces = false;
|
|
235
267
|
}
|
|
268
|
+
step.options = parseOptionsFromCallNode(call, 4);
|
|
236
269
|
break;
|
|
237
270
|
}
|
|
238
271
|
case "verifyAttribute": {
|
|
@@ -249,6 +282,7 @@ const invertStableCommand = (call, elements, stepParams) => {
|
|
|
249
282
|
step.dataKey = value.dataKey;
|
|
250
283
|
step.parameters = [attribute, toVariableName(value.dataKey)];
|
|
251
284
|
}
|
|
285
|
+
step.options = parseOptionsFromCallNode(call, 4);
|
|
252
286
|
break;
|
|
253
287
|
}
|
|
254
288
|
|
|
@@ -277,6 +311,7 @@ const invertStableCommand = (call, elements, stepParams) => {
|
|
|
277
311
|
step.parameters = [toVariableName(fillParam.dataKey), enterValue];
|
|
278
312
|
}
|
|
279
313
|
}
|
|
314
|
+
step.options = parseOptionsFromCallNode(call, 4);
|
|
280
315
|
break;
|
|
281
316
|
|
|
282
317
|
case "loadTestDataAsync": {
|
|
@@ -307,23 +342,28 @@ const invertStableCommand = (call, elements, stepParams) => {
|
|
|
307
342
|
step.dataKey = url.dataKey;
|
|
308
343
|
step.parameters = [toVariableName(url.dataKey)];
|
|
309
344
|
}
|
|
345
|
+
step.options = parseOptionsFromCallNode(call, 2);
|
|
310
346
|
break;
|
|
311
347
|
}
|
|
312
348
|
|
|
313
349
|
case "goBack":
|
|
314
350
|
step.type = Types.GO_BACK;
|
|
351
|
+
step.options = parseOptionsFromCallNode(call, 0);
|
|
315
352
|
break;
|
|
316
353
|
|
|
317
354
|
case "goForward":
|
|
318
355
|
step.type = Types.GO_FORWARD;
|
|
356
|
+
step.options = parseOptionsFromCallNode(call, 0);
|
|
319
357
|
break;
|
|
320
358
|
|
|
321
359
|
case "reloadPage":
|
|
322
360
|
step.type = Types.RELOAD;
|
|
361
|
+
step.options = parseOptionsFromCallNode(call, 0);
|
|
323
362
|
break;
|
|
324
363
|
|
|
325
364
|
case "closePage":
|
|
326
365
|
step.type = Types.CLOSE_PAGE;
|
|
366
|
+
step.options = parseOptionsFromCallNode(call, 0);
|
|
327
367
|
break;
|
|
328
368
|
|
|
329
369
|
case "simpleClick":
|
|
@@ -341,12 +381,15 @@ const invertStableCommand = (call, elements, stepParams) => {
|
|
|
341
381
|
case "hover":
|
|
342
382
|
step.type = Types.HOVER;
|
|
343
383
|
step.element = extractElement(call.arguments[0]);
|
|
384
|
+
step.options = parseOptionsFromCallNode(call, 2);
|
|
344
385
|
break;
|
|
345
386
|
|
|
346
387
|
case "setCheck":
|
|
347
388
|
step.type = Types.CHECK;
|
|
348
389
|
step.element = extractElement(call.arguments[0]);
|
|
349
390
|
step.check = call.arguments[1].value;
|
|
391
|
+
///
|
|
392
|
+
step.options = parseOptionsFromCallNode(call, 3);
|
|
350
393
|
break;
|
|
351
394
|
|
|
352
395
|
case "setViewportSize": {
|
|
@@ -354,12 +397,14 @@ const invertStableCommand = (call, elements, stepParams) => {
|
|
|
354
397
|
const width = call.arguments[0].value;
|
|
355
398
|
const height = call.arguments[1].value;
|
|
356
399
|
step.parameters = [width, height];
|
|
400
|
+
step.options = parseOptionsFromCallNode(call, 2);
|
|
357
401
|
break;
|
|
358
402
|
}
|
|
359
403
|
|
|
360
404
|
case "visualVerification": {
|
|
361
405
|
step.type = Types.VISUAL_VERIFICATION;
|
|
362
406
|
step.parameters = [call.arguments[0].value];
|
|
407
|
+
step.options = parseOptionsFromCallNode(call, 1);
|
|
363
408
|
break;
|
|
364
409
|
}
|
|
365
410
|
case "waitForUserInput": {
|
|
@@ -370,6 +415,7 @@ const invertStableCommand = (call, elements, stepParams) => {
|
|
|
370
415
|
case "extractEmailData": {
|
|
371
416
|
step.type = Types.MAIL_GET_CODE_OR_URL;
|
|
372
417
|
step.parameters = [call.arguments[0].value];
|
|
418
|
+
step.options = parseOptionsFromCallNode(call, 1);
|
|
373
419
|
break;
|
|
374
420
|
}
|
|
375
421
|
case "verifyTextRelatedToText": {
|
|
@@ -383,6 +429,7 @@ const invertStableCommand = (call, elements, stepParams) => {
|
|
|
383
429
|
const textToVerify =
|
|
384
430
|
textToVerifyParse.type === "literal" ? textToVerifyParse.value : toVariableName(textToVerifyParse.dataKey);
|
|
385
431
|
step.parameters = [textAnchor, climb, textToVerify];
|
|
432
|
+
step.options = parseOptionsFromCallNode(call, 3);
|
|
386
433
|
break;
|
|
387
434
|
}
|
|
388
435
|
case "setInputFiles": {
|
|
@@ -396,6 +443,7 @@ const invertStableCommand = (call, elements, stepParams) => {
|
|
|
396
443
|
step.dataKey = fileParam.dataKey;
|
|
397
444
|
step.parameters = [toVariableName(fileParam.dataKey)];
|
|
398
445
|
}
|
|
446
|
+
step.options = parseOptionsFromCallNode(call, 3);
|
|
399
447
|
break;
|
|
400
448
|
}
|
|
401
449
|
case "snapshotValidation": {
|
|
@@ -405,6 +453,7 @@ const invertStableCommand = (call, elements, stepParams) => {
|
|
|
405
453
|
step.parameters = [inputParam.value];
|
|
406
454
|
}
|
|
407
455
|
step.selectors = call.arguments[0].value;
|
|
456
|
+
step.options = parseOptionsFromCallNode(call, 3);
|
|
408
457
|
break;
|
|
409
458
|
}
|
|
410
459
|
case "verifyPageTitle": {
|
|
@@ -417,6 +466,7 @@ const invertStableCommand = (call, elements, stepParams) => {
|
|
|
417
466
|
step.dataKey = text.dataKey;
|
|
418
467
|
step.parameters = [toVariableName(text.dataKey)];
|
|
419
468
|
}
|
|
469
|
+
step.options = parseOptionsFromCallNode(call, 1);
|
|
420
470
|
break;
|
|
421
471
|
}
|
|
422
472
|
case "verifyPagePath": {
|
|
@@ -429,6 +479,7 @@ const invertStableCommand = (call, elements, stepParams) => {
|
|
|
429
479
|
step.dataKey = path.dataKey;
|
|
430
480
|
step.parameters = [toVariableName(path.dataKey)];
|
|
431
481
|
}
|
|
482
|
+
step.options = parseOptionsFromCallNode(call, 1);
|
|
432
483
|
break;
|
|
433
484
|
}
|
|
434
485
|
case "verifyProperty": {
|
|
@@ -443,6 +494,7 @@ const invertStableCommand = (call, elements, stepParams) => {
|
|
|
443
494
|
step.dataKey = value.dataKey;
|
|
444
495
|
step.parameters = [property, toVariableName(value.dataKey)];
|
|
445
496
|
}
|
|
497
|
+
step.options = parseOptionsFromCallNode(call, 4);
|
|
446
498
|
break;
|
|
447
499
|
}
|
|
448
500
|
case "extractProperty": {
|
|
@@ -473,6 +525,7 @@ const invertStableCommand = (call, elements, stepParams) => {
|
|
|
473
525
|
step.regex = "";
|
|
474
526
|
step.trimSpaces = false;
|
|
475
527
|
}
|
|
528
|
+
step.options = parseOptionsFromCallNode(call, 4);
|
|
476
529
|
break;
|
|
477
530
|
}
|
|
478
531
|
|
|
@@ -497,6 +550,7 @@ const invertStableCommand = (call, elements, stepParams) => {
|
|
|
497
550
|
// step.value = "true";
|
|
498
551
|
step.parameters = [timeout, condition, step.value];
|
|
499
552
|
// step.condition = condition;
|
|
553
|
+
step.options = parseOptionsFromCallNode(call, 4);
|
|
500
554
|
break;
|
|
501
555
|
}
|
|
502
556
|
|
|
@@ -513,6 +567,7 @@ const invertStableCommand = (call, elements, stepParams) => {
|
|
|
513
567
|
step.dataKey = duration.dataKey;
|
|
514
568
|
step.parameters = [toVariableName(duration.dataKey)];
|
|
515
569
|
}
|
|
570
|
+
step.options = parseOptionsFromCallNode(call, 1);
|
|
516
571
|
break;
|
|
517
572
|
}
|
|
518
573
|
case "verify_file_exists": {
|
|
@@ -525,6 +580,7 @@ const invertStableCommand = (call, elements, stepParams) => {
|
|
|
525
580
|
step.dataKey = filePath.dataKey;
|
|
526
581
|
step.parameters = [toVariableName(filePath.dataKey)];
|
|
527
582
|
}
|
|
583
|
+
step.options = parseOptionsFromCallNode(call, 1);
|
|
528
584
|
break;
|
|
529
585
|
}
|
|
530
586
|
|
|
@@ -49,6 +49,7 @@ const findElementIdentifier = (node, step, userData, elements) => {
|
|
|
49
49
|
return elementIdentifier;
|
|
50
50
|
};
|
|
51
51
|
const _isCodeGenerationStep = (step) => {
|
|
52
|
+
return true;
|
|
52
53
|
if (
|
|
53
54
|
step.type === Types.CLICK ||
|
|
54
55
|
step.type === Types.FILL ||
|
|
@@ -81,6 +82,27 @@ const _isLocatorStrategyStep = (step) => {
|
|
|
81
82
|
switch (step.type) {
|
|
82
83
|
case Types.VERIFY_PAGE_SNAPSHOT:
|
|
83
84
|
case Types.CLOSE_PAGE:
|
|
85
|
+
case Types.VERIFY_FILE_EXISTS:
|
|
86
|
+
case Types.VERIFY_PAGE_CONTAINS_NO_TEXT:
|
|
87
|
+
case Types.VERIFY_PAGE_CONTAINS_TEXT:
|
|
88
|
+
case Types.VERIFY_PAGE_PATH:
|
|
89
|
+
case Types.VERIFY_PAGE_TITLE:
|
|
90
|
+
case Types.VERIFY_TEXT_RELATED_TO_TEXT:
|
|
91
|
+
case Types.NAVIGATE:
|
|
92
|
+
case Types.RELOAD:
|
|
93
|
+
case Types.GO_BACK:
|
|
94
|
+
case Types.GO_FORWARD:
|
|
95
|
+
case Types.SLEEP:
|
|
96
|
+
case Types.SET_VIEWPORT:
|
|
97
|
+
case Types.VISUAL_VERIFICATION:
|
|
98
|
+
case Types.LOAD_DATA:
|
|
99
|
+
case Types.MAIL_GET_CODE_OR_URL:
|
|
100
|
+
case Types.ASK:
|
|
101
|
+
case Types.WAIT_FOR_USER_INPUT:
|
|
102
|
+
case Types.COMPLETE:
|
|
103
|
+
case Types.CLICK_SIMPLE:
|
|
104
|
+
case Types.FILL_SIMPLE:
|
|
105
|
+
case Types.API:
|
|
84
106
|
return false;
|
|
85
107
|
default:
|
|
86
108
|
return true;
|
|
@@ -110,6 +132,20 @@ const splitToLocatorsGroups = (locators) => {
|
|
|
110
132
|
});
|
|
111
133
|
return { basic, no_text, ignore_digit, context };
|
|
112
134
|
};
|
|
135
|
+
|
|
136
|
+
const serializeOptions = (options, context) => {
|
|
137
|
+
if (!options) return "null";
|
|
138
|
+
if (typeof options !== 'object') return "null";
|
|
139
|
+
if (Array.isArray(options)) return "null";
|
|
140
|
+
let result = "{ ";
|
|
141
|
+
if (context) result += `"context": ${context}, `;
|
|
142
|
+
for (const key in options) {
|
|
143
|
+
result += `"${key}": ${JSON.stringify(options[key])}, `;
|
|
144
|
+
}
|
|
145
|
+
result += " }";
|
|
146
|
+
return result;
|
|
147
|
+
}
|
|
148
|
+
|
|
113
149
|
const _generateCodeFromCommand = (step, elements, userData) => {
|
|
114
150
|
let elementsChanged = false;
|
|
115
151
|
|
|
@@ -192,7 +228,7 @@ const _generateCodeFromCommand = (step, elements, userData) => {
|
|
|
192
228
|
let attribute = null;
|
|
193
229
|
let variable = null;
|
|
194
230
|
let format = null;
|
|
195
|
-
let options = null;
|
|
231
|
+
let options = step.options ?? null;
|
|
196
232
|
let property = null;
|
|
197
233
|
switch (step.type) {
|
|
198
234
|
case Types.SET_INPUT:
|
|
@@ -202,7 +238,7 @@ const _generateCodeFromCommand = (step, elements, userData) => {
|
|
|
202
238
|
//parameters.push(step.dataKey);
|
|
203
239
|
input = "_" + step.dataKey;
|
|
204
240
|
}
|
|
205
|
-
line += `${input}, _params,
|
|
241
|
+
line += `${input}, _params, ${serializeOptions(options)}, this);`;
|
|
206
242
|
if (element_name) {
|
|
207
243
|
comment = `// Set ${element_name} to ${input}`;
|
|
208
244
|
codeLines.push(escapeNonPrintables(comment));
|
|
@@ -215,7 +251,7 @@ const _generateCodeFromCommand = (step, elements, userData) => {
|
|
|
215
251
|
comment = `// Check ${element_name}`;
|
|
216
252
|
codeLines.push(escapeNonPrintables(comment));
|
|
217
253
|
}
|
|
218
|
-
line = `await context.web.setCheck(elements["${elementIdentifier}"], ${step.check}, _params,
|
|
254
|
+
line = `await context.web.setCheck(elements["${elementIdentifier}"], ${step.check}, _params, ${serializeOptions(options)}, this);`;
|
|
219
255
|
codeLines.push(line);
|
|
220
256
|
} else {
|
|
221
257
|
switch (step.count) {
|
|
@@ -224,7 +260,7 @@ const _generateCodeFromCommand = (step, elements, userData) => {
|
|
|
224
260
|
comment = `// Click on ${element_name}`;
|
|
225
261
|
codeLines.push(escapeNonPrintables(comment));
|
|
226
262
|
}
|
|
227
|
-
line = `await context.web.click(elements["${elementIdentifier}"], _params,
|
|
263
|
+
line = `await context.web.click(elements["${elementIdentifier}"], _params, ${serializeOptions(options)}, this);`;
|
|
228
264
|
codeLines.push(line);
|
|
229
265
|
break;
|
|
230
266
|
case 2:
|
|
@@ -232,7 +268,9 @@ const _generateCodeFromCommand = (step, elements, userData) => {
|
|
|
232
268
|
comment = `// Double click on ${element_name}`;
|
|
233
269
|
codeLines.push(escapeNonPrintables(comment));
|
|
234
270
|
}
|
|
235
|
-
|
|
271
|
+
options = options ?? {};
|
|
272
|
+
options.clickCount = 2;
|
|
273
|
+
line = `await context.web.click(elements["${elementIdentifier}"], _params, ${serializeOptions(options)}, this);`;
|
|
236
274
|
codeLines.push(line);
|
|
237
275
|
break;
|
|
238
276
|
default:
|
|
@@ -240,7 +278,7 @@ const _generateCodeFromCommand = (step, elements, userData) => {
|
|
|
240
278
|
comment = `// Click on ${element_name}`;
|
|
241
279
|
codeLines.push(escapeNonPrintables(comment));
|
|
242
280
|
}
|
|
243
|
-
line = `await context.web.click(elements["${elementIdentifier}"], _params,
|
|
281
|
+
line = `await context.web.click(elements["${elementIdentifier}"], _params, ${serializeOptions(options)}, this);`;
|
|
244
282
|
codeLines.push(line);
|
|
245
283
|
break;
|
|
246
284
|
}
|
|
@@ -251,17 +289,19 @@ const _generateCodeFromCommand = (step, elements, userData) => {
|
|
|
251
289
|
case 1:
|
|
252
290
|
comment = `// Parameterized click on ${step.value}`;
|
|
253
291
|
codeLines.push(escapeNonPrintables(comment));
|
|
254
|
-
line = `await context.web.click(elements["${elementIdentifier}"], _params,
|
|
292
|
+
line = `await context.web.click(elements["${elementIdentifier}"], _params, ${serializeOptions(options)}, this);`;
|
|
255
293
|
break;
|
|
256
294
|
case 2:
|
|
257
295
|
comment = `// Parameterized double click on ${step.value}`;
|
|
258
296
|
codeLines.push(escapeNonPrintables(comment));
|
|
259
|
-
|
|
297
|
+
options = options ?? {};
|
|
298
|
+
options.clickCount = 2;
|
|
299
|
+
line = `await context.web.click(elements["${elementIdentifier}"], _params, ${serializeOptions(options)}, this);`;
|
|
260
300
|
break;
|
|
261
301
|
default:
|
|
262
302
|
comment = `// Parameterized click on ${step.value}`;
|
|
263
303
|
codeLines.push(escapeNonPrintables(comment));
|
|
264
|
-
line = `await context.web.click(elements["${elementIdentifier}"], _params,
|
|
304
|
+
line = `await context.web.click(elements["${elementIdentifier}"], _params, ${serializeOptions(options)}, this);`;
|
|
265
305
|
}
|
|
266
306
|
codeLines.push(line);
|
|
267
307
|
break;
|
|
@@ -280,7 +320,7 @@ const _generateCodeFromCommand = (step, elements, userData) => {
|
|
|
280
320
|
} else {
|
|
281
321
|
enter = '"' + step.parameters[2] + '"';
|
|
282
322
|
}
|
|
283
|
-
line += `${input}, "${format}", ${enter}, _params,
|
|
323
|
+
line += `${input}, "${format}", ${enter}, _params, ${serializeOptions(options)}, this);`;
|
|
284
324
|
if (element_name) {
|
|
285
325
|
comment = `// Set date time ${element_name} to "${input}" with format "${format}"`;
|
|
286
326
|
codeLines.push(escapeNonPrintables(comment));
|
|
@@ -302,7 +342,7 @@ const _generateCodeFromCommand = (step, elements, userData) => {
|
|
|
302
342
|
} else {
|
|
303
343
|
enter = '"' + step.parameters[1] + '"';
|
|
304
344
|
}
|
|
305
|
-
line += `${input}, ${enter}, _params,
|
|
345
|
+
line += `${input}, ${enter}, _params, ${serializeOptions(options)}, this);`;
|
|
306
346
|
if (element_name) {
|
|
307
347
|
comment = `// Fill ${element_name} with "${input}"`;
|
|
308
348
|
codeLines.push(escapeNonPrintables(comment));
|
|
@@ -324,7 +364,7 @@ const _generateCodeFromCommand = (step, elements, userData) => {
|
|
|
324
364
|
} else {
|
|
325
365
|
enter = '"' + step.parameters[1] + '"';
|
|
326
366
|
}
|
|
327
|
-
line += `${input}, ${enter}, _params,
|
|
367
|
+
line += `${input}, ${enter}, _params, ${serializeOptions(options)}, this);`;
|
|
328
368
|
if (element_name) {
|
|
329
369
|
comment = `// Fill ${element_name} with "${input}"`;
|
|
330
370
|
codeLines.push(escapeNonPrintables(comment));
|
|
@@ -338,15 +378,25 @@ const _generateCodeFromCommand = (step, elements, userData) => {
|
|
|
338
378
|
if (step.dataSource === "userData" || step.dataSource === "parameters") {
|
|
339
379
|
input = "_" + step.dataKey;
|
|
340
380
|
}
|
|
341
|
-
let options = "null";
|
|
381
|
+
// let options = "null";
|
|
342
382
|
if (step.regex !== "") {
|
|
343
|
-
options =
|
|
383
|
+
options = options ?? {}
|
|
384
|
+
options = {
|
|
385
|
+
...options,
|
|
386
|
+
regex: step.regex,
|
|
387
|
+
trimSpaces: step.trimSpaces
|
|
388
|
+
} // `{regex: ${JSON.stringify(step.regex)},trimSpaces: ${step.trimSpaces}}`;
|
|
344
389
|
} else if (step.trimSpaces) {
|
|
345
|
-
options =
|
|
390
|
+
options = options ?? {}
|
|
391
|
+
options = {
|
|
392
|
+
...options,
|
|
393
|
+
trimSpaces: step.trimSpaces
|
|
394
|
+
}
|
|
395
|
+
// options = `{trimSpaces: ${step.trimSpaces}}`;
|
|
346
396
|
} else {
|
|
347
|
-
options = "null";
|
|
397
|
+
options = null//"null";
|
|
348
398
|
}
|
|
349
|
-
line = `await context.web.extractAttribute(elements["${elementIdentifier}"], "${attribute}", ${input}, _params
|
|
399
|
+
line = `await context.web.extractAttribute(elements["${elementIdentifier}"], "${attribute}", ${input}, _params, ${serializeOptions(options)}, this);`;
|
|
350
400
|
|
|
351
401
|
if (element_name) {
|
|
352
402
|
comment = `// Extract attribute ${attribute} from ${element_name} to ${variable}`;
|
|
@@ -362,15 +412,24 @@ const _generateCodeFromCommand = (step, elements, userData) => {
|
|
|
362
412
|
if (step.dataSource === "userData" || step.dataSource === "parameters") {
|
|
363
413
|
input = "_" + step.dataKey;
|
|
364
414
|
}
|
|
365
|
-
let options = "null";
|
|
366
415
|
if (step.regex !== "") {
|
|
367
|
-
options =
|
|
416
|
+
options = options ?? {}
|
|
417
|
+
options = {
|
|
418
|
+
...options,
|
|
419
|
+
regex: step.regex,
|
|
420
|
+
trimSpaces: step.trimSpaces
|
|
421
|
+
} // `{regex: ${JSON.stringify(step.regex)},trimSpaces: ${step.trimSpaces}}`;
|
|
368
422
|
} else if (step.trimSpaces) {
|
|
369
|
-
options =
|
|
423
|
+
options = options ?? {}
|
|
424
|
+
options = {
|
|
425
|
+
...options,
|
|
426
|
+
trimSpaces: step.trimSpaces
|
|
427
|
+
}
|
|
428
|
+
// options = `{trimSpaces: ${step.trimSpaces}}`;
|
|
370
429
|
} else {
|
|
371
|
-
options = "null";
|
|
430
|
+
options = null//"null";
|
|
372
431
|
}
|
|
373
|
-
line = `await context.web.extractProperty(elements["${elementIdentifier}"], "${property}", ${input}, _params
|
|
432
|
+
line = `await context.web.extractProperty(elements["${elementIdentifier}"], "${property}", ${input}, _params, ${serializeOptions(options)}, this);`;
|
|
374
433
|
|
|
375
434
|
if (element_name) {
|
|
376
435
|
comment = `// Extract property ${property} from ${element_name} to ${variable}`;
|
|
@@ -386,7 +445,7 @@ const _generateCodeFromCommand = (step, elements, userData) => {
|
|
|
386
445
|
codeLines.push(escapeNonPrintables(comment));
|
|
387
446
|
line = `const frameLocator = ${JSON.stringify(step.selectors ?? null)}`;
|
|
388
447
|
codeLines.push(line);
|
|
389
|
-
line = `await context.web.snapshotValidation(frameLocator,${step.valueInStepText ? "_param_0" : `"${step.parameters[0]}"`}, _params, ${
|
|
448
|
+
line = `await context.web.snapshotValidation(frameLocator,${step.valueInStepText ? "_param_0" : `"${step.parameters[0]}"`}, _params, ${serializeOptions(options)}, this);`;
|
|
390
449
|
codeLines.push(line);
|
|
391
450
|
|
|
392
451
|
const data = step.data;
|
|
@@ -412,7 +471,7 @@ const _generateCodeFromCommand = (step, elements, userData) => {
|
|
|
412
471
|
if (step.dataSource === "userData" || step.dataSource === "parameters") {
|
|
413
472
|
input = "_" + step.dataKey;
|
|
414
473
|
}
|
|
415
|
-
line += `${input},
|
|
474
|
+
line += `${input}, ${serializeOptions(options)}, this);`;
|
|
416
475
|
comment = `// Verify page contains text "${input}"`;
|
|
417
476
|
codeLines.push(escapeNonPrintables(comment));
|
|
418
477
|
codeLines.push(line);
|
|
@@ -426,7 +485,7 @@ const _generateCodeFromCommand = (step, elements, userData) => {
|
|
|
426
485
|
if (step.dataSource === "userData" || step.dataSource === "parameters") {
|
|
427
486
|
input = "_" + step.dataKey;
|
|
428
487
|
}
|
|
429
|
-
line += `${input}, ${step.parameters[1]} ,_params,
|
|
488
|
+
line += `${input}, ${step.parameters[1]} , _params, ${serializeOptions(options)}, this);`;
|
|
430
489
|
if (element_name) {
|
|
431
490
|
comment = `// Verify ${element_name} contains text "${input}"`;
|
|
432
491
|
codeLines.push(escapeNonPrintables(comment));
|
|
@@ -441,7 +500,7 @@ const _generateCodeFromCommand = (step, elements, userData) => {
|
|
|
441
500
|
}
|
|
442
501
|
line = `await context.web.analyzeTable(elements["${elementIdentifier}"], ${JSON.stringify(
|
|
443
502
|
step.parameters[0]
|
|
444
|
-
)}, "${step.parameters[1]}", ${input}, _params,
|
|
503
|
+
)}, "${step.parameters[1]}", ${input}, _params, ${serializeOptions(options)}, this);`;
|
|
445
504
|
if (element_name) {
|
|
446
505
|
comment = `// Analyze table ${element_name} query ${JSON.stringify(
|
|
447
506
|
step.parameters[0]
|
|
@@ -461,27 +520,27 @@ const _generateCodeFromCommand = (step, elements, userData) => {
|
|
|
461
520
|
} else if (step.dataSource === "environment") {
|
|
462
521
|
input = `context.environment["_${step.dataKey}"]`;
|
|
463
522
|
}
|
|
464
|
-
line += `${input}, _params,
|
|
523
|
+
line += `${input}, _params, ${serializeOptions(options)}, this);`;
|
|
465
524
|
if (element_name) {
|
|
466
525
|
comment = `// Select "${input}" from ${element_name}`;
|
|
467
526
|
codeLines.push(escapeNonPrintables(comment));
|
|
468
527
|
}
|
|
469
528
|
codeLines.push(line);
|
|
470
529
|
} else if (step.selectMode === "click_combo") {
|
|
471
|
-
line = `await context.web.click(elements["${elementIdentifier}"], _params,
|
|
530
|
+
line = `await context.web.click(elements["${elementIdentifier}"], _params, ${serializeOptions(options)}, this);`;
|
|
472
531
|
if (element_name) {
|
|
473
532
|
comment = `// Open combobox ${element_name}`;
|
|
474
533
|
codeLines.push(escapeNonPrintables(comment));
|
|
475
534
|
}
|
|
476
535
|
codeLines.push(line);
|
|
477
|
-
line = `await context.web.click(elements["${optionIdentifier}"], _params,
|
|
536
|
+
line = `await context.web.click(elements["${optionIdentifier}"], _params, ${serializeOptions(options)}, this);`;
|
|
478
537
|
if (element_name) {
|
|
479
538
|
comment = `// Select "${optionIdentifier}" from ${element_name}`;
|
|
480
539
|
codeLines.push(escapeNonPrintables(comment));
|
|
481
540
|
}
|
|
482
541
|
codeLines.push(line);
|
|
483
542
|
} else if (step.selectMode === "click") {
|
|
484
|
-
line = `await context.web.click(elements["${optionIdentifier}"], _params,
|
|
543
|
+
line = `await context.web.click(elements["${optionIdentifier}"], _params, ${serializeOptions(options)}, this);`;
|
|
485
544
|
if (element_name) {
|
|
486
545
|
comment = `// Select ${optionIdentifier} from ${element_name}`;
|
|
487
546
|
codeLines.push(escapeNonPrintables(comment));
|
|
@@ -494,13 +553,13 @@ const _generateCodeFromCommand = (step, elements, userData) => {
|
|
|
494
553
|
if (step.dataSource === "userData" || step.dataSource === "parameters") {
|
|
495
554
|
input = "_" + step.dataKey;
|
|
496
555
|
}
|
|
497
|
-
line += `${input}, false, _params,
|
|
556
|
+
line += `${input}, false, _params, ${serializeOptions(options)}, this);`;
|
|
498
557
|
if (element_name) {
|
|
499
558
|
comment = `// Fill ${element_name} with "${input}"`;
|
|
500
559
|
codeLines.push(escapeNonPrintables(comment));
|
|
501
560
|
}
|
|
502
561
|
codeLines.push(line);
|
|
503
|
-
line = `await context.web.click(elements["${optionIdentifier}"], _params,
|
|
562
|
+
line = `await context.web.click(elements["${optionIdentifier}"], _params, ${serializeOptions(options)}, this);`;
|
|
504
563
|
codeLines.push(line);
|
|
505
564
|
} else {
|
|
506
565
|
throw new Error(`Unknown select mode ${step.selectMode}`);
|
|
@@ -512,13 +571,13 @@ const _generateCodeFromCommand = (step, elements, userData) => {
|
|
|
512
571
|
case Types.RELOAD:
|
|
513
572
|
comment = `// Reload page`;
|
|
514
573
|
codeLines.push(escapeNonPrintables(comment));
|
|
515
|
-
line =
|
|
574
|
+
line = `await context.web.reloadPage(${serializeOptions(options)}, this);`;
|
|
516
575
|
codeLines.push(line);
|
|
517
576
|
break;
|
|
518
577
|
case Types.CLOSE_PAGE:
|
|
519
578
|
comment = `// Close page`;
|
|
520
579
|
codeLines.push(escapeNonPrintables(comment));
|
|
521
|
-
line =
|
|
580
|
+
line = `await context.web.closePage(${serializeOptions(options)}, this);`;
|
|
522
581
|
codeLines.push(line);
|
|
523
582
|
break;
|
|
524
583
|
case Types.NAVIGATE:
|
|
@@ -531,7 +590,7 @@ const _generateCodeFromCommand = (step, elements, userData) => {
|
|
|
531
590
|
} else if (step.dataSource === "environment") {
|
|
532
591
|
input = `context.environment["_${step.dataKey}"]`;
|
|
533
592
|
}
|
|
534
|
-
line = `await context.web.goto(${input}, this);`;
|
|
593
|
+
line = `await context.web.goto(${input}, this, ${serializeOptions(options)});`;
|
|
535
594
|
codeLines.push(line);
|
|
536
595
|
break;
|
|
537
596
|
case Types.VERIFY_PAGE_PATH:
|
|
@@ -540,7 +599,7 @@ const _generateCodeFromCommand = (step, elements, userData) => {
|
|
|
540
599
|
if (step.dataSource === "userData" || step.dataSource === "parameters") {
|
|
541
600
|
input = "_" + step.dataKey;
|
|
542
601
|
}
|
|
543
|
-
line += `${input},
|
|
602
|
+
line += `${input}, ${serializeOptions(options)}, this);`;
|
|
544
603
|
comment = `// Verify page path "${input}"`;
|
|
545
604
|
codeLines.push(escapeNonPrintables(comment));
|
|
546
605
|
codeLines.push(line);
|
|
@@ -551,7 +610,7 @@ const _generateCodeFromCommand = (step, elements, userData) => {
|
|
|
551
610
|
if (step.dataSource === "userData" || step.dataSource === "parameters") {
|
|
552
611
|
input = "_" + step.dataKey;
|
|
553
612
|
}
|
|
554
|
-
line += `${input},
|
|
613
|
+
line += `${input}, ${serializeOptions(options)}, this);`;
|
|
555
614
|
comment = `// Verify page title "${input}"`;
|
|
556
615
|
codeLines.push(escapeNonPrintables(comment));
|
|
557
616
|
codeLines.push(line);
|
|
@@ -561,13 +620,13 @@ const _generateCodeFromCommand = (step, elements, userData) => {
|
|
|
561
620
|
if (step.dataSource === "userData" || step.dataSource === "parameters") {
|
|
562
621
|
input = "_" + step.dataKey;
|
|
563
622
|
}
|
|
564
|
-
line = `await context.web.type(${input}, _params,
|
|
623
|
+
line = `await context.web.type(${input}, _params, ${serializeOptions(options)}, this);`;
|
|
565
624
|
comment = `// Type "${input}"`;
|
|
566
625
|
codeLines.push(escapeNonPrintables(comment));
|
|
567
626
|
codeLines.push(line);
|
|
568
627
|
break;
|
|
569
628
|
case Types.HOVER:
|
|
570
|
-
line = `await context.web.hover(elements["${elementIdentifier}"], _params,
|
|
629
|
+
line = `await context.web.hover(elements["${elementIdentifier}"], _params, ${serializeOptions(options)}, this);`;
|
|
571
630
|
if (element_name) {
|
|
572
631
|
comment = `// Hover ${element_name}`;
|
|
573
632
|
codeLines.push(escapeNonPrintables(comment));
|
|
@@ -608,13 +667,15 @@ const _generateCodeFromCommand = (step, elements, userData) => {
|
|
|
608
667
|
case Types.CHECK:
|
|
609
668
|
comment = `// Check ${element_name}`;
|
|
610
669
|
codeLines.push(escapeNonPrintables(comment));
|
|
611
|
-
line = `await context.web.setCheck(elements["${elementIdentifier}"], ${step.check}, _params,
|
|
670
|
+
line = `await context.web.setCheck(elements["${elementIdentifier}"], ${step.check}, _params, ${serializeOptions(options)}, this);`;
|
|
612
671
|
codeLines.push(line);
|
|
613
672
|
break;
|
|
614
673
|
case Types.PRESS:
|
|
615
674
|
comment = `// Press ${step.key}`;
|
|
616
675
|
codeLines.push(escapeNonPrintables(comment));
|
|
617
|
-
|
|
676
|
+
options = options ?? {};
|
|
677
|
+
options.press = true;
|
|
678
|
+
line = `await context.web.clickType( elements["${elementIdentifier}"] ,"${step.key}",null, _params, ${serializeOptions(options)}, this);`;
|
|
618
679
|
codeLines.push(line);
|
|
619
680
|
break;
|
|
620
681
|
case Types.CONTEXT_CLICK:
|
|
@@ -626,7 +687,9 @@ const _generateCodeFromCommand = (step, elements, userData) => {
|
|
|
626
687
|
if (step.dataSource === "userData" || step.dataSource === "parameters") {
|
|
627
688
|
input = "_" + step.dataKey;
|
|
628
689
|
}
|
|
629
|
-
|
|
690
|
+
// options = options ?? {};
|
|
691
|
+
// options.context = input;
|
|
692
|
+
line = `await context.web.click(elements["${elementIdentifier}"], _params, ${serializeOptions(options, input)}, this);`;
|
|
630
693
|
codeLines.push(line);
|
|
631
694
|
break;
|
|
632
695
|
case 2:
|
|
@@ -636,7 +699,10 @@ const _generateCodeFromCommand = (step, elements, userData) => {
|
|
|
636
699
|
if (step.dataSource === "userData" || step.dataSource === "parameters") {
|
|
637
700
|
input = "_" + step.dataKey;
|
|
638
701
|
}
|
|
639
|
-
|
|
702
|
+
options = options ?? {};
|
|
703
|
+
// options.context = input;
|
|
704
|
+
options.clickCount = 2;
|
|
705
|
+
line = `await context.web.click(elements["${elementIdentifier}"], _params, ${serializeOptions(options, input)}, this);`;
|
|
640
706
|
codeLines.push(line);
|
|
641
707
|
break;
|
|
642
708
|
default:
|
|
@@ -646,7 +712,9 @@ const _generateCodeFromCommand = (step, elements, userData) => {
|
|
|
646
712
|
if (step.dataSource === "userData" || step.dataSource === "parameters") {
|
|
647
713
|
input = "_" + step.dataKey;
|
|
648
714
|
}
|
|
649
|
-
|
|
715
|
+
// options = options ?? {};
|
|
716
|
+
// options.context = input;
|
|
717
|
+
line = `await context.web.click(elements["${elementIdentifier}"], _params, ${serializeOptions(options, input)}, this);`;
|
|
650
718
|
codeLines.push(line);
|
|
651
719
|
break;
|
|
652
720
|
}
|
|
@@ -671,7 +739,7 @@ const _generateCodeFromCommand = (step, elements, userData) => {
|
|
|
671
739
|
if (step.dataSource === "userData" || step.dataSource === "parameters") {
|
|
672
740
|
input = "_" + step.dataKey;
|
|
673
741
|
}
|
|
674
|
-
line += `"${step.parameters[0]}", ${input}, _params,
|
|
742
|
+
line += `"${step.parameters[0]}", ${input}, _params, ${serializeOptions(options)}, this);`;
|
|
675
743
|
codeLines.push(line);
|
|
676
744
|
break;
|
|
677
745
|
}
|
|
@@ -681,14 +749,14 @@ const _generateCodeFromCommand = (step, elements, userData) => {
|
|
|
681
749
|
if (step.dataSource === "userData" || step.dataSource === "parameters") {
|
|
682
750
|
input = "_" + step.dataKey;
|
|
683
751
|
}
|
|
684
|
-
line += `"${step.parameters[0]}", ${input}, _params,
|
|
752
|
+
line += `"${step.parameters[0]}", ${input}, _params, ${serializeOptions(options)}, this);`;
|
|
685
753
|
codeLines.push(line);
|
|
686
754
|
break;
|
|
687
755
|
}
|
|
688
756
|
case Types.CONDITIONAL_WAIT: {
|
|
689
757
|
line = `await context.web.conditionalWait(elements["${elementIdentifier}"], `;
|
|
690
758
|
input = step.valueInStepText ? "_param_0" : `"${escapeNonPrintables(step.parameters[1].replaceAll('"', '\\"'))}"`;
|
|
691
|
-
line += `"${step.parameters[1]}", ${input}, _params,
|
|
759
|
+
line += `"${step.parameters[1]}", ${input}, _params, ${serializeOptions(options)}, this);`;
|
|
692
760
|
codeLines.push(line);
|
|
693
761
|
break;
|
|
694
762
|
}
|
|
@@ -699,7 +767,7 @@ const _generateCodeFromCommand = (step, elements, userData) => {
|
|
|
699
767
|
if (step.dataSource === "userData" || step.dataSource === "parameters") {
|
|
700
768
|
input = "_" + step.dataKey;
|
|
701
769
|
}
|
|
702
|
-
line += `${input}, _params,
|
|
770
|
+
line += `${input}, _params, ${serializeOptions(options)}, this);`;
|
|
703
771
|
if (element_name) {
|
|
704
772
|
comment = `// Set ${element_name} to ${input}`;
|
|
705
773
|
codeLines.push(escapeNonPrintables(comment));
|
|
@@ -707,6 +775,8 @@ const _generateCodeFromCommand = (step, elements, userData) => {
|
|
|
707
775
|
codeLines.push(line);
|
|
708
776
|
break;
|
|
709
777
|
}
|
|
778
|
+
|
|
779
|
+
|
|
710
780
|
case Types.CLICK_SIMPLE:
|
|
711
781
|
case Types.FILL_SIMPLE:
|
|
712
782
|
// no code need to be added
|
|
@@ -276,8 +276,8 @@ export class BVTStepRunner {
|
|
|
276
276
|
|
|
277
277
|
for (const cmdId of cmdIDs) {
|
|
278
278
|
this.liveExecutionMap.set(cmdId, {
|
|
279
|
-
resolve: () => {},
|
|
280
|
-
reject: () => {},
|
|
279
|
+
resolve: () => { },
|
|
280
|
+
reject: () => { },
|
|
281
281
|
});
|
|
282
282
|
}
|
|
283
283
|
|
|
@@ -331,7 +331,7 @@ export class BVTStepRunner {
|
|
|
331
331
|
});
|
|
332
332
|
}
|
|
333
333
|
|
|
334
|
-
if (!step.isImplemented && step.commands.length > 0) {
|
|
334
|
+
if ((!(step.isImplemented && !step.shouldOverride) || step.shouldMakeStepTextUnique) && step.commands.length > 0) {
|
|
335
335
|
const pageName = generatePageName(step.startFrame?.url ?? "default");
|
|
336
336
|
const stepDefinitionFolderPath = path.join(tempFolderPath, "step_definitions");
|
|
337
337
|
if (!existsSync(stepDefinitionFolderPath)) {
|
|
@@ -373,6 +373,7 @@ export const toRecordingStep = (cmd, parametersMap, stepText) => {
|
|
|
373
373
|
const step = _toRecordingStep(cmd, stepText);
|
|
374
374
|
const cmdID = {
|
|
375
375
|
cmdId: cmd.id,
|
|
376
|
+
options: cmd.options ?? null,
|
|
376
377
|
};
|
|
377
378
|
Object.assign(step, cmdID);
|
|
378
379
|
|
|
@@ -484,7 +485,7 @@ function makeStepTextUnique(step, stepsDefinitions) {
|
|
|
484
485
|
// console.log("makeStepTextUnique", step.text);
|
|
485
486
|
let stepDef = stepsDefinitions.findMatchingStep(stepText);
|
|
486
487
|
// console.log({ stepDef });
|
|
487
|
-
if (stepDef && stepDef?.file.endsWith("utils.mjs")) {
|
|
488
|
+
if (stepDef && stepDef?.file.endsWith("utils.mjs") && !step.shouldMakeStepTextUnique) {
|
|
488
489
|
return true;
|
|
489
490
|
}
|
|
490
491
|
while (stepDef) {
|