artes 1.4.2 → 1.4.3
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/cucumber.config.js +14 -5
- package/package.json +1 -1
- package/src/helper/controller/elementController.js +4 -1
- package/src/helper/stepFunctions/assertions.js +160 -1
- package/src/helper/stepFunctions/elementInteractions.js +3 -1
- package/src/helper/stepFunctions/keyboardActions.js +6 -1
- package/src/helper/stepFunctions/mouseActions.js +6 -1
- package/src/helper/stepFunctions/pageActions.js +6 -2
- package/src/stepDefinitions/API.steps.js +11 -17
- package/src/stepDefinitions/assertions.steps.js +4 -1
- package/src/stepDefinitions/keyboardActions.steps.js +10 -1
- package/src/stepDefinitions/random.steps.js +11 -1
package/cucumber.config.js
CHANGED
|
@@ -51,6 +51,15 @@ function resolveEnv(artesConfig) {
|
|
|
51
51
|
}
|
|
52
52
|
const env = resolveEnv(artesConfig);
|
|
53
53
|
|
|
54
|
+
const resolveFeaturePaths = (basePath, value) => {
|
|
55
|
+
return value
|
|
56
|
+
.split(',')
|
|
57
|
+
.map(p => p.trim())
|
|
58
|
+
.filter(Boolean)
|
|
59
|
+
.map(p => path.join(basePath, p));
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
|
|
54
63
|
module.exports = {
|
|
55
64
|
default: {
|
|
56
65
|
// File paths and patterns
|
|
@@ -60,13 +69,13 @@ module.exports = {
|
|
|
60
69
|
timeout: process.env.TIMEOUT
|
|
61
70
|
? Number(process.env.TIMEOUT) * 1000
|
|
62
71
|
: artesConfig.timeout * 1000 || 30 * 1000, // Default timeout in seconds
|
|
63
|
-
|
|
64
|
-
? [
|
|
72
|
+
paths: process.env.RERUN
|
|
73
|
+
? [path.join("../../", process.env.RERUN)]
|
|
65
74
|
: process.env.FEATURES
|
|
66
|
-
?
|
|
75
|
+
? resolveFeaturePaths(moduleConfig.projectPath, process.env.FEATURES)
|
|
67
76
|
: artesConfig.features
|
|
68
|
-
?
|
|
69
|
-
: [moduleConfig.featuresPath], // Paths to feature files
|
|
77
|
+
? resolveFeaturePaths(moduleConfig.projectPath, artesConfig.features)
|
|
78
|
+
: [moduleConfig.featuresPath], // Paths to feature files
|
|
70
79
|
require: [
|
|
71
80
|
process.env.STEP_DEFINITIONS
|
|
72
81
|
? [path.join(moduleConfig.projectPath, process.env.STEP_DEFINITIONS)]
|
package/package.json
CHANGED
|
@@ -38,7 +38,10 @@ function selectorSeparator(element) {
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
function getSelector(element) {
|
|
41
|
+
function getSelector(element) {
|
|
42
|
+
|
|
43
|
+
element = resolveVariable(element)
|
|
44
|
+
|
|
42
45
|
const selector =
|
|
43
46
|
elements?.[element]?.selector || elements?.[element] || element;
|
|
44
47
|
return resolveVariable(selectorSeparator(selector));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const { expect, element, context } = require("../imports/commons");
|
|
1
|
+
const { expect, element, context, resolveVariable } = require("../imports/commons");
|
|
2
2
|
const { elementInteractions } = require("./elementInteractions");
|
|
3
3
|
const { frame } = require("../stepFunctions/frameActions");
|
|
4
4
|
|
|
@@ -77,6 +77,8 @@ const assert = {
|
|
|
77
77
|
shouldContainText: async (selector, text, options) => {
|
|
78
78
|
options = options ?? {};
|
|
79
79
|
|
|
80
|
+
text = await resolveVariable(text)
|
|
81
|
+
|
|
80
82
|
await expect(
|
|
81
83
|
typeof selector === "string" ? element(selector) : await selector,
|
|
82
84
|
).toContainText(text, options);
|
|
@@ -88,6 +90,8 @@ const assert = {
|
|
|
88
90
|
) => {
|
|
89
91
|
options = options ?? {};
|
|
90
92
|
|
|
93
|
+
expectedText = await resolveVariable(expectedText)
|
|
94
|
+
|
|
91
95
|
const count = await frame.count(elements);
|
|
92
96
|
|
|
93
97
|
for (let i = 0; i < count; i++) {
|
|
@@ -101,6 +105,8 @@ const assert = {
|
|
|
101
105
|
shouldHaveAccessibleDescription: async (selector, description, options) => {
|
|
102
106
|
options = options ?? {};
|
|
103
107
|
|
|
108
|
+
description = await resolveVariable(description)
|
|
109
|
+
|
|
104
110
|
await expect(
|
|
105
111
|
typeof selector === "string" ? element(selector) : await selector,
|
|
106
112
|
).toHaveAccessibleDescription(description, options);
|
|
@@ -108,6 +114,8 @@ const assert = {
|
|
|
108
114
|
shouldHaveAccessibleName: async (selector, name, options) => {
|
|
109
115
|
options = options ?? {};
|
|
110
116
|
|
|
117
|
+
name = await resolveVariable(name)
|
|
118
|
+
|
|
111
119
|
await expect(
|
|
112
120
|
typeof selector === "string" ? element(selector) : await selector,
|
|
113
121
|
).toHaveAccessibleName(name, options);
|
|
@@ -115,6 +123,9 @@ const assert = {
|
|
|
115
123
|
shouldHaveAttribute: async (selector, attribute, value, options) => {
|
|
116
124
|
options = options ?? {};
|
|
117
125
|
|
|
126
|
+
attribute = await resolveVariable(attribute)
|
|
127
|
+
value = await resolveVariable(value)
|
|
128
|
+
|
|
118
129
|
await expect(
|
|
119
130
|
typeof selector === "string" ? element(selector) : await selector,
|
|
120
131
|
).toHaveAttribute(attribute, value, options);
|
|
@@ -122,6 +133,8 @@ const assert = {
|
|
|
122
133
|
shouldHaveClass: async (selector, className, options) => {
|
|
123
134
|
options = options ?? {};
|
|
124
135
|
|
|
136
|
+
className = await resolveVariable(className)
|
|
137
|
+
|
|
125
138
|
await expect(
|
|
126
139
|
typeof selector === "string" ? element(selector) : await selector,
|
|
127
140
|
).toHaveClass(className, options);
|
|
@@ -129,6 +142,8 @@ const assert = {
|
|
|
129
142
|
shouldHaveCount: async (selector, count, options) => {
|
|
130
143
|
options = options ?? {};
|
|
131
144
|
|
|
145
|
+
count = await resolveVariable(count)
|
|
146
|
+
|
|
132
147
|
await expect(
|
|
133
148
|
typeof selector === "string" ? element(selector) : await selector,
|
|
134
149
|
).toHaveCount(count, options);
|
|
@@ -136,6 +151,9 @@ const assert = {
|
|
|
136
151
|
shouldHaveCSS: async (selector, property, value, options) => {
|
|
137
152
|
options = options ?? {};
|
|
138
153
|
|
|
154
|
+
property = await resolveVariable(property)
|
|
155
|
+
value = await resolveVariable(value)
|
|
156
|
+
|
|
139
157
|
await expect(
|
|
140
158
|
typeof selector === "string" ? element(selector) : await selector,
|
|
141
159
|
).toHaveCSS(property, value, options);
|
|
@@ -143,6 +161,8 @@ const assert = {
|
|
|
143
161
|
shouldHaveId: async (selector, id, options) => {
|
|
144
162
|
options = options ?? {};
|
|
145
163
|
|
|
164
|
+
id = await resolveVariable(id)
|
|
165
|
+
|
|
146
166
|
await expect(
|
|
147
167
|
typeof selector === "string" ? element(selector) : await selector,
|
|
148
168
|
).toHaveId(id, options);
|
|
@@ -150,6 +170,9 @@ const assert = {
|
|
|
150
170
|
shouldHaveJSProperty: async (selector, property, value, options) => {
|
|
151
171
|
options = options ?? {};
|
|
152
172
|
|
|
173
|
+
property = await resolveVariable(property)
|
|
174
|
+
value = await resolveVariable(value)
|
|
175
|
+
|
|
153
176
|
await expect(
|
|
154
177
|
typeof selector === "string" ? element(selector) : await selector,
|
|
155
178
|
).toHaveJSProperty(property, value, options);
|
|
@@ -157,6 +180,8 @@ const assert = {
|
|
|
157
180
|
shouldHaveRole: async (selector, role, options) => {
|
|
158
181
|
options = options ?? {};
|
|
159
182
|
|
|
183
|
+
role = await resolveVariable(role)
|
|
184
|
+
|
|
160
185
|
await expect(
|
|
161
186
|
typeof selector === "string" ? element(selector) : await selector,
|
|
162
187
|
).toHaveRole(role, options);
|
|
@@ -171,6 +196,8 @@ const assert = {
|
|
|
171
196
|
shouldHaveText: async (selector, text, options) => {
|
|
172
197
|
options = options ?? {};
|
|
173
198
|
|
|
199
|
+
text = await resolveVariable(text)
|
|
200
|
+
|
|
174
201
|
await expect(
|
|
175
202
|
typeof selector === "string" ? element(selector) : await selector,
|
|
176
203
|
).toHaveText(text, options);
|
|
@@ -178,6 +205,8 @@ const assert = {
|
|
|
178
205
|
shouldHaveValue: async (selector, value, options) => {
|
|
179
206
|
options = options ?? {};
|
|
180
207
|
|
|
208
|
+
value = await resolveVariable(value)
|
|
209
|
+
|
|
181
210
|
await expect(
|
|
182
211
|
typeof selector === "string" ? element(selector) : await selector,
|
|
183
212
|
).toHaveValue(value, options);
|
|
@@ -185,6 +214,8 @@ const assert = {
|
|
|
185
214
|
shouldHaveValues: async (selector, values, options) => {
|
|
186
215
|
options = options ?? {};
|
|
187
216
|
|
|
217
|
+
values = values.map(value => resolveVariable(value))
|
|
218
|
+
|
|
188
219
|
await expect(
|
|
189
220
|
typeof selector === "string" ? element(selector) : await selector,
|
|
190
221
|
).toHaveValues(values, options);
|
|
@@ -197,11 +228,15 @@ const assert = {
|
|
|
197
228
|
shouldPageHaveTitle: async (title, options) => {
|
|
198
229
|
options = options ?? {};
|
|
199
230
|
|
|
231
|
+
title = await resolveVariable(title)
|
|
232
|
+
|
|
200
233
|
await expect(context.page).toHaveTitle(title, options);
|
|
201
234
|
},
|
|
202
235
|
shouldPageHaveURL: async (url, options) => {
|
|
203
236
|
options = options ?? {};
|
|
204
237
|
|
|
238
|
+
url = await resolveVariable(url)
|
|
239
|
+
|
|
205
240
|
await expect(context.page).toHaveURL(url, options);
|
|
206
241
|
},
|
|
207
242
|
shouldResponseBeOK: async (response, options) => {
|
|
@@ -284,6 +319,8 @@ const assert = {
|
|
|
284
319
|
shouldNotContainText: async (selector, text, options) => {
|
|
285
320
|
options = options ?? {};
|
|
286
321
|
|
|
322
|
+
text = await resolveVariable(text)
|
|
323
|
+
|
|
287
324
|
await expect(
|
|
288
325
|
typeof selector === "string" ? element(selector) : await selector,
|
|
289
326
|
).not.toContainText(text, options);
|
|
@@ -295,6 +332,8 @@ const assert = {
|
|
|
295
332
|
) => {
|
|
296
333
|
options = options ?? {};
|
|
297
334
|
|
|
335
|
+
description = await resolveVariable(description)
|
|
336
|
+
|
|
298
337
|
await expect(
|
|
299
338
|
typeof selector === "string" ? element(selector) : await selector,
|
|
300
339
|
).not.toHaveAccessibleDescription(description, options);
|
|
@@ -302,6 +341,8 @@ const assert = {
|
|
|
302
341
|
shouldNotHaveAccessibleName: async (selector, name, options) => {
|
|
303
342
|
options = options ?? {};
|
|
304
343
|
|
|
344
|
+
name = await resolveVariable(name)
|
|
345
|
+
|
|
305
346
|
await expect(
|
|
306
347
|
typeof selector === "string" ? element(selector) : await selector,
|
|
307
348
|
).not.toHaveAccessibleName(name, options);
|
|
@@ -309,6 +350,9 @@ const assert = {
|
|
|
309
350
|
shouldNotHaveAttribute: async (selector, attribute, value, options) => {
|
|
310
351
|
options = options ?? {};
|
|
311
352
|
|
|
353
|
+
attribute = await resolveVariable(attribute)
|
|
354
|
+
value = await resolveVariable(value)
|
|
355
|
+
|
|
312
356
|
await expect(
|
|
313
357
|
typeof selector === "string" ? element(selector) : await selector,
|
|
314
358
|
).not.toHaveAttribute(attribute, value, options);
|
|
@@ -316,12 +360,16 @@ const assert = {
|
|
|
316
360
|
shouldNotHaveClass: async (selector, className, options) => {
|
|
317
361
|
options = options ?? {};
|
|
318
362
|
|
|
363
|
+
className = await resolveVariable(className)
|
|
364
|
+
|
|
319
365
|
await expect(
|
|
320
366
|
typeof selector === "string" ? element(selector) : await selector,
|
|
321
367
|
).not.toHaveClass(className, options);
|
|
322
368
|
},
|
|
323
369
|
shouldNotHaveCount: async (selector, count, options) => {
|
|
324
370
|
options = options ?? {};
|
|
371
|
+
|
|
372
|
+
count = await resolveVariable(count)
|
|
325
373
|
|
|
326
374
|
await expect(
|
|
327
375
|
typeof selector === "string" ? element(selector) : await selector,
|
|
@@ -330,6 +378,9 @@ const assert = {
|
|
|
330
378
|
shouldNotHaveCSS: async (selector, property, value, options) => {
|
|
331
379
|
options = options ?? {};
|
|
332
380
|
|
|
381
|
+
property = await resolveVariable(property)
|
|
382
|
+
value = await resolveVariable(value)
|
|
383
|
+
|
|
333
384
|
await expect(
|
|
334
385
|
typeof selector === "string" ? element(selector) : await selector,
|
|
335
386
|
).not.toHaveCSS(property, value, options);
|
|
@@ -337,6 +388,8 @@ const assert = {
|
|
|
337
388
|
shouldNotHaveId: async (selector, id, options) => {
|
|
338
389
|
options = options ?? {};
|
|
339
390
|
|
|
391
|
+
id = await resolveVariable(id)
|
|
392
|
+
|
|
340
393
|
await expect(
|
|
341
394
|
typeof selector === "string" ? element(selector) : await selector,
|
|
342
395
|
).not.toHaveId(id, options);
|
|
@@ -344,6 +397,9 @@ const assert = {
|
|
|
344
397
|
shouldNotHaveJSProperty: async (selector, property, value, options) => {
|
|
345
398
|
options = options ?? {};
|
|
346
399
|
|
|
400
|
+
property = await resolveVariable(property)
|
|
401
|
+
value = await resolveVariable(value)
|
|
402
|
+
|
|
347
403
|
await expect(
|
|
348
404
|
typeof selector === "string" ? element(selector) : await selector,
|
|
349
405
|
).not.toHaveJSProperty(property, value, options);
|
|
@@ -351,6 +407,8 @@ const assert = {
|
|
|
351
407
|
shouldNotHaveRole: async (selector, role, options) => {
|
|
352
408
|
options = options ?? {};
|
|
353
409
|
|
|
410
|
+
role = await resolveVariable(role)
|
|
411
|
+
|
|
354
412
|
await expect(
|
|
355
413
|
typeof selector === "string" ? element(selector) : await selector,
|
|
356
414
|
).not.toHaveRole(role, options);
|
|
@@ -365,6 +423,8 @@ const assert = {
|
|
|
365
423
|
shouldNotHaveText: async (selector, text, options) => {
|
|
366
424
|
options = options ?? {};
|
|
367
425
|
|
|
426
|
+
text = await resolveVariable(text)
|
|
427
|
+
|
|
368
428
|
await expect(
|
|
369
429
|
typeof selector === "string" ? element(selector) : await selector,
|
|
370
430
|
).not.toHaveText(text, options);
|
|
@@ -372,6 +432,8 @@ const assert = {
|
|
|
372
432
|
shouldNotHaveValue: async (selector, value, options) => {
|
|
373
433
|
options = options ?? {};
|
|
374
434
|
|
|
435
|
+
value = await resolveVariable(value)
|
|
436
|
+
|
|
375
437
|
await expect(
|
|
376
438
|
typeof selector === "string" ? element(selector) : await selector,
|
|
377
439
|
).not.toHaveValue(value, options);
|
|
@@ -379,6 +441,8 @@ const assert = {
|
|
|
379
441
|
shouldNotHaveValues: async (selector, values, options) => {
|
|
380
442
|
options = options ?? {};
|
|
381
443
|
|
|
444
|
+
values = values.map(value => resolveVariable(value))
|
|
445
|
+
|
|
382
446
|
await expect(
|
|
383
447
|
typeof selector === "string" ? element(selector) : await selector,
|
|
384
448
|
).not.toHaveValues(values, options);
|
|
@@ -391,11 +455,15 @@ const assert = {
|
|
|
391
455
|
shouldNotPageHaveTitle: async (title, options) => {
|
|
392
456
|
options = options ?? {};
|
|
393
457
|
|
|
458
|
+
title = await resolveVariable(title)
|
|
459
|
+
|
|
394
460
|
await expect(context.page).not.toHaveTitle(title, options);
|
|
395
461
|
},
|
|
396
462
|
shouldNotPageHaveURL: async (url, options) => {
|
|
397
463
|
options = options ?? {};
|
|
398
464
|
|
|
465
|
+
url = await resolveVariable(url)
|
|
466
|
+
|
|
399
467
|
await expect(context.page).not.toHaveURL(url, options);
|
|
400
468
|
},
|
|
401
469
|
shouldNotResponseBeOK: async (response, options) => {
|
|
@@ -408,6 +476,8 @@ const assert = {
|
|
|
408
476
|
shouldBe: async (selector, expected, options) => {
|
|
409
477
|
options = options ?? {};
|
|
410
478
|
|
|
479
|
+
expected = await resolveVariable(expected)
|
|
480
|
+
|
|
411
481
|
await expect(await elementInteractions.textContent(selector)).toBe(
|
|
412
482
|
expected,
|
|
413
483
|
options,
|
|
@@ -416,6 +486,10 @@ const assert = {
|
|
|
416
486
|
shouldBeCloseTo: async (selector, expected, precision, options) => {
|
|
417
487
|
options = options ?? {};
|
|
418
488
|
|
|
489
|
+
expected = await resolveVariable(expected)
|
|
490
|
+
precision = await resolveVariable(precision)
|
|
491
|
+
|
|
492
|
+
|
|
419
493
|
await expect(
|
|
420
494
|
Number(await elementInteractions.textContent(selector)),
|
|
421
495
|
).toBeCloseTo(expected, precision, options);
|
|
@@ -437,6 +511,8 @@ const assert = {
|
|
|
437
511
|
shouldBeGreaterThan: async (selector, expected, options) => {
|
|
438
512
|
options = options ?? {};
|
|
439
513
|
|
|
514
|
+
expected = await resolveVariable(expected)
|
|
515
|
+
|
|
440
516
|
await expect(
|
|
441
517
|
Number(await elementInteractions.textContent(selector)),
|
|
442
518
|
).toBeGreaterThan(expected, options);
|
|
@@ -444,6 +520,8 @@ const assert = {
|
|
|
444
520
|
shouldBeGreaterThanOrEqual: async (selector, expected, options) => {
|
|
445
521
|
options = options ?? {};
|
|
446
522
|
|
|
523
|
+
expected = await resolveVariable(expected)
|
|
524
|
+
|
|
447
525
|
await expect(
|
|
448
526
|
Number(await elementInteractions.textContent(selector)),
|
|
449
527
|
).toBeGreaterThanOrEqual(expected, options);
|
|
@@ -451,6 +529,8 @@ const assert = {
|
|
|
451
529
|
shouldBeInstanceOf: async (selector, constructor, options) => {
|
|
452
530
|
options = options ?? {};
|
|
453
531
|
|
|
532
|
+
constructor = await resolveVariable(constructor)
|
|
533
|
+
|
|
454
534
|
await expect(
|
|
455
535
|
await elementInteractions.textContent(selector),
|
|
456
536
|
).toBeInstanceOf(constructor, options);
|
|
@@ -458,6 +538,8 @@ const assert = {
|
|
|
458
538
|
shouldBeLessThan: async (selector, expected, options) => {
|
|
459
539
|
options = options ?? {};
|
|
460
540
|
|
|
541
|
+
expected = await resolveVariable(expected)
|
|
542
|
+
|
|
461
543
|
await expect(
|
|
462
544
|
Number(await elementInteractions.textContent(selector)),
|
|
463
545
|
).toBeLessThan(expected, options);
|
|
@@ -465,6 +547,8 @@ const assert = {
|
|
|
465
547
|
shouldBeLessThanOrEqual: async (selector, expected, options) => {
|
|
466
548
|
options = options ?? {};
|
|
467
549
|
|
|
550
|
+
expected = await resolveVariable(expected)
|
|
551
|
+
|
|
468
552
|
await expect(
|
|
469
553
|
Number(await elementInteractions.textContent(selector)),
|
|
470
554
|
).toBeLessThanOrEqual(expected, options);
|
|
@@ -508,6 +592,8 @@ const assert = {
|
|
|
508
592
|
shouldContainEqual: async (selector, expected, options) => {
|
|
509
593
|
options = options ?? {};
|
|
510
594
|
|
|
595
|
+
expected = await resolveVariable(expected)
|
|
596
|
+
|
|
511
597
|
await expect(
|
|
512
598
|
await elementInteractions.textContent(selector),
|
|
513
599
|
).toContainEqual(expected, options);
|
|
@@ -515,6 +601,8 @@ const assert = {
|
|
|
515
601
|
shouldEqual: async (selector, expected, options) => {
|
|
516
602
|
options = options ?? {};
|
|
517
603
|
|
|
604
|
+
expected = await resolveVariable(expected)
|
|
605
|
+
|
|
518
606
|
await expect(
|
|
519
607
|
Number(await elementInteractions.textContent(selector)),
|
|
520
608
|
).toEqual(expected, options);
|
|
@@ -522,6 +610,8 @@ const assert = {
|
|
|
522
610
|
shouldHaveLength: async (selector, length, options) => {
|
|
523
611
|
options = options ?? {};
|
|
524
612
|
|
|
613
|
+
length = await resolveVariable(length)
|
|
614
|
+
|
|
525
615
|
await expect(await elementInteractions.textContent(selector)).toHaveLength(
|
|
526
616
|
length,
|
|
527
617
|
options,
|
|
@@ -530,6 +620,8 @@ const assert = {
|
|
|
530
620
|
shouldHaveProperty: async (selector, property, options) => {
|
|
531
621
|
options = options ?? {};
|
|
532
622
|
|
|
623
|
+
property = await resolveVariable(property)
|
|
624
|
+
|
|
533
625
|
await expect(
|
|
534
626
|
await elementInteractions.textContent(selector),
|
|
535
627
|
).toHaveProperty(property, options);
|
|
@@ -537,6 +629,8 @@ const assert = {
|
|
|
537
629
|
shouldMatch: async (selector, regex, options) => {
|
|
538
630
|
options = options ?? {};
|
|
539
631
|
|
|
632
|
+
regex = await resolveVariable(regex)
|
|
633
|
+
|
|
540
634
|
await expect(await elementInteractions.textContent(selector)).toMatch(
|
|
541
635
|
regex,
|
|
542
636
|
options,
|
|
@@ -545,6 +639,8 @@ const assert = {
|
|
|
545
639
|
shouldMatchObject: async (selector, object, options) => {
|
|
546
640
|
options = options ?? {};
|
|
547
641
|
|
|
642
|
+
object = await resolveVariable(object)
|
|
643
|
+
|
|
548
644
|
await expect(await elementInteractions.textContent(selector)).toMatchObject(
|
|
549
645
|
object,
|
|
550
646
|
options,
|
|
@@ -553,6 +649,8 @@ const assert = {
|
|
|
553
649
|
shouldStrictEqual: async (selector, expected, options) => {
|
|
554
650
|
options = options ?? {};
|
|
555
651
|
|
|
652
|
+
expected = await resolveVariable(expected)
|
|
653
|
+
|
|
556
654
|
await expect(
|
|
557
655
|
Number(await elementInteractions.textContent(selector)),
|
|
558
656
|
).toStrictEqual(expected, options);
|
|
@@ -560,11 +658,15 @@ const assert = {
|
|
|
560
658
|
shouldThrow: async (fn, options) => {
|
|
561
659
|
options = options ?? {};
|
|
562
660
|
|
|
661
|
+
fn = await resolveVariable(fn)
|
|
662
|
+
|
|
563
663
|
await expect(fn).toThrow(options);
|
|
564
664
|
},
|
|
565
665
|
shouldAny: async (selector, constructor, options) => {
|
|
566
666
|
options = options ?? {};
|
|
567
667
|
|
|
668
|
+
constructor = await resolveVariable(constructor)
|
|
669
|
+
|
|
568
670
|
await expect(
|
|
569
671
|
await elementInteractions.textContent(selector),
|
|
570
672
|
).any.toBeInstanceOf(constructor, options);
|
|
@@ -579,6 +681,8 @@ const assert = {
|
|
|
579
681
|
shouldArrayContaining: async (selector, elements, options) => {
|
|
580
682
|
options = options ?? {};
|
|
581
683
|
|
|
684
|
+
elements = elements.map(element => resolveVariable(element))
|
|
685
|
+
|
|
582
686
|
await expect(await elementInteractions.textContent(selector)).toEqual(
|
|
583
687
|
expect.arrayContaining(elements),
|
|
584
688
|
options,
|
|
@@ -587,6 +691,9 @@ const assert = {
|
|
|
587
691
|
shouldCloseTo: async (selector, expected, precision, options) => {
|
|
588
692
|
options = options ?? {};
|
|
589
693
|
|
|
694
|
+
expected = await resolveVariable(expected)
|
|
695
|
+
precision = await resolveVariable(precision)
|
|
696
|
+
|
|
590
697
|
await expect(
|
|
591
698
|
Number(await elementInteractions.textContent(selector)),
|
|
592
699
|
).toBeCloseTo(expected, precision, options);
|
|
@@ -594,6 +701,8 @@ const assert = {
|
|
|
594
701
|
shouldObjectContaining: async (selector, properties, options) => {
|
|
595
702
|
options = options ?? {};
|
|
596
703
|
|
|
704
|
+
properties = await resolveVariable(properties)
|
|
705
|
+
|
|
597
706
|
await expect(await elementInteractions.textContent(selector)).toEqual(
|
|
598
707
|
expect.objectContaining(properties),
|
|
599
708
|
options,
|
|
@@ -602,6 +711,8 @@ const assert = {
|
|
|
602
711
|
shouldStringContaining: async (selector, substring, options) => {
|
|
603
712
|
options = options ?? {};
|
|
604
713
|
|
|
714
|
+
substring = await resolveVariable(substring)
|
|
715
|
+
|
|
605
716
|
await expect(await elementInteractions.textContent(selector)).toEqual(
|
|
606
717
|
expect.stringContaining(substring),
|
|
607
718
|
options,
|
|
@@ -610,6 +721,8 @@ const assert = {
|
|
|
610
721
|
shouldStringMatching: async (selector, regex, options) => {
|
|
611
722
|
options = options ?? {};
|
|
612
723
|
|
|
724
|
+
regex = await resolveVariable(regex)
|
|
725
|
+
|
|
613
726
|
await expect(await elementInteractions.textContent(selector)).toEqual(
|
|
614
727
|
expect.stringMatching(regex),
|
|
615
728
|
options,
|
|
@@ -620,6 +733,8 @@ const assert = {
|
|
|
620
733
|
shouldNotBe: async (selector, expected, options) => {
|
|
621
734
|
options = options ?? {};
|
|
622
735
|
|
|
736
|
+
expected = await resolveVariable(expected)
|
|
737
|
+
|
|
623
738
|
await expect(await elementInteractions.textContent(selector)).not.toBe(
|
|
624
739
|
expected,
|
|
625
740
|
options,
|
|
@@ -628,6 +743,9 @@ const assert = {
|
|
|
628
743
|
shouldNotBeCloseTo: async (selector, expected, precision, options) => {
|
|
629
744
|
options = options ?? {};
|
|
630
745
|
|
|
746
|
+
expected = await resolveVariable(expected)
|
|
747
|
+
precision = await resolveVariable(precision)
|
|
748
|
+
|
|
631
749
|
await expect(
|
|
632
750
|
Number(await elementInteractions.textContent(selector)),
|
|
633
751
|
).not.toBeCloseTo(expected, precision, options);
|
|
@@ -649,6 +767,8 @@ const assert = {
|
|
|
649
767
|
shouldNotBeGreaterThan: async (selector, expected, options) => {
|
|
650
768
|
options = options ?? {};
|
|
651
769
|
|
|
770
|
+
expected = await resolveVariable(expected)
|
|
771
|
+
|
|
652
772
|
await expect(
|
|
653
773
|
await elementInteractions.textContent(selector),
|
|
654
774
|
).not.toBeGreaterThan(expected, options);
|
|
@@ -656,6 +776,8 @@ const assert = {
|
|
|
656
776
|
shouldNotBeGreaterThanOrEqual: async (selector, expected, options) => {
|
|
657
777
|
options = options ?? {};
|
|
658
778
|
|
|
779
|
+
expected = await resolveVariable(expected)
|
|
780
|
+
|
|
659
781
|
await expect(
|
|
660
782
|
Number(await elementInteractions.textContent(selector)),
|
|
661
783
|
).not.toBeGreaterThanOrEqual(expected, options);
|
|
@@ -663,6 +785,8 @@ const assert = {
|
|
|
663
785
|
shouldNotBeInstanceOf: async (selector, constructor, options) => {
|
|
664
786
|
options = options ?? {};
|
|
665
787
|
|
|
788
|
+
constructor = await resolveVariable(constructor)
|
|
789
|
+
|
|
666
790
|
await expect(
|
|
667
791
|
await elementInteractions.textContent(selector),
|
|
668
792
|
).not.toBeInstanceOf(constructor, options);
|
|
@@ -670,6 +794,8 @@ const assert = {
|
|
|
670
794
|
shouldNotBeLessThan: async (selector, expected, options) => {
|
|
671
795
|
options = options ?? {};
|
|
672
796
|
|
|
797
|
+
expected = await resolveVariable(expected)
|
|
798
|
+
|
|
673
799
|
await expect(
|
|
674
800
|
Number(await elementInteractions.textContent(selector)),
|
|
675
801
|
).not.toBeLessThan(expected, options);
|
|
@@ -677,6 +803,8 @@ const assert = {
|
|
|
677
803
|
shouldNotBeLessThanOrEqual: async (selector, expected, options) => {
|
|
678
804
|
options = options ?? {};
|
|
679
805
|
|
|
806
|
+
expected = await resolveVariable(expected)
|
|
807
|
+
|
|
680
808
|
await expect(
|
|
681
809
|
Number(await elementInteractions.textContent(selector)),
|
|
682
810
|
).not.toBeLessThanOrEqual(expected, options);
|
|
@@ -712,6 +840,8 @@ const assert = {
|
|
|
712
840
|
shouldNotContain: async (selector, substring, options) => {
|
|
713
841
|
options = options ?? {};
|
|
714
842
|
|
|
843
|
+
substring = await resolveVariable(substring)
|
|
844
|
+
|
|
715
845
|
await expect(await elementInteractions.textContent(selector)).not.toContain(
|
|
716
846
|
substring,
|
|
717
847
|
options,
|
|
@@ -720,6 +850,8 @@ const assert = {
|
|
|
720
850
|
shouldNotContainEqual: async (selector, expected, options) => {
|
|
721
851
|
options = options ?? {};
|
|
722
852
|
|
|
853
|
+
expected = await resolveVariable(expected)
|
|
854
|
+
|
|
723
855
|
await expect(
|
|
724
856
|
Number(await elementInteractions.textContent(selector)),
|
|
725
857
|
).not.toContainEqual(expected, options);
|
|
@@ -727,6 +859,8 @@ const assert = {
|
|
|
727
859
|
shouldNotEqual: async (selector, expected, options) => {
|
|
728
860
|
options = options ?? {};
|
|
729
861
|
|
|
862
|
+
expected = await resolveVariable(expected)
|
|
863
|
+
|
|
730
864
|
await expect(
|
|
731
865
|
Number(await elementInteractions.textContent(selector)),
|
|
732
866
|
).not.toEqual(expected, options);
|
|
@@ -734,6 +868,8 @@ const assert = {
|
|
|
734
868
|
shouldNotHaveLength: async (selector, length, options) => {
|
|
735
869
|
options = options ?? {};
|
|
736
870
|
|
|
871
|
+
length = await resolveVariable(length)
|
|
872
|
+
|
|
737
873
|
await expect(
|
|
738
874
|
await elementInteractions.textContent(selector),
|
|
739
875
|
).not.toHaveLength(length, options);
|
|
@@ -741,6 +877,8 @@ const assert = {
|
|
|
741
877
|
shouldNotHaveProperty: async (selector, property, options) => {
|
|
742
878
|
options = options ?? {};
|
|
743
879
|
|
|
880
|
+
property = await resolveVariable(property)
|
|
881
|
+
|
|
744
882
|
await expect(
|
|
745
883
|
await elementInteractions.textContent(selector),
|
|
746
884
|
).not.toHaveProperty(property, options);
|
|
@@ -748,6 +886,8 @@ const assert = {
|
|
|
748
886
|
shouldNotMatch: async (selector, regex, options) => {
|
|
749
887
|
options = options ?? {};
|
|
750
888
|
|
|
889
|
+
regex = await resolveVariable(regex)
|
|
890
|
+
|
|
751
891
|
await expect(await elementInteractions.textContent(selector)).not.toMatch(
|
|
752
892
|
regex,
|
|
753
893
|
options,
|
|
@@ -756,6 +896,8 @@ const assert = {
|
|
|
756
896
|
shouldNotMatchObject: async (selector, object, options) => {
|
|
757
897
|
options = options ?? {};
|
|
758
898
|
|
|
899
|
+
object = await resolveVariable(object)
|
|
900
|
+
|
|
759
901
|
await expect(
|
|
760
902
|
await elementInteractions.textContent(selector),
|
|
761
903
|
).not.toMatchObject(object, options);
|
|
@@ -763,6 +905,8 @@ const assert = {
|
|
|
763
905
|
shouldNotStrictEqual: async (selector, expected, options) => {
|
|
764
906
|
options = options ?? {};
|
|
765
907
|
|
|
908
|
+
expected = await resolveVariable(expected)
|
|
909
|
+
|
|
766
910
|
await expect(
|
|
767
911
|
Number(await elementInteractions.textContent(selector)),
|
|
768
912
|
).not.toStrictEqual(expected, options);
|
|
@@ -770,11 +914,15 @@ const assert = {
|
|
|
770
914
|
shouldNotThrow: async (fn, options) => {
|
|
771
915
|
options = options ?? {};
|
|
772
916
|
|
|
917
|
+
fn = await resolveVariable(fn)
|
|
918
|
+
|
|
773
919
|
await expect(fn).not.toThrow(options);
|
|
774
920
|
},
|
|
775
921
|
shouldNotAny: async (selector, constructor, options) => {
|
|
776
922
|
options = options ?? {};
|
|
777
923
|
|
|
924
|
+
constructor = await await resolveVariable(constructor)
|
|
925
|
+
|
|
778
926
|
await expect(
|
|
779
927
|
await elementInteractions.textContent(selector),
|
|
780
928
|
).any.toBeInstanceOf(constructor, options);
|
|
@@ -789,6 +937,8 @@ const assert = {
|
|
|
789
937
|
shouldNotArrayContaining: async (selector, elements, options) => {
|
|
790
938
|
options = options ?? {};
|
|
791
939
|
|
|
940
|
+
elements = elements.map(element => resolveVariable(element))
|
|
941
|
+
|
|
792
942
|
await expect(await elementInteractions.textContent(selector)).not.toEqual(
|
|
793
943
|
expect.arrayContaining(elements),
|
|
794
944
|
options,
|
|
@@ -797,6 +947,9 @@ const assert = {
|
|
|
797
947
|
shouldNotCloseTo: async (selector, expected, precision, options) => {
|
|
798
948
|
options = options ?? {};
|
|
799
949
|
|
|
950
|
+
expected = await resolveVariable(expected)
|
|
951
|
+
precision = await resolveVariable(precision)
|
|
952
|
+
|
|
800
953
|
await expect(
|
|
801
954
|
Number(await elementInteractions.textContent(selector)),
|
|
802
955
|
).not.toBeCloseTo(expected, precision, options);
|
|
@@ -804,6 +957,8 @@ const assert = {
|
|
|
804
957
|
shouldNotObjectContaining: async (selector, properties, options) => {
|
|
805
958
|
options = options ?? {};
|
|
806
959
|
|
|
960
|
+
properties = await resolveVariable(properties)
|
|
961
|
+
|
|
807
962
|
await expect(await elementInteractions.textContent(selector)).not.toEqual(
|
|
808
963
|
expect.objectContaining(properties),
|
|
809
964
|
options,
|
|
@@ -812,6 +967,8 @@ const assert = {
|
|
|
812
967
|
shouldNotStringContaining: async (selector, substring, options) => {
|
|
813
968
|
options = options ?? {};
|
|
814
969
|
|
|
970
|
+
substring = await resolveVariable(substring)
|
|
971
|
+
|
|
815
972
|
await expect(await elementInteractions.textContent(selector)).not.toEqual(
|
|
816
973
|
expect.stringContaining(substring),
|
|
817
974
|
options,
|
|
@@ -820,6 +977,8 @@ const assert = {
|
|
|
820
977
|
shouldNotStringMatching: async (selector, regex, options) => {
|
|
821
978
|
options = options ?? {};
|
|
822
979
|
|
|
980
|
+
regex = await resolveVariable(regex)
|
|
981
|
+
|
|
823
982
|
await expect(await elementInteractions.textContent(selector)).not.toEqual(
|
|
824
983
|
expect.stringMatching(regex),
|
|
825
984
|
options,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const { element } = require("../imports/commons");
|
|
1
|
+
const { element, resolveVariable } = require("../imports/commons");
|
|
2
2
|
|
|
3
3
|
const elementInteractions = {
|
|
4
4
|
isChecked: async (selector, options) => {
|
|
@@ -34,6 +34,8 @@ const elementInteractions = {
|
|
|
34
34
|
getAttribute: async (selector, attribute, options) => {
|
|
35
35
|
options = options ?? {};
|
|
36
36
|
|
|
37
|
+
attribute = await resolveVariable(attribute)
|
|
38
|
+
|
|
37
39
|
return await element(selector).getAttribute(attribute, options);
|
|
38
40
|
},
|
|
39
41
|
innerHTML: async (selector, options) => {
|
|
@@ -1,41 +1,46 @@
|
|
|
1
1
|
const { element, resolveVariable } = require("../imports/commons");
|
|
2
|
-
const { frame } = require("./frameActions");
|
|
3
2
|
|
|
4
3
|
const keyboard = {
|
|
5
4
|
press: async (selector, key, options) => {
|
|
6
5
|
options = options ?? {};
|
|
7
6
|
|
|
8
7
|
key = await resolveVariable(key);
|
|
8
|
+
|
|
9
9
|
await element(selector).press(key, options);
|
|
10
10
|
},
|
|
11
11
|
pressSequentially: async (selector, keys, options) => {
|
|
12
12
|
options = options ?? {};
|
|
13
13
|
|
|
14
14
|
keys = await resolveVariable(keys);
|
|
15
|
+
|
|
15
16
|
await element(selector).pressSequentially(keys, options);
|
|
16
17
|
},
|
|
17
18
|
fill: async (selector, value, options) => {
|
|
18
19
|
options = options ?? {};
|
|
19
20
|
|
|
20
21
|
value = await resolveVariable(value);
|
|
22
|
+
|
|
21
23
|
value !== "" ? await element(selector).fill(value, options) : "";
|
|
22
24
|
},
|
|
23
25
|
keyDown: async (selector, key, options) => {
|
|
24
26
|
options = options ?? {};
|
|
25
27
|
|
|
26
28
|
key = await resolveVariable(key);
|
|
29
|
+
|
|
27
30
|
await element(selector).down(key, options);
|
|
28
31
|
},
|
|
29
32
|
keyUp: async (selector, key, options) => {
|
|
30
33
|
options = options ?? {};
|
|
31
34
|
|
|
32
35
|
key = await resolveVariable(key);
|
|
36
|
+
|
|
33
37
|
await element(selector).up(key, options);
|
|
34
38
|
},
|
|
35
39
|
insertText: async (selector, text, options) => {
|
|
36
40
|
options = options ?? {};
|
|
37
41
|
|
|
38
42
|
text = await resolveVariable(text);
|
|
43
|
+
|
|
39
44
|
await element(selector).insertText(text, options);
|
|
40
45
|
},
|
|
41
46
|
clear: async (selector, options) => {
|
|
@@ -3,7 +3,7 @@ const {
|
|
|
3
3
|
element,
|
|
4
4
|
context,
|
|
5
5
|
selector,
|
|
6
|
-
moduleConfig,
|
|
6
|
+
moduleConfig, resolveVariable
|
|
7
7
|
} = require("../imports/commons");
|
|
8
8
|
|
|
9
9
|
const mouse = {
|
|
@@ -37,11 +37,15 @@ const mouse = {
|
|
|
37
37
|
selectByValue: async (selector, value, options) => {
|
|
38
38
|
options = options ?? {};
|
|
39
39
|
|
|
40
|
+
value = await resolveVariable(value);
|
|
41
|
+
|
|
40
42
|
value !== "" ? await element(selector).selectOption(value, options) : "";
|
|
41
43
|
},
|
|
42
44
|
selectByText: async (selector, text, options) => {
|
|
43
45
|
options = options ?? {};
|
|
44
46
|
|
|
47
|
+
text = await resolveVariable(text);
|
|
48
|
+
|
|
45
49
|
text !== "" ? await element(selector).selectOption(text, options) : "";
|
|
46
50
|
},
|
|
47
51
|
check: async (selector, options) => {
|
|
@@ -62,6 +66,7 @@ const mouse = {
|
|
|
62
66
|
upload: async (filePath, fileInput, options) => {
|
|
63
67
|
options = options ?? {};
|
|
64
68
|
|
|
69
|
+
filePath = await resolveVariable(filePath);
|
|
65
70
|
const file = selector(filePath);
|
|
66
71
|
const fileChooserPromise = context.page.waitForEvent("filechooser");
|
|
67
72
|
await element(fileInput).click();
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
const { context, selector } = require("../imports/commons");
|
|
1
|
+
const { context, selector, resolveVariable } = require("../imports/commons");
|
|
2
2
|
|
|
3
3
|
const page = {
|
|
4
4
|
navigateTo: async (url, options) => {
|
|
5
5
|
options = options ?? {};
|
|
6
6
|
|
|
7
|
-
url =
|
|
7
|
+
url = await resolveVariable(url);
|
|
8
|
+
url = await selector(url);
|
|
9
|
+
|
|
8
10
|
return await context.page.goto(url, options);
|
|
9
11
|
},
|
|
10
12
|
getURL: async (options) => {
|
|
@@ -30,6 +32,8 @@ const page = {
|
|
|
30
32
|
wait: async (time, options) => {
|
|
31
33
|
options = options ?? {};
|
|
32
34
|
|
|
35
|
+
time = await resolveVariable(time);
|
|
36
|
+
|
|
33
37
|
return await context.page.waitForTimeout(time, options);
|
|
34
38
|
},
|
|
35
39
|
};
|
|
@@ -5,7 +5,7 @@ const {
|
|
|
5
5
|
saveVar,
|
|
6
6
|
time,
|
|
7
7
|
random,
|
|
8
|
-
moduleConfig,
|
|
8
|
+
moduleConfig, resolveVariable
|
|
9
9
|
} = require("../helper/imports/commons");
|
|
10
10
|
const { api } = require("../helper/stepFunctions/exporter");
|
|
11
11
|
const path = require("path");
|
|
@@ -239,37 +239,29 @@ When("User wants to see response body", async function () {
|
|
|
239
239
|
});
|
|
240
240
|
|
|
241
241
|
When(
|
|
242
|
-
"User sends {string} request to {string}",
|
|
243
|
-
async function (method, url,
|
|
242
|
+
"User sends {string} request to {string} with payload:",
|
|
243
|
+
async function (method, url, payload) {
|
|
244
244
|
const httpMethod = method.toUpperCase();
|
|
245
245
|
|
|
246
|
-
let headers = {};
|
|
247
|
-
let body;
|
|
248
|
-
|
|
249
|
-
if (["POST", "PUT", "PATCH"].includes(httpMethod)) {
|
|
250
|
-
const payload = JSON.parse(reqParams);
|
|
251
|
-
headers = payload.headers || {};
|
|
252
|
-
body = payload.body || {};
|
|
253
|
-
}
|
|
254
246
|
|
|
255
247
|
switch (httpMethod) {
|
|
256
248
|
case "GET":
|
|
257
|
-
await api.get(url);
|
|
249
|
+
await api.get(url, payload);
|
|
258
250
|
break;
|
|
259
251
|
case "HEAD":
|
|
260
|
-
await api.head(url);
|
|
252
|
+
await api.head(url, payload);
|
|
261
253
|
break;
|
|
262
254
|
case "POST":
|
|
263
|
-
await api.post(url,
|
|
255
|
+
await api.post(url, payload);
|
|
264
256
|
break;
|
|
265
257
|
case "PUT":
|
|
266
|
-
await api.put(url,
|
|
258
|
+
await api.put(url, payload);
|
|
267
259
|
break;
|
|
268
260
|
case "PATCH":
|
|
269
|
-
await api.patch(url,
|
|
261
|
+
await api.patch(url, payload);
|
|
270
262
|
break;
|
|
271
263
|
case "DELETE":
|
|
272
|
-
await api.delete(url);
|
|
264
|
+
await api.delete(url, payload);
|
|
273
265
|
break;
|
|
274
266
|
default:
|
|
275
267
|
throw new Error(`Unsupported HTTP method: ${httpMethod}`);
|
|
@@ -308,6 +300,8 @@ When(
|
|
|
308
300
|
When(
|
|
309
301
|
"User convert {string} into base64 as {string}",
|
|
310
302
|
async (file, variable) => {
|
|
303
|
+
file = await resolveVariable(file);
|
|
304
|
+
|
|
311
305
|
const filePath = await path.join(moduleConfig.projectPath, file);
|
|
312
306
|
const fileData = await fs.readFileSync(filePath);
|
|
313
307
|
const base64Data = await fileData.toString("base64");
|
|
@@ -5,7 +5,7 @@ const {
|
|
|
5
5
|
element,
|
|
6
6
|
extractVarsFromResponse,
|
|
7
7
|
context,
|
|
8
|
-
resolveVariable
|
|
8
|
+
resolveVariable
|
|
9
9
|
} = require("../helper/imports/commons");
|
|
10
10
|
const { assert, frame } = require("../helper/stepFunctions/exporter");
|
|
11
11
|
const Ajv = require("ajv");
|
|
@@ -837,6 +837,7 @@ Then(
|
|
|
837
837
|
Then(
|
|
838
838
|
"User expects that response body should match {string} schema",
|
|
839
839
|
async function (expectedSchema) {
|
|
840
|
+
expectedSchema = await resolveVariable(expectedSchema);
|
|
840
841
|
if (expectedSchema != "") {
|
|
841
842
|
const schema = await selector(expectedSchema);
|
|
842
843
|
const ajv = await new Ajv();
|
|
@@ -851,6 +852,7 @@ Then(
|
|
|
851
852
|
Then(
|
|
852
853
|
"User expects that request should have {int} status code",
|
|
853
854
|
async function (expectedStatusCode) {
|
|
855
|
+
expectedStatusCode = await resolveVariable(expectedStatusCode);
|
|
854
856
|
const actualStatusCode = await context.response.Response.status();
|
|
855
857
|
expect(actualStatusCode).toBe(expectedStatusCode);
|
|
856
858
|
},
|
|
@@ -859,6 +861,7 @@ Then(
|
|
|
859
861
|
Then(
|
|
860
862
|
"User expects that response should have {int} status code",
|
|
861
863
|
async function (expectedStatusCode) {
|
|
864
|
+
expectedStatusCode = await resolveVariable(expectedStatusCode);
|
|
862
865
|
const actualStatusCode = await context.response.Response.status();
|
|
863
866
|
expect(actualStatusCode).toBe(expectedStatusCode);
|
|
864
867
|
},
|
|
@@ -3,7 +3,7 @@ const {
|
|
|
3
3
|
random,
|
|
4
4
|
element,
|
|
5
5
|
selector,
|
|
6
|
-
time,
|
|
6
|
+
time, resolveVariable
|
|
7
7
|
} = require("../helper/imports/commons");
|
|
8
8
|
const { keyboard, frame } = require("../helper/stepFunctions/exporter");
|
|
9
9
|
|
|
@@ -225,6 +225,9 @@ When("User types random middle name in {string}", async (input) => {
|
|
|
225
225
|
When(
|
|
226
226
|
"User types random date between {int} and {int} in {string}",
|
|
227
227
|
async (fromYear, toYear, input) => {
|
|
228
|
+
fromYear = await resolveVariable(fromYear);
|
|
229
|
+
toYear = await resolveVariable(toYear);
|
|
230
|
+
|
|
228
231
|
const year = Math.floor(Math.random() * (toYear - fromYear + 1)) + fromYear;
|
|
229
232
|
const month = Math.floor(Math.random() * 12) + 1;
|
|
230
233
|
const day = Math.floor(Math.random() * 28) + 1;
|
|
@@ -237,6 +240,9 @@ When(
|
|
|
237
240
|
When(
|
|
238
241
|
"User types date {int} days after today in {string}",
|
|
239
242
|
async (day, input) => {
|
|
243
|
+
|
|
244
|
+
day = await resolveVariable(day);
|
|
245
|
+
|
|
240
246
|
const now = new time();
|
|
241
247
|
const afterDate = now.add(day, "day").format("DD-MM-YYYY");
|
|
242
248
|
await element(input).fill(afterDate);
|
|
@@ -246,6 +252,9 @@ When(
|
|
|
246
252
|
When(
|
|
247
253
|
"User types date {int} days before today in {string}",
|
|
248
254
|
async (day, input) => {
|
|
255
|
+
|
|
256
|
+
day = await resolveVariable(day);
|
|
257
|
+
|
|
249
258
|
const now = new time();
|
|
250
259
|
const beforeDate = now.subtract(day, "day").format("DD-MM-YYYY");
|
|
251
260
|
await element(input).fill(beforeDate);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const { Given, context, random, time } = require("../helper/imports/commons");
|
|
1
|
+
const { Given, context, random, time, resolveVariable } = require("../helper/imports/commons");
|
|
2
2
|
const { api } = require("../helper/stepFunctions/exporter");
|
|
3
3
|
|
|
4
4
|
Given("User sets random word as {string}", async (key) => {
|
|
@@ -153,6 +153,10 @@ Given("User sets random middle name as {string}", async (key) => {
|
|
|
153
153
|
Given(
|
|
154
154
|
"User sets random date between {int} and {int} as {string}",
|
|
155
155
|
async (fromYear, toYear, key) => {
|
|
156
|
+
|
|
157
|
+
fromYear = await resolveVariable(fromYear);
|
|
158
|
+
toYear = await resolveVariable(toYear);
|
|
159
|
+
|
|
156
160
|
const year = Math.floor(Math.random() * (toYear - fromYear + 1)) + fromYear;
|
|
157
161
|
const month = Math.floor(Math.random() * 12) + 1;
|
|
158
162
|
const day = Math.floor(Math.random() * 28) + 1;
|
|
@@ -163,6 +167,9 @@ Given(
|
|
|
163
167
|
);
|
|
164
168
|
|
|
165
169
|
Given("User sets date {int} days after today as {string}", async (day, key) => {
|
|
170
|
+
|
|
171
|
+
day = await resolveVariable(day);
|
|
172
|
+
|
|
166
173
|
const now = new time();
|
|
167
174
|
const afterDate = now.add(day, "day").format("DD-MM-YYYY");
|
|
168
175
|
context.vars[key] = afterDate;
|
|
@@ -171,6 +178,9 @@ Given("User sets date {int} days after today as {string}", async (day, key) => {
|
|
|
171
178
|
Given(
|
|
172
179
|
"User sets date {int} days before today as {string}",
|
|
173
180
|
async (day, key) => {
|
|
181
|
+
|
|
182
|
+
day = await resolveVariable(day);
|
|
183
|
+
|
|
174
184
|
const now = new time();
|
|
175
185
|
const beforeDate = now.subtract(day, "day").format("DD-MM-YYYY");
|
|
176
186
|
context.vars[key] = beforeDate;
|