artes 1.7.19 → 1.7.21

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.
Files changed (49) hide show
  1. package/README.md +781 -781
  2. package/assets/styles.css +4 -4
  3. package/cucumber.config.js +253 -253
  4. package/docs/ciExecutors.md +198 -198
  5. package/docs/emulationDevicesList.md +152 -152
  6. package/docs/functionDefinitions.md +2401 -2401
  7. package/docs/stepDefinitions.md +435 -435
  8. package/executer.js +266 -266
  9. package/index.js +51 -51
  10. package/package.json +56 -56
  11. package/src/helper/contextManager/browserManager.js +74 -74
  12. package/src/helper/contextManager/requestManager.js +23 -23
  13. package/src/helper/controller/elementController.js +230 -230
  14. package/src/helper/controller/findDuplicateTestNames.js +69 -69
  15. package/src/helper/controller/getEnvInfo.js +97 -97
  16. package/src/helper/controller/getExecutor.js +109 -109
  17. package/src/helper/controller/pomCollector.js +83 -83
  18. package/src/helper/controller/reportCustomizer.js +511 -511
  19. package/src/helper/controller/screenComparer.js +96 -96
  20. package/src/helper/controller/status-formatter.js +137 -137
  21. package/src/helper/controller/testCoverageCalculator.js +111 -111
  22. package/src/helper/executers/cleaner.js +23 -23
  23. package/src/helper/executers/exporter.js +19 -19
  24. package/src/helper/executers/helper.js +193 -193
  25. package/src/helper/executers/projectCreator.js +226 -226
  26. package/src/helper/executers/reportGenerator.js +91 -91
  27. package/src/helper/executers/testRunner.js +28 -28
  28. package/src/helper/executers/versionChecker.js +31 -31
  29. package/src/helper/imports/commons.js +69 -69
  30. package/src/helper/stepFunctions/APIActions.js +582 -582
  31. package/src/helper/stepFunctions/assertions.js +986 -986
  32. package/src/helper/stepFunctions/browserActions.js +87 -87
  33. package/src/helper/stepFunctions/elementInteractions.js +60 -60
  34. package/src/helper/stepFunctions/exporter.js +19 -19
  35. package/src/helper/stepFunctions/frameActions.js +72 -72
  36. package/src/helper/stepFunctions/keyboardActions.js +66 -66
  37. package/src/helper/stepFunctions/mouseActions.js +84 -84
  38. package/src/helper/stepFunctions/pageActions.js +43 -43
  39. package/src/hooks/context.js +18 -18
  40. package/src/hooks/hooks.js +287 -287
  41. package/src/stepDefinitions/API.steps.js +404 -404
  42. package/src/stepDefinitions/assertions.steps.js +1358 -1351
  43. package/src/stepDefinitions/browser.steps.js +74 -74
  44. package/src/stepDefinitions/frameActions.steps.js +76 -76
  45. package/src/stepDefinitions/keyboardActions.steps.js +264 -264
  46. package/src/stepDefinitions/mouseActions.steps.js +374 -374
  47. package/src/stepDefinitions/page.steps.js +71 -71
  48. package/src/stepDefinitions/random.steps.js +199 -199
  49. package/src/stepDefinitions/report.steps.js +5 -5
@@ -1,1352 +1,1359 @@
1
- const {
2
- Then,
3
- selector,
4
- expect,
5
- element,
6
- extractVarsFromResponse,
7
- pathToCamelCase,
8
- context,
9
- resolveVariable,
10
- } = require("../helper/imports/commons");
11
- const {
12
- screenComparer,
13
- } = require("../helper/controller/screenComparer");
14
- const { assert, frame } = require("../helper/stepFunctions/exporter");
15
- const Ajv = require("ajv");
16
-
17
-
18
- // Check if a selector should be attached
19
- Then("User expects {string} should be attached", async function (selector) {
20
- await assert.shouldBeAttached(selector);
21
- });
22
-
23
- Then(
24
- "User expects {int} th of {string} should be attached",
25
- async function (order, elements) {
26
- const nthElement = await frame.nth(elements, order);
27
- await assert.shouldBeAttached(nthElement);
28
- },
29
- );
30
-
31
- // Check if a selector should be checked
32
- Then("User expects {string} should be checked", async function (selector) {
33
- await assert.shouldBeChecked(selector);
34
- });
35
-
36
- Then(
37
- "User expects {int} th of {string} should be checked",
38
- async function (order, elements) {
39
- const nthElement = await frame.nth(elements, order);
40
- await assert.shouldBeChecked(nthElement);
41
- },
42
- );
43
-
44
- // Check if a selector should be disabled
45
- Then("User expects {string} should be disabled", async function (selector) {
46
- await assert.shouldBeDisabled(selector);
47
- });
48
-
49
- Then(
50
- "User expects {int} th of {string} should be disabled",
51
- async function (order, elements) {
52
- const nthElement = await frame.nth(elements, order);
53
- await assert.shouldBeDisabled(nthElement);
54
- },
55
- );
56
-
57
- // Check if a selector should be editable
58
- Then("User expects {string} should be editable", async function (selector) {
59
- await assert.shouldBeEditable(selector);
60
- });
61
-
62
- Then(
63
- "User expects {int} th of {string} should be editable",
64
- async function (order, elements) {
65
- const nthElement = await frame.nth(elements, order);
66
- await assert.shouldBeEditable(nthElement);
67
- },
68
- );
69
-
70
- // Check if a selector should be empty
71
- Then("User expects {string} should be empty", async function (selector) {
72
- await assert.shouldBeEmpty(selector);
73
- });
74
-
75
- Then(
76
- "User expects {int} th of {string} should be empty",
77
- async function (order, elements) {
78
- const nthElement = await frame.nth(elements, order);
79
- await assert.shouldBeEmpty(nthElement);
80
- },
81
- );
82
-
83
- // Check if a selector should be enabled
84
- Then("User expects {string} should be enabled", async function (selector) {
85
- await assert.shouldBeEnabled(selector);
86
- });
87
-
88
- Then(
89
- "User expects {int} th of {string} should be enabled",
90
- async function (order, elements) {
91
- const nthElement = await frame.nth(elements, order);
92
- await assert.shouldBeEnabled(nthElement);
93
- },
94
- );
95
-
96
- // Check if a selector should be focused
97
- Then("User expects {string} should be focused", async function (selector) {
98
- await assert.shouldBeFocused(selector);
99
- });
100
-
101
- Then(
102
- "User expects {int} th of {string} should be focused",
103
- async function (order, elements) {
104
- const nthElement = await frame.nth(elements, order);
105
- await assert.shouldBeFocused(nthElement);
106
- },
107
- );
108
-
109
- // Check if a selector should be hidden
110
- Then("User expects {string} should be hidden", async function (selector) {
111
- await assert.shouldBeHidden(selector);
112
- });
113
-
114
- Then(
115
- "User expects {int} th of {string} should be hidden",
116
- async function (order, elements) {
117
- const nthElement = await frame.nth(elements, order);
118
- await assert.shouldBeHidden(nthElement);
119
- },
120
- );
121
-
122
- // Check if a selector should be in the viewport
123
- Then(
124
- "User expects {string} should be on the screen",
125
- async function (selector) {
126
- await assert.shouldBeInViewport(selector);
127
- },
128
- );
129
-
130
- Then(
131
- "User expects {int} th of {string} should be on the screen",
132
- async function (order, elements) {
133
- const nthElement = await frame.nth(elements, order);
134
- await assert.shouldBeInViewport(nthElement);
135
- },
136
- );
137
-
138
- Then(
139
- "User expects {int} th of {string} should be screen",
140
- async function (order, elements) {
141
- const nthElement = await frame.nth(elements, order);
142
- await assert.shouldBeInViewport(nthElement);
143
- },
144
- );
145
-
146
- // Check if a selector should be visible
147
- Then("User expects {string} should be visible", async function (selector) {
148
- await assert.shouldBeVisible(selector);
149
- });
150
-
151
- Then(
152
- "User expects {int} th of {string} should be visible",
153
- async function (order, elements) {
154
- const nthElement = await frame.nth(elements, order);
155
- await assert.shouldBeVisible(nthElement);
156
- },
157
- );
158
-
159
- // Check if a selector should contain specific text
160
- Then(
161
- "User expects {string} should have {string} text",
162
- async function (selector, text) {
163
- await assert.shouldContainText(selector, text);
164
- },
165
- );
166
-
167
- Then(
168
- "User expects {int} th of {string} should have {string} text",
169
- async function (order, elements, text) {
170
- const nthElement = await frame.nth(elements, order);
171
- await assert.shouldContainText(nthElement, text);
172
- },
173
- );
174
-
175
- Then(
176
- "User expects default value of {string} should have {string} text",
177
- async (selector, text) => {
178
- const defaultValue = await element(selector).inputValue();
179
- await expect(defaultValue).toContain(text);
180
- },
181
- );
182
-
183
- Then(
184
- "User expects default value of {int} th of {string} should have {string} text",
185
- async function (order, elements, text) {
186
- const nthElement = await frame.nth(elements, order);
187
- await assert.toContain(nthElement, text);
188
- },
189
- );
190
-
191
- Then(
192
- "User expects multiple {string} should have {string} text",
193
- async (elements, expectedText) => {
194
- await assert.multipleElementsShouldContainText(elements, expectedText);
195
- },
196
- );
197
-
198
- // Check if a selector should have an accessible description
199
- Then(
200
- "User expects {string} should have {string} description",
201
- async function (selector, description) {
202
- await assert.shouldHaveAccessibleDescription(selector, description);
203
- },
204
- );
205
-
206
- Then(
207
- "User expects {int} th of {string} should have {string} description",
208
- async function (order, elements, text) {
209
- const nthElement = await frame.nth(elements, order);
210
- await assert.shouldHaveAccessibleDescription(nthElement, text);
211
- },
212
- );
213
-
214
- // Check if a selector should have an accessible name
215
- Then(
216
- "User expects {string} should have {string} name",
217
- async function (selector, name) {
218
- await assert.shouldHaveAccessibleName(selector, name);
219
- },
220
- );
221
-
222
- Then(
223
- "User expects {int} th of {string} should have {string} name",
224
- async function (order, elements, text) {
225
- const nthElement = await frame.nth(elements, order);
226
- await assert.shouldHaveAccessibleName(nthElement, text);
227
- },
228
- );
229
-
230
- // Check if a selector should have a specific attribute with a given value
231
- Then(
232
- "User expects {string} should have {string} attribute with {string} value",
233
- async function (selector, attribute, value) {
234
- await assert.shouldHaveAttribute(selector, attribute, value);
235
- },
236
- );
237
-
238
- Then(
239
- "User expects {int} th of {string} should have {string} attribute with {string} value",
240
- async function (order, elements, attribute, value) {
241
- const nthElement = await frame.nth(elements, order);
242
- await assert.shouldHaveAttribute(nthElement, attribute, value);
243
- },
244
- );
245
-
246
- // Check if a selector should have a specific class
247
- Then(
248
- "User expects {string} should have {string} class",
249
- async function (selector, className) {
250
- await assert.shouldHaveClass(selector, className);
251
- },
252
- );
253
-
254
- Then(
255
- "User expects {int} th of {string} should have {string} class",
256
- async function (order, elements, className) {
257
- const nthElement = await frame.nth(elements, order);
258
- await assert.shouldHaveClass(nthElement, className);
259
- },
260
- );
261
-
262
- // Check if a selector should have a specific count
263
- Then(
264
- "User expects count of {string} should be {int}",
265
- async function (selector, count) {
266
- await assert.shouldHaveCount(selector, count);
267
- },
268
- );
269
-
270
- // Check if a selector should have a specific CSS property with a given value
271
- Then(
272
- "User expects {string} should have {string} CSS property with {string} value",
273
- async function (selector, property, value) {
274
- await assert.shouldHaveCSS(selector, property, value);
275
- },
276
- );
277
-
278
- Then(
279
- "User expects {int} th of {string} should have {string} CSS property with {string} value",
280
- async function (order, elements, property, value) {
281
- const nthElement = await frame.nth(elements, order);
282
- await assert.shouldHaveCSS(nthElement, property, value);
283
- },
284
- );
285
-
286
- // Check if a selector should have a specific id
287
- Then(
288
- "User expects {string} should have {string} id",
289
- async function (selector, id) {
290
- await assert.shouldHaveId(selector, id);
291
- },
292
- );
293
-
294
- Then(
295
- "User expects {int} th of {string} should have {string} id",
296
- async function (order, elements, id) {
297
- const nthElement = await frame.nth(elements, order);
298
- await assert.shouldHaveId(nthElement, id);
299
- },
300
- );
301
-
302
- // Check if a selector should have a specific JavaScript property with a given value
303
- Then(
304
- "User expects {string} should have {string} JavaScript property with {string} value",
305
- async function (selector, property, value) {
306
- await assert.shouldHaveJSProperty(selector, property, value);
307
- },
308
- );
309
-
310
- Then(
311
- "User expects {int} th of {string} should have {string} JavaScript property with {string} value",
312
- async function (order, elements, property, value) {
313
- const nthElement = await frame.nth(elements, order);
314
- await assert.shouldHaveJSProperty(nthElement, property, value);
315
- },
316
- );
317
-
318
- // Check if a selector should have a specific role
319
- Then(
320
- "User expects {string} should have {string} role",
321
- async function (selector, role) {
322
- await assert.shouldHaveRole(selector, role);
323
- },
324
- );
325
-
326
- Then(
327
- "User expects {int} th of {string} should have {string} role",
328
- async function (order, elements, role) {
329
- const nthElement = await frame.nth(elements, order);
330
- await assert.shouldHaveId(nthElement, role);
331
- },
332
- );
333
-
334
- Then(
335
- "User expects that full page match with {string} screenshot",
336
- async function (baselineFilename) {
337
- await screenComparer(
338
- baselineFilename,
339
- (actualPath) =>
340
- context.page.screenshot({ path: actualPath, fullPage: true }),
341
- { maxDiffPercent: 0.01 },
342
- );
343
- },
344
- );
345
-
346
- Then(
347
- "User expects that full page match with {string} screenshot with {float}% difference",
348
- async function (baselineFilename, maxDiff) {
349
- await screenComparer(
350
- baselineFilename,
351
- (actualPath) =>
352
- context.page.screenshot({ path: actualPath, fullPage: true }),
353
- { maxDiffPercent: maxDiff / 100 },
354
- );
355
- },
356
- );
357
-
358
- Then(
359
- "User expects that page match with {string} screenshot",
360
- async function (baselineFilename) {
361
- await screenComparer(
362
- baselineFilename,
363
- (actualPath) =>
364
- context.page.screenshot({ path: actualPath, fullPage: false }),
365
- { maxDiffPercent: 0.01 },
366
- );
367
- },
368
- );
369
-
370
- Then(
371
- "User expects that page match with {string} screenshot with {float}% difference",
372
- async function (baselineFilename, maxDiff) {
373
- await screenComparer(
374
- baselineFilename,
375
- (actualPath) =>
376
- context.page.screenshot({ path: actualPath, fullPage: false }),
377
- { maxDiffPercent: maxDiff / 100 },
378
- );
379
- },
380
- );
381
-
382
- Then(
383
- "User expects that {string} element match with {string} screenshot",
384
- async function (selector, baselineFilename) {
385
- await screenComparer(
386
- baselineFilename,
387
- (actualPath) => element(selector).screenshot({ path: actualPath }),
388
- { maxDiffPercent: 0.01 },
389
- );
390
- },
391
- );
392
-
393
- Then(
394
- "User expects that {string} element match with {string} screenshot with {float}% difference",
395
- async function (selector, baselineFilename, maxDiff) {
396
- await screenComparer(
397
- baselineFilename,
398
- (actualPath) => element(selector).screenshot({ path: actualPath }),
399
- { maxDiffPercent: maxDiff / 100 },
400
- );
401
- },
402
- );
403
-
404
-
405
- Then(
406
- "User expects that {string} screenshot match with {string} screenshot",
407
- async function (ss1, ss2) {
408
- await screenComparer(
409
- ss1,
410
- null,
411
- { maxDiffPercent: 0.01, comparePath: ss2 },
412
- );
413
- },
414
- );
415
-
416
- Then(
417
- "User expects that {string} screenshot match with {string} screenshot with {float}% difference",
418
- async function (ss1, ss2, maxDiff) {
419
- await screenComparer(
420
- ss1,
421
- null,
422
- { maxDiffPercent: maxDiff / 100, comparePath: ss2 },
423
- );
424
- },
425
- );
426
-
427
- // Check if a selector should have specific text
428
- Then(
429
- "User expects {string} should match {string} text",
430
- async function (selector, text) {
431
- await assert.shouldHaveText(selector, text);
432
- },
433
- );
434
-
435
- Then(
436
- "User expects {int} th of {string} should match {string} text",
437
- async function (order, elements, text) {
438
- const nthElement = await frame.nth(elements, order);
439
- await assert.shouldHaveText(nthElement, text);
440
- },
441
- );
442
-
443
- // Check if a selector should have a specific value
444
- Then(
445
- "User expects {string} should have {string} value",
446
- async function (selector, value) {
447
- await assert.shouldHaveValue(selector, value);
448
- },
449
- );
450
-
451
- Then(
452
- "User expects {int} th of {string} should have {string} value",
453
- async function (order, elements, value) {
454
- const nthElement = await frame.nth(elements, order);
455
- await assert.shouldHaveValue(nthElement, value);
456
- },
457
- );
458
-
459
- // Check if a selector should have specific values
460
- Then(
461
- "User expects {string} should have {string} values",
462
- async function (selector, values) {
463
- await assert.shouldHaveValues(selector, values.split(","));
464
- },
465
- );
466
-
467
- // Check if the page should have a screenshot
468
- Then("User expects the page should have a screenshot", async function () {
469
- await assert.shouldPageHaveScreenshot();
470
- });
471
-
472
- // Check if the page should have a specific title
473
- Then(
474
- "User expects the page should have {string} title",
475
- async function (title) {
476
- await assert.shouldPageHaveTitle(title);
477
- },
478
- );
479
-
480
- // Check if the page should have a specific URL
481
- Then("User expects to be in {string} page", async function (url) {
482
- const URL = await selector(url);
483
- await assert.shouldPageHaveURL(URL);
484
- });
485
-
486
- // Check if a selector should not be attached
487
- Then("User expects {string} should not be attached", async function (selector) {
488
- await assert.shouldNotBeAttached(selector);
489
- });
490
-
491
- Then(
492
- "User expects {int} th of {string} should be not be attached",
493
- async function (order, elements) {
494
- const nthElement = await frame.nth(elements, order);
495
- await assert.shouldNotBeAttached(nthElement);
496
- },
497
- );
498
-
499
- // Check if a selector should not be checked
500
- Then("User expects {string} should not be checked", async function (selector) {
501
- await assert.shouldNotBeChecked(selector);
502
- });
503
-
504
- Then(
505
- "User expects {int} th of {string} should be not be checked",
506
- async function (order, elements) {
507
- const nthElement = await frame.nth(elements, order);
508
- await assert.shouldNotBeChecked(nthElement);
509
- },
510
- );
511
-
512
- // Check if a selector should not be disabled
513
- Then("User expects {string} should not be disabled", async function (selector) {
514
- await assert.shouldNotBeDisabled(selector);
515
- });
516
-
517
- Then(
518
- "User expects {int} th of {string} should be not be disabled",
519
- async function (order, elements) {
520
- const nthElement = await frame.nth(elements, order);
521
- await assert.shouldNotBeDisabled(nthElement);
522
- },
523
- );
524
-
525
- // Check if a selector should not be editable
526
- Then("User expects {string} should not be editable", async function (selector) {
527
- await assert.shouldNotBeEditable(selector);
528
- });
529
-
530
- Then(
531
- "User expects {int} th of {string} should be not be editable",
532
- async function (order, elements) {
533
- const nthElement = await frame.nth(elements, order);
534
- await assert.shouldNotBeEditable(nthElement);
535
- },
536
- );
537
-
538
- // Check if a selector should not be empty
539
- Then("User expects {string} should not be empty", async function (selector) {
540
- await assert.shouldNotBeEmpty(selector);
541
- });
542
-
543
- Then(
544
- "User expects {int} th of {string} should be not be empty",
545
- async function (order, elements) {
546
- const nthElement = await frame.nth(elements, order);
547
- await assert.shouldNotBeEmpty(nthElement);
548
- },
549
- );
550
-
551
- // Check if a selector should not be enabled
552
- Then("User expects {string} should not be enabled", async function (selector) {
553
- await assert.shouldNotBeEnabled(selector);
554
- });
555
-
556
- Then(
557
- "User expects {int} th of {string} should be not be enabled",
558
- async function (order, elements) {
559
- const nthElement = await frame.nth(elements, order);
560
- await assert.shouldNotBeEnabled(nthElement);
561
- },
562
- );
563
-
564
- // Check if a selector should not be focused
565
- Then("User expects {string} should not be focused", async function (selector) {
566
- await assert.shouldNotBeFocused(selector);
567
- });
568
-
569
- Then(
570
- "User expects {int} th of {string} should be not be focused",
571
- async function (order, elements) {
572
- const nthElement = await frame.nth(elements, order);
573
- await assert.shouldNotBeFocused(nthElement);
574
- },
575
- );
576
-
577
- // Check if a selector should not be hidden
578
- Then("User expects {string} should not be hidden", async function (selector) {
579
- await assert.shouldNotBeHidden(selector);
580
- });
581
-
582
- Then(
583
- "User expects {int} th of {string} should be not be hidden",
584
- async function (order, elements) {
585
- const nthElement = await frame.nth(elements, order);
586
- await assert.shouldNotBeHidden(nthElement);
587
- },
588
- );
589
-
590
- // Check if a selector should not be in the viewport
591
- Then(
592
- "User expects {string} should not be on the screen",
593
- async function (selector) {
594
- await assert.shouldNotBeInViewport(selector);
595
- },
596
- );
597
-
598
- Then(
599
- "User expects {int} th of {string} should not be on the screen",
600
- async function (order, elements) {
601
- const nthElement = await frame.nth(elements, order);
602
- await assert.shouldNotBeInViewport(nthElement);
603
- },
604
- );
605
-
606
- // Check if a selector should not be visible
607
- Then("User expects {string} should not be visible", async function (selector) {
608
- await assert.shouldNotBeVisible(selector);
609
- });
610
-
611
- Then(
612
- "User expects {int} th of {string} should not be visible",
613
- async function (order, elements) {
614
- const nthElement = await frame.nth(elements, order);
615
- await assert.shouldNotBeVisible(nthElement);
616
- },
617
- );
618
-
619
- // Check if a selector should not contain specific text
620
- Then(
621
- "User expects {string} should not have {string} text",
622
- async function (selector, text) {
623
- await assert.shouldNotContainText(selector, text);
624
- },
625
- );
626
-
627
- Then(
628
- "User expects {int} th of {string} should not have {string} text",
629
- async function (order, elements, text) {
630
- const nthElement = await frame.nth(elements, order);
631
- await assert.shouldNotContainText(nthElement, text);
632
- },
633
- );
634
-
635
- // Check if a selector should not have an accessible description
636
- Then(
637
- "User expects {string} should not have {string} description",
638
- async function (selector, description) {
639
- await assert.shouldNotHaveAccessibleDescription(selector, description);
640
- },
641
- );
642
-
643
- Then(
644
- "User expects {int} th of {string} should not have {string} description",
645
- async function (order, elements, text) {
646
- const nthElement = await frame.nth(elements, order);
647
- await assert.shouldNotHaveAccessibleDescription(nthElement, text);
648
- },
649
- );
650
-
651
- // Check if a selector should not have an accessible name
652
- Then(
653
- "User expects {string} should not have {string} name",
654
- async function (selector, name) {
655
- await assert.shouldNotHaveAccessibleName(selector, name);
656
- },
657
- );
658
-
659
- Then(
660
- "User expects {int} th of {string} should not have {string} name",
661
- async function (order, elements, text) {
662
- const nthElement = await frame.nth(elements, order);
663
- await assert.shouldNotHaveAccessibleName(nthElement, text);
664
- },
665
- );
666
-
667
- // Check if a selector should not have a specific attribute with a given value
668
- Then(
669
- "User expects {string} should not have {string} attribute with {string} value",
670
- async function (selector, attribute, value) {
671
- await assert.shouldNotHaveAttribute(selector, attribute, value);
672
- },
673
- );
674
-
675
- Then(
676
- "User expects {int} th of {string} should have {string} attribute with {string} value",
677
- async function (order, elements, attribute, value) {
678
- const nthElement = await frame.nth(elements, order);
679
- await assert.shouldNotHaveAttribute(nthElement, attribute, value);
680
- },
681
- );
682
-
683
- // Check if a selector should not have a specific class
684
- Then(
685
- "User expects {string} should not have {string} class",
686
- async function (selector, className) {
687
- await assert.shouldNotHaveClass(selector, className);
688
- },
689
- );
690
-
691
- Then(
692
- "User expects {int} th of {string} should not have {string} class",
693
- async function (order, elements, text) {
694
- const nthElement = await frame.nth(elements, order);
695
- await assert.shouldNotHaveClass(nthElement, text);
696
- },
697
- );
698
-
699
- // Check if a selector should not have a specific count
700
- Then(
701
- "User expects count of {string} should not be {int}",
702
- async function (selector, count) {
703
- await assert.shouldNotHaveCount(selector, count);
704
- },
705
- );
706
-
707
- // Check if a selector should not have a specific CSS property with a given value
708
- Then(
709
- "User expects {string} should not have {string} CSS property with {string} value",
710
- async function (selector, property, value) {
711
- await assert.shouldNotHaveCSS(selector, property, value);
712
- },
713
- );
714
-
715
- Then(
716
- "User expects {int} th of {string} should not have {string} CSS property with {string} value",
717
- async function (order, elements, property, value) {
718
- const nthElement = await frame.nth(elements, order);
719
- await assert.shouldNotHaveCSS(nthElement, property, value);
720
- },
721
- );
722
-
723
- // Check if a selector should not have a specific ID
724
- Then(
725
- "User expects {string} should not have {string} id",
726
- async function (selector, id) {
727
- await assert.shouldNotHaveId(selector, id);
728
- },
729
- );
730
-
731
- Then(
732
- "User expects {int} th of {string} should not have {string} id",
733
- async function (order, elements, text) {
734
- const nthElement = await frame.nth(elements, order);
735
- await assert.shouldNotHaveId(nthElement, text);
736
- },
737
- );
738
-
739
- // Check if a selector should not have a specific JavaScript property with a given value
740
- Then(
741
- "User expects {string} should not have {string} JavaScript property with {string} value",
742
- async function (selector, property, value) {
743
- await assert.shouldNotHaveJSProperty(selector, property, value);
744
- },
745
- );
746
-
747
- Then(
748
- "User expects {int} th of {string} should not have {string} JavaScript property with {string} value",
749
- async function (order, elements, property, value) {
750
- const nthElement = await frame.nth(elements, order);
751
- await assert.shouldNotHaveJSProperty(nthElement, property, value);
752
- },
753
- );
754
-
755
- // Check if a selector should not have a specific role
756
- Then(
757
- "User expects {string} should not have {string} role",
758
- async function (selector, role) {
759
- await assert.shouldNotHaveRole(selector, role);
760
- },
761
- );
762
-
763
- Then(
764
- "User expects {int} th of {string} should not have {string} role",
765
- async function (order, elements, text) {
766
- const nthElement = await frame.nth(elements, order);
767
- await assert.shouldNotHaveRole(nthElement, text);
768
- },
769
- );
770
-
771
- // Check if a selector should not have specific text
772
- Then(
773
- "User expects {string} should not match {string} text",
774
- async function (selector, text) {
775
- await assert.shouldNotHaveText(selector, text);
776
- },
777
- );
778
-
779
- Then(
780
- "User expects {int} th of {string} should not have {string} text",
781
- async function (order, elements, text) {
782
- const nthElement = await frame.nth(elements, order);
783
- await assert.shouldNotHaveText(nthElement, text);
784
- },
785
- );
786
-
787
- // Check if a selector should not have a specific value
788
- Then(
789
- "User expects {string} should not have {string} value",
790
- async function (selector, value) {
791
- await assert.shouldNotHaveValue(selector, value);
792
- },
793
- );
794
-
795
- Then(
796
- "User expects {int} th of {string} should not have {string} value",
797
- async function (order, elements, text) {
798
- const nthElement = await frame.nth(elements, order);
799
- await assert.shouldNotHaveValue(nthElement, text);
800
- },
801
- );
802
-
803
- // Check if a selector should not have specific values
804
- Then(
805
- "User expects {string} should not have {string} values",
806
- async function (selector, values) {
807
- await assert.shouldNotHaveValues(selector, values.split(","));
808
- },
809
- );
810
-
811
- // Check if the page should not have a screenshot
812
- Then("User expects the page should not have a screenshot", async function () {
813
- await assert.shouldNotPageHaveScreenshot();
814
- });
815
-
816
- // Check if the page should not have a specific title
817
- Then(
818
- "User expects the page should not have {string} title",
819
- async function (title) {
820
- await assert.shouldNotPageHaveTitle(title);
821
- },
822
- );
823
-
824
- // Check if the page should not have a specific URL
825
- Then("User expects the page url should not be {string}", async function (url) {
826
- await assert.shouldNotPageHaveURL(url);
827
- });
828
-
829
- Then("User is not on {string} page", async function (url) {
830
- await assert.shouldNotPageHaveURL(url);
831
- });
832
-
833
- // Check if a response should not be OK
834
- Then("The response should not be OK", async function (response) {
835
- await assert.shouldNotResponseBeOK(response);
836
- });
837
-
838
- // Check if a selector's value should be equal to the expected value
839
- Then(
840
- "User expects {string} should be {string} text",
841
- async function (selector, expected) {
842
- await assert.shouldBe(selector, expected);
843
- },
844
- );
845
-
846
- // Check if a selector's value should be close to the expected value within a precision
847
- Then(
848
- "User expects {string} should be close to {float} with precision {int}",
849
- async function (selector, expected, precision) {
850
- await assert.shouldBeCloseTo(selector, expected, precision);
851
- },
852
- );
853
-
854
- // Check if a selector's value should be defined
855
- Then("User expects {string} should be defined", async function (selector) {
856
- await assert.shouldBeDefined(selector);
857
- });
858
-
859
- // Check if a selector's text content should be falsy
860
- Then("User expects {string} should be falsy", async function (selector) {
861
- await assert.shouldBeFalsy(selector);
862
- });
863
-
864
- // Check if a selector's value should be greater than the expected value
865
- Then(
866
- "User expects {string} should be greater than {float}",
867
- async function (selector, expected) {
868
- await assert.shouldBeGreaterThan(selector, expected);
869
- },
870
- );
871
-
872
- // Check if a selector's value should be greater than or equal to the expected value
873
- Then(
874
- "User expects {string} should be greater than or equal to {float}",
875
- async function (selector, expected) {
876
- await assert.shouldBeGreaterThanOrEqual(selector, expected);
877
- },
878
- );
879
-
880
- // Check if a selector's value should be an instance of a specific constructor
881
- Then(
882
- "User expects {string} should be an instance of {string}",
883
- async function (selector, constructor) {
884
- await assert.shouldBeInstanceOf(selector, constructor);
885
- },
886
- );
887
-
888
- // Check if a selector's value should be less than the expected value
889
- Then(
890
- "User expects {string} should be less than {float}",
891
- async function (selector, expected) {
892
- await assert.shouldBeLessThan(selector, expected);
893
- },
894
- );
895
-
896
- // Check if a selector's value should be less than or equal to the expected value
897
- Then(
898
- "User expects {string} should be less than or equal to {float}",
899
- async function (selector, expected) {
900
- await assert.shouldBeLessThanOrEqual(selector, expected);
901
- },
902
- );
903
-
904
- // Check if a selector's value should be NaN
905
- Then("User expects {string} should be NaN", async function (selector) {
906
- await assert.shouldBeNaN(selector);
907
- });
908
-
909
- // Check if a selector's value should be null
910
- Then("User expects {string} should be null", async function (selector) {
911
- await assert.shouldBeNull(selector);
912
- });
913
-
914
- // Check if a selector's value should be truthy
915
- Then("User expects {string} should be truthy", async function (selector) {
916
- await assert.shouldBeTruthy(selector);
917
- });
918
-
919
- // Check if a selector's value should be undefined
920
- Then("User expects {string} should be undefined", async function (selector) {
921
- await assert.shouldBeUndefined(selector);
922
- });
923
-
924
- // Check if a selector's value should contain a specific substring
925
- Then(
926
- "User expects {string} should have {string} substring",
927
- async function (selector, substring) {
928
- await assert.shouldContain(selector, substring);
929
- },
930
- );
931
-
932
- // Check if a selector's value should contain an equal value
933
- Then(
934
- "User expects {string} should contain equal {string}",
935
- async function (selector, expected) {
936
- await assert.shouldContainEqual(selector, expected);
937
- },
938
- );
939
-
940
- // Check if a selector's value should equal the expected value
941
- Then(
942
- "User expects {string} should equal {int}",
943
- async function (selector, expected) {
944
- await assert.shouldEqual(selector, expected);
945
- },
946
- );
947
-
948
- // Check if a selector's text content should have a specific length
949
- Then(
950
- "User expects length of {string} should be {int}",
951
- async function (selector, length) {
952
- await assert.shouldHaveLength(selector, length);
953
- },
954
- );
955
-
956
- // Check if a selector's text content should have a specific property
957
- Then(
958
- "User expects {string} should have {string} property",
959
- async function (selector, property) {
960
- await assert.shouldHaveProperty(selector, property);
961
- },
962
- );
963
-
964
- // Check if a selector's text content should match a specific regex
965
- Then(
966
- "User expects {string} should match {string} regex",
967
- async function (selector, regex) {
968
- await assert.shouldMatch(selector, new RegExp(regex));
969
- },
970
- );
971
-
972
- // Check if a selector's text content should match a specific object
973
- Then(
974
- "User expects {string} should match {string} object",
975
- async function (selector, object) {
976
- await assert.shouldMatchObject(selector, JSON.parse(object));
977
- },
978
- );
979
-
980
- // Check if a selector's text content should strictly equal the expected value
981
- Then(
982
- "User expects {string} should strictly equal {string}",
983
- async function (selector, expected) {
984
- await assert.shouldStrictEqual(selector, expected);
985
- },
986
- );
987
-
988
- // Check if a async function should throw an error
989
- Then("The async function should throw", async function (fn) {
990
- await assert.shouldThrow(fn);
991
- });
992
-
993
- // Check if the text content of a selector should be an instance of a specific constructor
994
- Then(
995
- "User expects {string} should be any instance of {string}",
996
- async function (selector, constructor) {
997
- await assert.shouldAny(selector, constructor);
998
- },
999
- );
1000
-
1001
- // Check if the text content of a selector may be anything (truthy)
1002
- Then("User expects {string} may be anything", async function (selector) {
1003
- await assert.shouldAnything(selector);
1004
- });
1005
-
1006
- // Check if the text content of a selector should contain any of the specified elements in an array
1007
- Then(
1008
- "User expects {string} should contain {string} array elements",
1009
- async function (selector, elements) {
1010
- const parsedElements = elements.split(",");
1011
- await assert.shouldArrayContaining(selector, parsedElements);
1012
- },
1013
- );
1014
-
1015
- // Check if the text content of a selector should be close to the expected value within a precision
1016
- Then(
1017
- "User expects {string} should be close to {float} with precision {int}",
1018
- async function (selector, expected, precision) {
1019
- await assert.shouldCloseTo(selector, expected, precision);
1020
- },
1021
- );
1022
-
1023
- // Check if the text content of a selector should contain the specified properties in an object
1024
- Then(
1025
- "User expects {string} should contain {string} object properties",
1026
- async function (selector, properties) {
1027
- const parsedProperties = properties.split(",");
1028
- await assert.shouldObjectContaining(selector, parsedProperties);
1029
- },
1030
- );
1031
-
1032
- // Check if the text content of a selector should contain a specific substring
1033
- Then(
1034
- "User expects {string} should have {string} substring",
1035
- async function (selector, substring) {
1036
- await assert.shouldStringContaining(selector, substring);
1037
- },
1038
- );
1039
-
1040
- // Check if the text content of a selector should match a specific regex
1041
- Then(
1042
- "User expects {string} should match {string} regex",
1043
- async function (selector, regex) {
1044
- await assert.shouldStringMatching(selector, new RegExp(regex));
1045
- },
1046
- );
1047
-
1048
- // Check if a selector's text content should not be equal to the expected value
1049
- Then(
1050
- "User expects {string} should not be {string} text",
1051
- async function (selector, expected) {
1052
- await assert.shouldNotBe(selector, expected);
1053
- },
1054
- );
1055
-
1056
- // Check if a selector's text content should not be close to the expected value within a precision
1057
- Then(
1058
- "User expects {string} should not be close to {float} with precision {int}",
1059
- async function (selector, expected, precision) {
1060
- await assert.shouldNotBeCloseTo(selector, expected, precision);
1061
- },
1062
- );
1063
-
1064
- // Check if a selector's text content should not be defined
1065
- Then("User expects {string} should not be defined", async function (selector) {
1066
- await assert.shouldNotBeDefined(selector);
1067
- });
1068
-
1069
- // Check if a selector's text content should not be falsy
1070
- Then("User expects {string} should not be falsy", async function (selector) {
1071
- await assert.shouldNotBeFalsy(selector);
1072
- });
1073
-
1074
- // Check if a selector's text content should not be greater than the expected value
1075
- Then(
1076
- "User expects {string} should not be greater than {float}",
1077
- async function (selector, expected) {
1078
- await assert.shouldNotBeGreaterThan(selector, expected);
1079
- },
1080
- );
1081
-
1082
- // Check if a selector's text content should not be greater than or equal to the expected value
1083
- Then(
1084
- "User expects {string} should not be greater than or equal to {float}",
1085
- async function (selector, expected) {
1086
- await assert.shouldNotBeGreaterThanOrEqual(selector, expected);
1087
- },
1088
- );
1089
-
1090
- // Check if a selector's text content should not be an instance of a specific constructor
1091
- Then(
1092
- "User expects {string} should not be an instance of {string}",
1093
- async function (selector, constructor) {
1094
- await assert.shouldNotBeInstanceOf(selector, constructor);
1095
- },
1096
- );
1097
-
1098
- // Check if a selector's text content should not be less than the expected value
1099
- Then(
1100
- "User expects {string} should not be less than {float}",
1101
- async function (selector, expected) {
1102
- await assert.shouldNotBeLessThan(selector, expected);
1103
- },
1104
- );
1105
-
1106
- // Check if a selector's text content should not be less than or equal to the expected value
1107
- Then(
1108
- "User expects {string} should not be less than or equal to {float}",
1109
- async function (selector, expected) {
1110
- await assert.shouldNotBeLessThanOrEqual(selector, expected);
1111
- },
1112
- );
1113
-
1114
- // Check if a selector's text content should not be NaN
1115
- Then("User expects {string} should not be NaN", async function (selector) {
1116
- await assert.shouldNotBeNaN(selector);
1117
- });
1118
-
1119
- // Check if a selector's text content should not be null
1120
- Then("User expects {string} should not be null", async function (selector) {
1121
- await assert.shouldNotBeNull(selector);
1122
- });
1123
-
1124
- // Check if a selector's text content should not be truthy
1125
- Then("User expects {string} should not be truthy", async function (selector) {
1126
- await assert.shouldNotBeTruthy(selector);
1127
- });
1128
-
1129
- // Check if a selector's text content should not be undefined
1130
- Then(
1131
- "User expects {string} should not be undefined",
1132
- async function (selector) {
1133
- await assert.shouldNotBeUndefined(selector);
1134
- },
1135
- );
1136
-
1137
- // Check if a selector's text content should not contain a specific substring
1138
- Then(
1139
- "User expects {string} should not have {string} substring",
1140
- async function (selector, substring) {
1141
- await assert.shouldNotContain(selector, substring);
1142
- },
1143
- );
1144
-
1145
- // Check if a selector's text content should not contain an equal value
1146
- Then(
1147
- "User expects {string} should not contain equal {string}",
1148
- async function (selector, expected) {
1149
- await assert.shouldNotContainEqual(selector, expected);
1150
- },
1151
- );
1152
-
1153
- // Check if a selector's text content should not equal the expected value
1154
- Then(
1155
- "User expects {string} should not equal {string}",
1156
- async function (selector, expected) {
1157
- await assert.shouldNotEqual(selector, expected);
1158
- },
1159
- );
1160
-
1161
- // Check if a selector's text content should not have a specific length
1162
- Then(
1163
- "User expects length of {string} should not be {int} ",
1164
- async function (selector, length) {
1165
- await assert.shouldNotHaveLength(selector, length);
1166
- },
1167
- );
1168
-
1169
- // Check if a selector's text content should not have a specific property
1170
- Then(
1171
- "User expects {string} should not have {string} property",
1172
- async function (selector, property) {
1173
- await assert.shouldNotHaveProperty(selector, property);
1174
- },
1175
- );
1176
-
1177
- // Check if a selector's text content should not match a specific regex
1178
- Then(
1179
- "User expects {string} should not match {string} regex",
1180
- async function (selector, regex) {
1181
- await assert.shouldNotMatch(selector, new RegExp(regex));
1182
- },
1183
- );
1184
-
1185
- // Check if a selector's text content should not match a specific object
1186
- Then(
1187
- "User expects {string} should not match {string} object",
1188
- async function (selector, object) {
1189
- await assert.shouldNotMatchObject(selector, JSON.parse(object));
1190
- },
1191
- );
1192
-
1193
- // Check if a async function should not throw an error
1194
- Then("The async function should not throw", async function (fn) {
1195
- await assert.shouldNotThrow(fn);
1196
- });
1197
-
1198
- // Check if a selector's text content should not be any instance of a specific constructor
1199
- Then(
1200
- "User expects {string} should not be any instance of {string}",
1201
- async function (selector, constructor) {
1202
- await assert.shouldNotAny(selector, constructor);
1203
- },
1204
- );
1205
-
1206
- // Check if a selector's text content may not be anything (falsy)
1207
- Then("User expects {string} may not be anything", async function (selector) {
1208
- await assert.shouldNotAnything(selector);
1209
- });
1210
-
1211
- // Check if a selector's text content should not contain any of the specified elements in an array
1212
- Then(
1213
- "User expects {string} should not contain {string} array elements",
1214
- async function (selector, elements) {
1215
- const parsedElements = elements.split(",");
1216
- await assert.shouldNotArrayContaining(selector, parsedElements);
1217
- },
1218
- );
1219
-
1220
- // Check if a selector's text content should not be close to the expected value within a precision
1221
- Then(
1222
- "User expects {string} should not be close to {float} with precision {int}",
1223
- async function (selector, expected, precision) {
1224
- await assert.shouldNotCloseTo(selector, expected, precision);
1225
- },
1226
- );
1227
-
1228
- // Check if a selector's text content should not contain the specified properties in an object
1229
- Then(
1230
- "User expects {string} should not contain {string} object properties",
1231
- async function (selector, properties) {
1232
- const parsedProperties = JSON.parse(properties);
1233
- await assert.shouldNotObjectContaining(selector, parsedProperties);
1234
- },
1235
- );
1236
-
1237
- // Check if a selector's text content should not contain a specific substring
1238
- Then(
1239
- "User expects {string} should not contain {string} substring",
1240
- async function (selector, substring) {
1241
- await assert.shouldNotStringContaining(selector, substring);
1242
- },
1243
- );
1244
-
1245
- // Check if a selector's text content should not match a specific regex
1246
- Then(
1247
- "User expects {string} should not match {string} regex",
1248
- async function (selector, regex) {
1249
- await assert.shouldNotStringMatching(selector, new RegExp(regex));
1250
- },
1251
- );
1252
-
1253
- Then("User expects should have {int} {string}", async (count, elements) => {
1254
- const elementCount = await frame.count(elements);
1255
- expect(elementCount).toEqual(count);
1256
- });
1257
-
1258
- Then(
1259
- "User expects that response has {string} field with {string} value",
1260
- async (field, value) => {
1261
- extractVarsFromResponse(context.response["Response Body"], field);
1262
- const key = pathToCamelCase(field);
1263
- expect(String(context.vars[key])).toBe(resolveVariable(value));
1264
- },
1265
- );
1266
-
1267
- Then(
1268
- "User expects that {string} array has {int} items",
1269
- async (field, count) => {
1270
- extractVarsFromResponse(context.response["Response Body"], field);
1271
- const key = pathToCamelCase(field);
1272
- expect(context.vars[key].length).toEqual(count);
1273
- },
1274
- );
1275
-
1276
- Then(
1277
- "User expects that {string} should match {string}",
1278
- async (value1, value2) => {
1279
- await expect(resolveVariable(value1)).toBe(resolveVariable(value2));
1280
- },
1281
- );
1282
-
1283
- Then(
1284
- "User expects that response body should match {string} schema",
1285
- async function (expectedSchema) {
1286
- expectedSchema = await resolveVariable(expectedSchema);
1287
- if (expectedSchema != "") {
1288
- const schema = await selector(expectedSchema);
1289
- const ajv = await new Ajv();
1290
- const validate = await ajv.compile(schema);
1291
- const responseBody = await context.response["Response Body"];
1292
- const valid = await validate(responseBody);
1293
- await expect(valid).toBe(true);
1294
- }
1295
- },
1296
- );
1297
-
1298
- Then(
1299
- "User expects that request should have {int} status code",
1300
- async function (expectedStatusCode) {
1301
- expectedStatusCode = await resolveVariable(expectedStatusCode);
1302
- const actualStatusCode = await context.response.Response.status();
1303
- expect(actualStatusCode).toBe(expectedStatusCode);
1304
- },
1305
- );
1306
-
1307
- Then(
1308
- "User expects that response should have {int} status code",
1309
- async function (expectedStatusCode) {
1310
- expectedStatusCode = await resolveVariable(expectedStatusCode);
1311
- const actualStatusCode = await context.response.Response.status();
1312
- expect(actualStatusCode).toBe(expectedStatusCode);
1313
- },
1314
- );
1315
-
1316
-
1317
- Then("User expects that response should have {string} field", async (field) => {
1318
- extractVarsFromResponse(context.response["Response Body"], field);
1319
- const key = pathToCamelCase(field);
1320
- const varToString = JSON.stringify(context.vars[field]);
1321
- expect(varToString).toBeDefined();
1322
- });
1323
-
1324
- Then(
1325
- "User expects that response should not have {string} field",
1326
- async (field) => {
1327
- extractVarsFromResponse(context.response["Response Body"], field);
1328
- const key = pathToCamelCase(field);
1329
- const varToString = JSON.stringify(context.vars[field]);
1330
- expect(varToString).not.toBeDefined();
1331
- },
1332
- );
1333
-
1334
- Then(
1335
- "User expects that {string} array has items more than {int}",
1336
- (field, count) => {
1337
- extractVarsFromResponse(context.response["Response Body"], field);
1338
- const key = pathToCamelCase(field);
1339
- const resolvedCount = resolveVariable(count)
1340
- expect(context.vars[key].length).toBeGreaterThan(resolvedCount);
1341
- },
1342
- );
1343
-
1344
- Then(
1345
- "User expects that {string} array has items less than {int}",
1346
- (field, count) => {
1347
- extractVarsFromResponse(context.response["Response Body"], field);
1348
- const key = pathToCamelCase(field);
1349
- const resolvedCount = resolveVariable(count)
1350
- expect(context.vars[key].length).toBeLessThan(resolvedCount);
1351
- },
1
+ const {
2
+ Then,
3
+ selector,
4
+ expect,
5
+ element,
6
+ extractVarsFromResponse,
7
+ pathToCamelCase,
8
+ context,
9
+ resolveVariable,
10
+ } = require("../helper/imports/commons");
11
+ const {
12
+ screenComparer,
13
+ } = require("../helper/controller/screenComparer");
14
+ const { assert, frame } = require("../helper/stepFunctions/exporter");
15
+ const Ajv = require("ajv");
16
+
17
+
18
+ // Check if a selector should be attached
19
+ Then("User expects {string} should be attached", async function (selector) {
20
+ await assert.shouldBeAttached(selector);
21
+ });
22
+
23
+ Then(
24
+ "User expects {int} th of {string} should be attached",
25
+ async function (order, elements) {
26
+ const nthElement = await frame.nth(elements, order);
27
+ await assert.shouldBeAttached(nthElement);
28
+ },
29
+ );
30
+
31
+ // Check if a selector should be checked
32
+ Then("User expects {string} should be checked", async function (selector) {
33
+ await assert.shouldBeChecked(selector);
34
+ });
35
+
36
+ Then(
37
+ "User expects {int} th of {string} should be checked",
38
+ async function (order, elements) {
39
+ const nthElement = await frame.nth(elements, order);
40
+ await assert.shouldBeChecked(nthElement);
41
+ },
42
+ );
43
+
44
+ // Check if a selector should be disabled
45
+ Then("User expects {string} should be disabled", async function (selector) {
46
+ await assert.shouldBeDisabled(selector);
47
+ });
48
+
49
+ Then(
50
+ "User expects {int} th of {string} should be disabled",
51
+ async function (order, elements) {
52
+ const nthElement = await frame.nth(elements, order);
53
+ await assert.shouldBeDisabled(nthElement);
54
+ },
55
+ );
56
+
57
+ // Check if a selector should be editable
58
+ Then("User expects {string} should be editable", async function (selector) {
59
+ await assert.shouldBeEditable(selector);
60
+ });
61
+
62
+ Then(
63
+ "User expects {int} th of {string} should be editable",
64
+ async function (order, elements) {
65
+ const nthElement = await frame.nth(elements, order);
66
+ await assert.shouldBeEditable(nthElement);
67
+ },
68
+ );
69
+
70
+ // Check if a selector should be empty
71
+ Then("User expects {string} should be empty", async function (selector) {
72
+ await assert.shouldBeEmpty(selector);
73
+ });
74
+
75
+ Then(
76
+ "User expects {int} th of {string} should be empty",
77
+ async function (order, elements) {
78
+ const nthElement = await frame.nth(elements, order);
79
+ await assert.shouldBeEmpty(nthElement);
80
+ },
81
+ );
82
+
83
+ // Check if a selector should be enabled
84
+ Then("User expects {string} should be enabled", async function (selector) {
85
+ await assert.shouldBeEnabled(selector);
86
+ });
87
+
88
+ Then(
89
+ "User expects {int} th of {string} should be enabled",
90
+ async function (order, elements) {
91
+ const nthElement = await frame.nth(elements, order);
92
+ await assert.shouldBeEnabled(nthElement);
93
+ },
94
+ );
95
+
96
+ // Check if a selector should be focused
97
+ Then("User expects {string} should be focused", async function (selector) {
98
+ await assert.shouldBeFocused(selector);
99
+ });
100
+
101
+ Then(
102
+ "User expects {int} th of {string} should be focused",
103
+ async function (order, elements) {
104
+ const nthElement = await frame.nth(elements, order);
105
+ await assert.shouldBeFocused(nthElement);
106
+ },
107
+ );
108
+
109
+ // Check if a selector should be hidden
110
+ Then("User expects {string} should be hidden", async function (selector) {
111
+ await assert.shouldBeHidden(selector);
112
+ });
113
+
114
+ Then(
115
+ "User expects {int} th of {string} should be hidden",
116
+ async function (order, elements) {
117
+ const nthElement = await frame.nth(elements, order);
118
+ await assert.shouldBeHidden(nthElement);
119
+ },
120
+ );
121
+
122
+ // Check if a selector should be in the viewport
123
+ Then(
124
+ "User expects {string} should be on the screen",
125
+ async function (selector) {
126
+ await assert.shouldBeInViewport(selector);
127
+ },
128
+ );
129
+
130
+ Then(
131
+ "User expects {int} th of {string} should be on the screen",
132
+ async function (order, elements) {
133
+ const nthElement = await frame.nth(elements, order);
134
+ await assert.shouldBeInViewport(nthElement);
135
+ },
136
+ );
137
+
138
+ Then(
139
+ "User expects {int} th of {string} should be screen",
140
+ async function (order, elements) {
141
+ const nthElement = await frame.nth(elements, order);
142
+ await assert.shouldBeInViewport(nthElement);
143
+ },
144
+ );
145
+
146
+ // Check if a selector should be visible
147
+ Then("User expects {string} should be visible", async function (selector) {
148
+ await assert.shouldBeVisible(selector);
149
+ });
150
+
151
+ Then(
152
+ "User expects {int} th of {string} should be visible",
153
+ async function (order, elements) {
154
+ const nthElement = await frame.nth(elements, order);
155
+ await assert.shouldBeVisible(nthElement);
156
+ },
157
+ );
158
+
159
+ // Check if a selector should contain specific text
160
+ Then(
161
+ "User expects {string} should have {string} text",
162
+ async function (selector, text) {
163
+ await assert.shouldContainText(selector, text);
164
+ },
165
+ );
166
+
167
+ Then(
168
+ "User expects {int} th of {string} should have {string} text",
169
+ async function (order, elements, text) {
170
+ const nthElement = await frame.nth(elements, order);
171
+ await assert.shouldContainText(nthElement, text);
172
+ },
173
+ );
174
+
175
+ Then(
176
+ "User expects default value of {string} should have {string} text",
177
+ async (selector, text) => {
178
+ const defaultValue = await element(selector).inputValue();
179
+ await expect(defaultValue).toContain(text);
180
+ },
181
+ );
182
+
183
+ Then(
184
+ "User expects default value of {int} th of {string} should have {string} text",
185
+ async function (order, elements, text) {
186
+ const nthElement = await frame.nth(elements, order);
187
+ await assert.toContain(nthElement, text);
188
+ },
189
+ );
190
+
191
+ Then(
192
+ "User expects multiple {string} should have {string} text",
193
+ async (elements, expectedText) => {
194
+ await assert.multipleElementsShouldContainText(elements, expectedText);
195
+ },
196
+ );
197
+
198
+ // Check if a selector should have an accessible description
199
+ Then(
200
+ "User expects {string} should have {string} description",
201
+ async function (selector, description) {
202
+ await assert.shouldHaveAccessibleDescription(selector, description);
203
+ },
204
+ );
205
+
206
+ Then(
207
+ "User expects {int} th of {string} should have {string} description",
208
+ async function (order, elements, text) {
209
+ const nthElement = await frame.nth(elements, order);
210
+ await assert.shouldHaveAccessibleDescription(nthElement, text);
211
+ },
212
+ );
213
+
214
+ // Check if a selector should have an accessible name
215
+ Then(
216
+ "User expects {string} should have {string} name",
217
+ async function (selector, name) {
218
+ await assert.shouldHaveAccessibleName(selector, name);
219
+ },
220
+ );
221
+
222
+ Then(
223
+ "User expects {int} th of {string} should have {string} name",
224
+ async function (order, elements, text) {
225
+ const nthElement = await frame.nth(elements, order);
226
+ await assert.shouldHaveAccessibleName(nthElement, text);
227
+ },
228
+ );
229
+
230
+ // Check if a selector should have a specific attribute with a given value
231
+ Then(
232
+ "User expects {string} should have {string} attribute with {string} value",
233
+ async function (selector, attribute, value) {
234
+ await assert.shouldHaveAttribute(selector, attribute, value);
235
+ },
236
+ );
237
+
238
+ Then(
239
+ "User expects {int} th of {string} should have {string} attribute with {string} value",
240
+ async function (order, elements, attribute, value) {
241
+ const nthElement = await frame.nth(elements, order);
242
+ await assert.shouldHaveAttribute(nthElement, attribute, value);
243
+ },
244
+ );
245
+
246
+ // Check if a selector should have a specific class
247
+ Then(
248
+ "User expects {string} should have {string} class",
249
+ async function (selector, className) {
250
+ await assert.shouldHaveClass(selector, className);
251
+ },
252
+ );
253
+
254
+ Then(
255
+ "User expects {int} th of {string} should have {string} class",
256
+ async function (order, elements, className) {
257
+ const nthElement = await frame.nth(elements, order);
258
+ await assert.shouldHaveClass(nthElement, className);
259
+ },
260
+ );
261
+
262
+ // Check if a selector should have a specific count
263
+ Then(
264
+ "User expects count of {string} should be {int}",
265
+ async function (selector, count) {
266
+ await assert.shouldHaveCount(selector, count);
267
+ },
268
+ );
269
+
270
+ // Check if a selector should have a specific CSS property with a given value
271
+ Then(
272
+ "User expects {string} should have {string} CSS property with {string} value",
273
+ async function (selector, property, value) {
274
+ await assert.shouldHaveCSS(selector, property, value);
275
+ },
276
+ );
277
+
278
+ Then(
279
+ "User expects {int} th of {string} should have {string} CSS property with {string} value",
280
+ async function (order, elements, property, value) {
281
+ const nthElement = await frame.nth(elements, order);
282
+ await assert.shouldHaveCSS(nthElement, property, value);
283
+ },
284
+ );
285
+
286
+ // Check if a selector should have a specific id
287
+ Then(
288
+ "User expects {string} should have {string} id",
289
+ async function (selector, id) {
290
+ await assert.shouldHaveId(selector, id);
291
+ },
292
+ );
293
+
294
+ Then(
295
+ "User expects {int} th of {string} should have {string} id",
296
+ async function (order, elements, id) {
297
+ const nthElement = await frame.nth(elements, order);
298
+ await assert.shouldHaveId(nthElement, id);
299
+ },
300
+ );
301
+
302
+ // Check if a selector should have a specific JavaScript property with a given value
303
+ Then(
304
+ "User expects {string} should have {string} JavaScript property with {string} value",
305
+ async function (selector, property, value) {
306
+ await assert.shouldHaveJSProperty(selector, property, value);
307
+ },
308
+ );
309
+
310
+ Then(
311
+ "User expects {int} th of {string} should have {string} JavaScript property with {string} value",
312
+ async function (order, elements, property, value) {
313
+ const nthElement = await frame.nth(elements, order);
314
+ await assert.shouldHaveJSProperty(nthElement, property, value);
315
+ },
316
+ );
317
+
318
+ // Check if a selector should have a specific role
319
+ Then(
320
+ "User expects {string} should have {string} role",
321
+ async function (selector, role) {
322
+ await assert.shouldHaveRole(selector, role);
323
+ },
324
+ );
325
+
326
+ Then(
327
+ "User expects {int} th of {string} should have {string} role",
328
+ async function (order, elements, role) {
329
+ const nthElement = await frame.nth(elements, order);
330
+ await assert.shouldHaveId(nthElement, role);
331
+ },
332
+ );
333
+
334
+ Then(
335
+ "User expects that full page match with {string} screenshot",
336
+ async function (baselineFilename) {
337
+ await screenComparer(
338
+ baselineFilename,
339
+ (actualPath) =>
340
+ context.page.screenshot({ path: actualPath, fullPage: true }),
341
+ { maxDiffPercent: 0.01 },
342
+ );
343
+ },
344
+ );
345
+
346
+ Then(
347
+ "User expects that full page match with {string} screenshot with {float}% difference",
348
+ async function (baselineFilename, maxDiff) {
349
+ await screenComparer(
350
+ baselineFilename,
351
+ (actualPath) =>
352
+ context.page.screenshot({ path: actualPath, fullPage: true }),
353
+ { maxDiffPercent: maxDiff / 100 },
354
+ );
355
+ },
356
+ );
357
+
358
+ Then(
359
+ "User expects that page match with {string} screenshot",
360
+ async function (baselineFilename) {
361
+ await screenComparer(
362
+ baselineFilename,
363
+ (actualPath) =>
364
+ context.page.screenshot({ path: actualPath, fullPage: false }),
365
+ { maxDiffPercent: 0.01 },
366
+ );
367
+ },
368
+ );
369
+
370
+ Then(
371
+ "User expects that page match with {string} screenshot with {float}% difference",
372
+ async function (baselineFilename, maxDiff) {
373
+ await screenComparer(
374
+ baselineFilename,
375
+ (actualPath) =>
376
+ context.page.screenshot({ path: actualPath, fullPage: false }),
377
+ { maxDiffPercent: maxDiff / 100 },
378
+ );
379
+ },
380
+ );
381
+
382
+ Then(
383
+ "User expects that {string} element match with {string} screenshot",
384
+ async function (selector, baselineFilename) {
385
+ await screenComparer(
386
+ baselineFilename,
387
+ (actualPath) => element(selector).screenshot({ path: actualPath }),
388
+ { maxDiffPercent: 0.01 },
389
+ );
390
+ },
391
+ );
392
+
393
+ Then(
394
+ "User expects that {string} element match with {string} screenshot with {float}% difference",
395
+ async function (selector, baselineFilename, maxDiff) {
396
+ await screenComparer(
397
+ baselineFilename,
398
+ (actualPath) => element(selector).screenshot({ path: actualPath }),
399
+ { maxDiffPercent: maxDiff / 100 },
400
+ );
401
+ },
402
+ );
403
+
404
+
405
+ Then(
406
+ "User expects that {string} screenshot match with {string} screenshot",
407
+ async function (ss1, ss2) {
408
+ await screenComparer(
409
+ ss1,
410
+ null,
411
+ { maxDiffPercent: 0.01, comparePath: ss2 },
412
+ );
413
+ },
414
+ );
415
+
416
+ Then(
417
+ "User expects that {string} screenshot match with {string} screenshot with {float}% difference",
418
+ async function (ss1, ss2, maxDiff) {
419
+ await screenComparer(
420
+ ss1,
421
+ null,
422
+ { maxDiffPercent: maxDiff / 100, comparePath: ss2 },
423
+ );
424
+ },
425
+ );
426
+
427
+ // Check if a selector should have specific text
428
+ Then(
429
+ "User expects {string} should match {string} text",
430
+ async function (selector, text) {
431
+ await assert.shouldHaveText(selector, text);
432
+ },
433
+ );
434
+
435
+ Then(
436
+ "User expects {int} th of {string} should match {string} text",
437
+ async function (order, elements, text) {
438
+ const nthElement = await frame.nth(elements, order);
439
+ await assert.shouldHaveText(nthElement, text);
440
+ },
441
+ );
442
+
443
+ // Check if a selector should have a specific value
444
+ Then(
445
+ "User expects {string} should have {string} value",
446
+ async function (selector, value) {
447
+ await assert.shouldHaveValue(selector, value);
448
+ },
449
+ );
450
+
451
+ Then(
452
+ "User expects {int} th of {string} should have {string} value",
453
+ async function (order, elements, value) {
454
+ const nthElement = await frame.nth(elements, order);
455
+ await assert.shouldHaveValue(nthElement, value);
456
+ },
457
+ );
458
+
459
+ // Check if a selector should have specific values
460
+ Then(
461
+ "User expects {string} should have {string} values",
462
+ async function (selector, values) {
463
+ await assert.shouldHaveValues(selector, values.split(","));
464
+ },
465
+ );
466
+
467
+ // Check if the page should have a screenshot
468
+ Then("User expects the page should have a screenshot", async function () {
469
+ await assert.shouldPageHaveScreenshot();
470
+ });
471
+
472
+ // Check if the page should have a specific title
473
+ Then(
474
+ "User expects the page should have {string} title",
475
+ async function (title) {
476
+ await assert.shouldPageHaveTitle(title);
477
+ },
478
+ );
479
+
480
+ // Check if the page should have a specific URL
481
+ Then("User expects to be in {string} page", async function (url) {
482
+ const URL = await selector(url);
483
+ await assert.shouldPageHaveURL(URL);
484
+ });
485
+
486
+ // Check if a selector should not be attached
487
+ Then("User expects {string} should not be attached", async function (selector) {
488
+ await assert.shouldNotBeAttached(selector);
489
+ });
490
+
491
+ Then(
492
+ "User expects {int} th of {string} should be not be attached",
493
+ async function (order, elements) {
494
+ const nthElement = await frame.nth(elements, order);
495
+ await assert.shouldNotBeAttached(nthElement);
496
+ },
497
+ );
498
+
499
+ // Check if a selector should not be checked
500
+ Then("User expects {string} should not be checked", async function (selector) {
501
+ await assert.shouldNotBeChecked(selector);
502
+ });
503
+
504
+ Then(
505
+ "User expects {int} th of {string} should be not be checked",
506
+ async function (order, elements) {
507
+ const nthElement = await frame.nth(elements, order);
508
+ await assert.shouldNotBeChecked(nthElement);
509
+ },
510
+ );
511
+
512
+ // Check if a selector should not be disabled
513
+ Then("User expects {string} should not be disabled", async function (selector) {
514
+ await assert.shouldNotBeDisabled(selector);
515
+ });
516
+
517
+ Then(
518
+ "User expects {int} th of {string} should be not be disabled",
519
+ async function (order, elements) {
520
+ const nthElement = await frame.nth(elements, order);
521
+ await assert.shouldNotBeDisabled(nthElement);
522
+ },
523
+ );
524
+
525
+ // Check if a selector should not be editable
526
+ Then("User expects {string} should not be editable", async function (selector) {
527
+ await assert.shouldNotBeEditable(selector);
528
+ });
529
+
530
+ Then(
531
+ "User expects {int} th of {string} should be not be editable",
532
+ async function (order, elements) {
533
+ const nthElement = await frame.nth(elements, order);
534
+ await assert.shouldNotBeEditable(nthElement);
535
+ },
536
+ );
537
+
538
+ // Check if a selector should not be empty
539
+ Then("User expects {string} should not be empty", async function (selector) {
540
+ await assert.shouldNotBeEmpty(selector);
541
+ });
542
+
543
+ Then(
544
+ "User expects {int} th of {string} should be not be empty",
545
+ async function (order, elements) {
546
+ const nthElement = await frame.nth(elements, order);
547
+ await assert.shouldNotBeEmpty(nthElement);
548
+ },
549
+ );
550
+
551
+ // Check if a selector should not be enabled
552
+ Then("User expects {string} should not be enabled", async function (selector) {
553
+ await assert.shouldNotBeEnabled(selector);
554
+ });
555
+
556
+ Then(
557
+ "User expects {int} th of {string} should be not be enabled",
558
+ async function (order, elements) {
559
+ const nthElement = await frame.nth(elements, order);
560
+ await assert.shouldNotBeEnabled(nthElement);
561
+ },
562
+ );
563
+
564
+ // Check if a selector should not be focused
565
+ Then("User expects {string} should not be focused", async function (selector) {
566
+ await assert.shouldNotBeFocused(selector);
567
+ });
568
+
569
+ Then(
570
+ "User expects {int} th of {string} should be not be focused",
571
+ async function (order, elements) {
572
+ const nthElement = await frame.nth(elements, order);
573
+ await assert.shouldNotBeFocused(nthElement);
574
+ },
575
+ );
576
+
577
+ // Check if a selector should not be hidden
578
+ Then("User expects {string} should not be hidden", async function (selector) {
579
+ await assert.shouldNotBeHidden(selector);
580
+ });
581
+
582
+ Then(
583
+ "User expects {int} th of {string} should be not be hidden",
584
+ async function (order, elements) {
585
+ const nthElement = await frame.nth(elements, order);
586
+ await assert.shouldNotBeHidden(nthElement);
587
+ },
588
+ );
589
+
590
+ // Check if a selector should not be in the viewport
591
+ Then(
592
+ "User expects {string} should not be on the screen",
593
+ async function (selector) {
594
+ await assert.shouldNotBeInViewport(selector);
595
+ },
596
+ );
597
+
598
+ Then(
599
+ "User expects {int} th of {string} should not be on the screen",
600
+ async function (order, elements) {
601
+ const nthElement = await frame.nth(elements, order);
602
+ await assert.shouldNotBeInViewport(nthElement);
603
+ },
604
+ );
605
+
606
+ // Check if a selector should not be visible
607
+ Then("User expects {string} should not be visible", async function (selector) {
608
+ await assert.shouldNotBeVisible(selector);
609
+ });
610
+
611
+ Then(
612
+ "User expects {int} th of {string} should not be visible",
613
+ async function (order, elements) {
614
+ const nthElement = await frame.nth(elements, order);
615
+ await assert.shouldNotBeVisible(nthElement);
616
+ },
617
+ );
618
+
619
+ // Check if a selector should not contain specific text
620
+ Then(
621
+ "User expects {string} should not have {string} text",
622
+ async function (selector, text) {
623
+ await assert.shouldNotContainText(selector, text);
624
+ },
625
+ );
626
+
627
+ Then(
628
+ "User expects {int} th of {string} should not have {string} text",
629
+ async function (order, elements, text) {
630
+ const nthElement = await frame.nth(elements, order);
631
+ await assert.shouldNotContainText(nthElement, text);
632
+ },
633
+ );
634
+
635
+ // Check if a selector should not have an accessible description
636
+ Then(
637
+ "User expects {string} should not have {string} description",
638
+ async function (selector, description) {
639
+ await assert.shouldNotHaveAccessibleDescription(selector, description);
640
+ },
641
+ );
642
+
643
+ Then(
644
+ "User expects {int} th of {string} should not have {string} description",
645
+ async function (order, elements, text) {
646
+ const nthElement = await frame.nth(elements, order);
647
+ await assert.shouldNotHaveAccessibleDescription(nthElement, text);
648
+ },
649
+ );
650
+
651
+ // Check if a selector should not have an accessible name
652
+ Then(
653
+ "User expects {string} should not have {string} name",
654
+ async function (selector, name) {
655
+ await assert.shouldNotHaveAccessibleName(selector, name);
656
+ },
657
+ );
658
+
659
+ Then(
660
+ "User expects {int} th of {string} should not have {string} name",
661
+ async function (order, elements, text) {
662
+ const nthElement = await frame.nth(elements, order);
663
+ await assert.shouldNotHaveAccessibleName(nthElement, text);
664
+ },
665
+ );
666
+
667
+ // Check if a selector should not have a specific attribute with a given value
668
+ Then(
669
+ "User expects {string} should not have {string} attribute with {string} value",
670
+ async function (selector, attribute, value) {
671
+ await assert.shouldNotHaveAttribute(selector, attribute, value);
672
+ },
673
+ );
674
+
675
+ Then(
676
+ "User expects {int} th of {string} should have {string} attribute with {string} value",
677
+ async function (order, elements, attribute, value) {
678
+ const nthElement = await frame.nth(elements, order);
679
+ await assert.shouldNotHaveAttribute(nthElement, attribute, value);
680
+ },
681
+ );
682
+
683
+ // Check if a selector should not have a specific class
684
+ Then(
685
+ "User expects {string} should not have {string} class",
686
+ async function (selector, className) {
687
+ await assert.shouldNotHaveClass(selector, className);
688
+ },
689
+ );
690
+
691
+ Then(
692
+ "User expects {int} th of {string} should not have {string} class",
693
+ async function (order, elements, text) {
694
+ const nthElement = await frame.nth(elements, order);
695
+ await assert.shouldNotHaveClass(nthElement, text);
696
+ },
697
+ );
698
+
699
+ // Check if a selector should not have a specific count
700
+ Then(
701
+ "User expects count of {string} should not be {int}",
702
+ async function (selector, count) {
703
+ await assert.shouldNotHaveCount(selector, count);
704
+ },
705
+ );
706
+
707
+ // Check if a selector should not have a specific CSS property with a given value
708
+ Then(
709
+ "User expects {string} should not have {string} CSS property with {string} value",
710
+ async function (selector, property, value) {
711
+ await assert.shouldNotHaveCSS(selector, property, value);
712
+ },
713
+ );
714
+
715
+ Then(
716
+ "User expects {int} th of {string} should not have {string} CSS property with {string} value",
717
+ async function (order, elements, property, value) {
718
+ const nthElement = await frame.nth(elements, order);
719
+ await assert.shouldNotHaveCSS(nthElement, property, value);
720
+ },
721
+ );
722
+
723
+ // Check if a selector should not have a specific ID
724
+ Then(
725
+ "User expects {string} should not have {string} id",
726
+ async function (selector, id) {
727
+ await assert.shouldNotHaveId(selector, id);
728
+ },
729
+ );
730
+
731
+ Then(
732
+ "User expects {int} th of {string} should not have {string} id",
733
+ async function (order, elements, text) {
734
+ const nthElement = await frame.nth(elements, order);
735
+ await assert.shouldNotHaveId(nthElement, text);
736
+ },
737
+ );
738
+
739
+ // Check if a selector should not have a specific JavaScript property with a given value
740
+ Then(
741
+ "User expects {string} should not have {string} JavaScript property with {string} value",
742
+ async function (selector, property, value) {
743
+ await assert.shouldNotHaveJSProperty(selector, property, value);
744
+ },
745
+ );
746
+
747
+ Then(
748
+ "User expects {int} th of {string} should not have {string} JavaScript property with {string} value",
749
+ async function (order, elements, property, value) {
750
+ const nthElement = await frame.nth(elements, order);
751
+ await assert.shouldNotHaveJSProperty(nthElement, property, value);
752
+ },
753
+ );
754
+
755
+ // Check if a selector should not have a specific role
756
+ Then(
757
+ "User expects {string} should not have {string} role",
758
+ async function (selector, role) {
759
+ await assert.shouldNotHaveRole(selector, role);
760
+ },
761
+ );
762
+
763
+ Then(
764
+ "User expects {int} th of {string} should not have {string} role",
765
+ async function (order, elements, text) {
766
+ const nthElement = await frame.nth(elements, order);
767
+ await assert.shouldNotHaveRole(nthElement, text);
768
+ },
769
+ );
770
+
771
+ // Check if a selector should not have specific text
772
+ Then(
773
+ "User expects {string} should not match {string} text",
774
+ async function (selector, text) {
775
+ await assert.shouldNotHaveText(selector, text);
776
+ },
777
+ );
778
+
779
+ Then(
780
+ "User expects {int} th of {string} should not have {string} text",
781
+ async function (order, elements, text) {
782
+ const nthElement = await frame.nth(elements, order);
783
+ await assert.shouldNotHaveText(nthElement, text);
784
+ },
785
+ );
786
+
787
+ // Check if a selector should not have a specific value
788
+ Then(
789
+ "User expects {string} should not have {string} value",
790
+ async function (selector, value) {
791
+ await assert.shouldNotHaveValue(selector, value);
792
+ },
793
+ );
794
+
795
+ Then(
796
+ "User expects {int} th of {string} should not have {string} value",
797
+ async function (order, elements, text) {
798
+ const nthElement = await frame.nth(elements, order);
799
+ await assert.shouldNotHaveValue(nthElement, text);
800
+ },
801
+ );
802
+
803
+ // Check if a selector should not have specific values
804
+ Then(
805
+ "User expects {string} should not have {string} values",
806
+ async function (selector, values) {
807
+ await assert.shouldNotHaveValues(selector, values.split(","));
808
+ },
809
+ );
810
+
811
+ // Check if the page should not have a screenshot
812
+ Then("User expects the page should not have a screenshot", async function () {
813
+ await assert.shouldNotPageHaveScreenshot();
814
+ });
815
+
816
+ // Check if the page should not have a specific title
817
+ Then(
818
+ "User expects the page should not have {string} title",
819
+ async function (title) {
820
+ await assert.shouldNotPageHaveTitle(title);
821
+ },
822
+ );
823
+
824
+ // Check if the page should not have a specific URL
825
+ Then("User expects the page url should not be {string}", async function (url) {
826
+ await assert.shouldNotPageHaveURL(url);
827
+ });
828
+
829
+ Then("User is not on {string} page", async function (url) {
830
+ await assert.shouldNotPageHaveURL(url);
831
+ });
832
+
833
+ // Check if a response should not be OK
834
+ Then("The response should not be OK", async function (response) {
835
+ await assert.shouldNotResponseBeOK(response);
836
+ });
837
+
838
+ // Check if a selector's value should be equal to the expected value
839
+ Then(
840
+ "User expects {string} should be {string} text",
841
+ async function (selector, expected) {
842
+ await assert.shouldBe(selector, expected);
843
+ },
844
+ );
845
+
846
+ // Check if a selector's value should be close to the expected value within a precision
847
+ Then(
848
+ "User expects {string} should be close to {float} with precision {int}",
849
+ async function (selector, expected, precision) {
850
+ await assert.shouldBeCloseTo(selector, expected, precision);
851
+ },
852
+ );
853
+
854
+ // Check if a selector's value should be defined
855
+ Then("User expects {string} should be defined", async function (selector) {
856
+ await assert.shouldBeDefined(selector);
857
+ });
858
+
859
+ // Check if a selector's text content should be falsy
860
+ Then("User expects {string} should be falsy", async function (selector) {
861
+ await assert.shouldBeFalsy(selector);
862
+ });
863
+
864
+ // Check if a selector's value should be greater than the expected value
865
+ Then(
866
+ "User expects {string} should be greater than {float}",
867
+ async function (selector, expected) {
868
+ await assert.shouldBeGreaterThan(selector, expected);
869
+ },
870
+ );
871
+
872
+ // Check if a selector's value should be greater than or equal to the expected value
873
+ Then(
874
+ "User expects {string} should be greater than or equal to {float}",
875
+ async function (selector, expected) {
876
+ await assert.shouldBeGreaterThanOrEqual(selector, expected);
877
+ },
878
+ );
879
+
880
+ // Check if a selector's value should be an instance of a specific constructor
881
+ Then(
882
+ "User expects {string} should be an instance of {string}",
883
+ async function (selector, constructor) {
884
+ await assert.shouldBeInstanceOf(selector, constructor);
885
+ },
886
+ );
887
+
888
+ // Check if a selector's value should be less than the expected value
889
+ Then(
890
+ "User expects {string} should be less than {float}",
891
+ async function (selector, expected) {
892
+ await assert.shouldBeLessThan(selector, expected);
893
+ },
894
+ );
895
+
896
+ // Check if a selector's value should be less than or equal to the expected value
897
+ Then(
898
+ "User expects {string} should be less than or equal to {float}",
899
+ async function (selector, expected) {
900
+ await assert.shouldBeLessThanOrEqual(selector, expected);
901
+ },
902
+ );
903
+
904
+ // Check if a selector's value should be NaN
905
+ Then("User expects {string} should be NaN", async function (selector) {
906
+ await assert.shouldBeNaN(selector);
907
+ });
908
+
909
+ // Check if a selector's value should be null
910
+ Then("User expects {string} should be null", async function (selector) {
911
+ await assert.shouldBeNull(selector);
912
+ });
913
+
914
+ // Check if a selector's value should be truthy
915
+ Then("User expects {string} should be truthy", async function (selector) {
916
+ await assert.shouldBeTruthy(selector);
917
+ });
918
+
919
+ // Check if a selector's value should be undefined
920
+ Then("User expects {string} should be undefined", async function (selector) {
921
+ await assert.shouldBeUndefined(selector);
922
+ });
923
+
924
+ // Check if a selector's value should contain a specific substring
925
+ Then(
926
+ "User expects {string} should have {string} substring",
927
+ async function (selector, substring) {
928
+ await assert.shouldContain(selector, substring);
929
+ },
930
+ );
931
+
932
+ // Check if a selector's value should contain an equal value
933
+ Then(
934
+ "User expects {string} should contain equal {string}",
935
+ async function (selector, expected) {
936
+ await assert.shouldContainEqual(selector, expected);
937
+ },
938
+ );
939
+
940
+ // Check if a selector's value should equal the expected value
941
+ Then(
942
+ "User expects {string} should equal {int}",
943
+ async function (selector, expected) {
944
+ await assert.shouldEqual(selector, expected);
945
+ },
946
+ );
947
+
948
+ // Check if a selector's text content should have a specific length
949
+ Then(
950
+ "User expects length of {string} should be {int}",
951
+ async function (selector, length) {
952
+ await assert.shouldHaveLength(selector, length);
953
+ },
954
+ );
955
+
956
+ // Check if a selector's text content should have a specific property
957
+ Then(
958
+ "User expects {string} should have {string} property",
959
+ async function (selector, property) {
960
+ await assert.shouldHaveProperty(selector, property);
961
+ },
962
+ );
963
+
964
+ // Check if a selector's text content should match a specific regex
965
+ Then(
966
+ "User expects {string} should match {string} regex",
967
+ async function (selector, regex) {
968
+ await assert.shouldMatch(selector, new RegExp(regex));
969
+ },
970
+ );
971
+
972
+ // Check if a selector's text content should match a specific object
973
+ Then(
974
+ "User expects {string} should match {string} object",
975
+ async function (selector, object) {
976
+ await assert.shouldMatchObject(selector, JSON.parse(object));
977
+ },
978
+ );
979
+
980
+ // Check if a selector's text content should strictly equal the expected value
981
+ Then(
982
+ "User expects {string} should strictly equal {string}",
983
+ async function (selector, expected) {
984
+ await assert.shouldStrictEqual(selector, expected);
985
+ },
986
+ );
987
+
988
+ // Check if a async function should throw an error
989
+ Then("The async function should throw", async function (fn) {
990
+ await assert.shouldThrow(fn);
991
+ });
992
+
993
+ // Check if the text content of a selector should be an instance of a specific constructor
994
+ Then(
995
+ "User expects {string} should be any instance of {string}",
996
+ async function (selector, constructor) {
997
+ await assert.shouldAny(selector, constructor);
998
+ },
999
+ );
1000
+
1001
+ // Check if the text content of a selector may be anything (truthy)
1002
+ Then("User expects {string} may be anything", async function (selector) {
1003
+ await assert.shouldAnything(selector);
1004
+ });
1005
+
1006
+ // Check if the text content of a selector should contain any of the specified elements in an array
1007
+ Then(
1008
+ "User expects {string} should contain {string} array elements",
1009
+ async function (selector, elements) {
1010
+ const parsedElements = elements.split(",");
1011
+ await assert.shouldArrayContaining(selector, parsedElements);
1012
+ },
1013
+ );
1014
+
1015
+ // Check if the text content of a selector should be close to the expected value within a precision
1016
+ Then(
1017
+ "User expects {string} should be close to {float} with precision {int}",
1018
+ async function (selector, expected, precision) {
1019
+ await assert.shouldCloseTo(selector, expected, precision);
1020
+ },
1021
+ );
1022
+
1023
+ // Check if the text content of a selector should contain the specified properties in an object
1024
+ Then(
1025
+ "User expects {string} should contain {string} object properties",
1026
+ async function (selector, properties) {
1027
+ const parsedProperties = properties.split(",");
1028
+ await assert.shouldObjectContaining(selector, parsedProperties);
1029
+ },
1030
+ );
1031
+
1032
+ // Check if the text content of a selector should contain a specific substring
1033
+ Then(
1034
+ "User expects {string} should have {string} substring",
1035
+ async function (selector, substring) {
1036
+ await assert.shouldStringContaining(selector, substring);
1037
+ },
1038
+ );
1039
+
1040
+ // Check if the text content of a selector should match a specific regex
1041
+ Then(
1042
+ "User expects {string} should match {string} regex",
1043
+ async function (selector, regex) {
1044
+ await assert.shouldStringMatching(selector, new RegExp(regex));
1045
+ },
1046
+ );
1047
+
1048
+ // Check if a selector's text content should not be equal to the expected value
1049
+ Then(
1050
+ "User expects {string} should not be {string} text",
1051
+ async function (selector, expected) {
1052
+ await assert.shouldNotBe(selector, expected);
1053
+ },
1054
+ );
1055
+
1056
+ // Check if a selector's text content should not be close to the expected value within a precision
1057
+ Then(
1058
+ "User expects {string} should not be close to {float} with precision {int}",
1059
+ async function (selector, expected, precision) {
1060
+ await assert.shouldNotBeCloseTo(selector, expected, precision);
1061
+ },
1062
+ );
1063
+
1064
+ // Check if a selector's text content should not be defined
1065
+ Then("User expects {string} should not be defined", async function (selector) {
1066
+ await assert.shouldNotBeDefined(selector);
1067
+ });
1068
+
1069
+ // Check if a selector's text content should not be falsy
1070
+ Then("User expects {string} should not be falsy", async function (selector) {
1071
+ await assert.shouldNotBeFalsy(selector);
1072
+ });
1073
+
1074
+ // Check if a selector's text content should not be greater than the expected value
1075
+ Then(
1076
+ "User expects {string} should not be greater than {float}",
1077
+ async function (selector, expected) {
1078
+ await assert.shouldNotBeGreaterThan(selector, expected);
1079
+ },
1080
+ );
1081
+
1082
+ // Check if a selector's text content should not be greater than or equal to the expected value
1083
+ Then(
1084
+ "User expects {string} should not be greater than or equal to {float}",
1085
+ async function (selector, expected) {
1086
+ await assert.shouldNotBeGreaterThanOrEqual(selector, expected);
1087
+ },
1088
+ );
1089
+
1090
+ // Check if a selector's text content should not be an instance of a specific constructor
1091
+ Then(
1092
+ "User expects {string} should not be an instance of {string}",
1093
+ async function (selector, constructor) {
1094
+ await assert.shouldNotBeInstanceOf(selector, constructor);
1095
+ },
1096
+ );
1097
+
1098
+ // Check if a selector's text content should not be less than the expected value
1099
+ Then(
1100
+ "User expects {string} should not be less than {float}",
1101
+ async function (selector, expected) {
1102
+ await assert.shouldNotBeLessThan(selector, expected);
1103
+ },
1104
+ );
1105
+
1106
+ // Check if a selector's text content should not be less than or equal to the expected value
1107
+ Then(
1108
+ "User expects {string} should not be less than or equal to {float}",
1109
+ async function (selector, expected) {
1110
+ await assert.shouldNotBeLessThanOrEqual(selector, expected);
1111
+ },
1112
+ );
1113
+
1114
+ // Check if a selector's text content should not be NaN
1115
+ Then("User expects {string} should not be NaN", async function (selector) {
1116
+ await assert.shouldNotBeNaN(selector);
1117
+ });
1118
+
1119
+ // Check if a selector's text content should not be null
1120
+ Then("User expects {string} should not be null", async function (selector) {
1121
+ await assert.shouldNotBeNull(selector);
1122
+ });
1123
+
1124
+ // Check if a selector's text content should not be truthy
1125
+ Then("User expects {string} should not be truthy", async function (selector) {
1126
+ await assert.shouldNotBeTruthy(selector);
1127
+ });
1128
+
1129
+ // Check if a selector's text content should not be undefined
1130
+ Then(
1131
+ "User expects {string} should not be undefined",
1132
+ async function (selector) {
1133
+ await assert.shouldNotBeUndefined(selector);
1134
+ },
1135
+ );
1136
+
1137
+ // Check if a selector's text content should not contain a specific substring
1138
+ Then(
1139
+ "User expects {string} should not have {string} substring",
1140
+ async function (selector, substring) {
1141
+ await assert.shouldNotContain(selector, substring);
1142
+ },
1143
+ );
1144
+
1145
+ // Check if a selector's text content should not contain an equal value
1146
+ Then(
1147
+ "User expects {string} should not contain equal {string}",
1148
+ async function (selector, expected) {
1149
+ await assert.shouldNotContainEqual(selector, expected);
1150
+ },
1151
+ );
1152
+
1153
+ // Check if a selector's text content should not equal the expected value
1154
+ Then(
1155
+ "User expects {string} should not equal {string}",
1156
+ async function (selector, expected) {
1157
+ await assert.shouldNotEqual(selector, expected);
1158
+ },
1159
+ );
1160
+
1161
+ // Check if a selector's text content should not have a specific length
1162
+ Then(
1163
+ "User expects length of {string} should not be {int} ",
1164
+ async function (selector, length) {
1165
+ await assert.shouldNotHaveLength(selector, length);
1166
+ },
1167
+ );
1168
+
1169
+ // Check if a selector's text content should not have a specific property
1170
+ Then(
1171
+ "User expects {string} should not have {string} property",
1172
+ async function (selector, property) {
1173
+ await assert.shouldNotHaveProperty(selector, property);
1174
+ },
1175
+ );
1176
+
1177
+ // Check if a selector's text content should not match a specific regex
1178
+ Then(
1179
+ "User expects {string} should not match {string} regex",
1180
+ async function (selector, regex) {
1181
+ await assert.shouldNotMatch(selector, new RegExp(regex));
1182
+ },
1183
+ );
1184
+
1185
+ // Check if a selector's text content should not match a specific object
1186
+ Then(
1187
+ "User expects {string} should not match {string} object",
1188
+ async function (selector, object) {
1189
+ await assert.shouldNotMatchObject(selector, JSON.parse(object));
1190
+ },
1191
+ );
1192
+
1193
+ // Check if a async function should not throw an error
1194
+ Then("The async function should not throw", async function (fn) {
1195
+ await assert.shouldNotThrow(fn);
1196
+ });
1197
+
1198
+ // Check if a selector's text content should not be any instance of a specific constructor
1199
+ Then(
1200
+ "User expects {string} should not be any instance of {string}",
1201
+ async function (selector, constructor) {
1202
+ await assert.shouldNotAny(selector, constructor);
1203
+ },
1204
+ );
1205
+
1206
+ // Check if a selector's text content may not be anything (falsy)
1207
+ Then("User expects {string} may not be anything", async function (selector) {
1208
+ await assert.shouldNotAnything(selector);
1209
+ });
1210
+
1211
+ // Check if a selector's text content should not contain any of the specified elements in an array
1212
+ Then(
1213
+ "User expects {string} should not contain {string} array elements",
1214
+ async function (selector, elements) {
1215
+ const parsedElements = elements.split(",");
1216
+ await assert.shouldNotArrayContaining(selector, parsedElements);
1217
+ },
1218
+ );
1219
+
1220
+ // Check if a selector's text content should not be close to the expected value within a precision
1221
+ Then(
1222
+ "User expects {string} should not be close to {float} with precision {int}",
1223
+ async function (selector, expected, precision) {
1224
+ await assert.shouldNotCloseTo(selector, expected, precision);
1225
+ },
1226
+ );
1227
+
1228
+ // Check if a selector's text content should not contain the specified properties in an object
1229
+ Then(
1230
+ "User expects {string} should not contain {string} object properties",
1231
+ async function (selector, properties) {
1232
+ const parsedProperties = JSON.parse(properties);
1233
+ await assert.shouldNotObjectContaining(selector, parsedProperties);
1234
+ },
1235
+ );
1236
+
1237
+ // Check if a selector's text content should not contain a specific substring
1238
+ Then(
1239
+ "User expects {string} should not contain {string} substring",
1240
+ async function (selector, substring) {
1241
+ await assert.shouldNotStringContaining(selector, substring);
1242
+ },
1243
+ );
1244
+
1245
+ // Check if a selector's text content should not match a specific regex
1246
+ Then(
1247
+ "User expects {string} should not match {string} regex",
1248
+ async function (selector, regex) {
1249
+ await assert.shouldNotStringMatching(selector, new RegExp(regex));
1250
+ },
1251
+ );
1252
+
1253
+ Then("User expects should have {int} {string}", async (count, elements) => {
1254
+ const elementCount = await frame.count(elements);
1255
+ expect(elementCount).toEqual(count);
1256
+ });
1257
+
1258
+ Then(
1259
+ "User expects that response has {string} field with {string} value",
1260
+ async (field, value) => {
1261
+ extractVarsFromResponse(context.response["Response Body"], field);
1262
+ const key = pathToCamelCase(field);
1263
+ expect(String(context.vars[key])).toBe(resolveVariable(value));
1264
+ },
1265
+ );
1266
+
1267
+ Then(
1268
+ "User expects that response does not have {string} field with {string} value",
1269
+ async (field, value) => {
1270
+ extractVarsFromResponse(context.response["Response Body"], field);
1271
+ const key = pathToCamelCase(field);
1272
+ expect(String(context.vars[key])).not.toBe(resolveVariable(value));
1273
+ },
1274
+ );
1275
+
1276
+ Then(
1277
+ "User expects that {string} array has {int} items",
1278
+ async (field, count) => {
1279
+ extractVarsFromResponse(context.response["Response Body"], field);
1280
+ const key = pathToCamelCase(field);
1281
+ expect(context.vars[key].length).toEqual(count);
1282
+ },
1283
+ );
1284
+
1285
+ Then(
1286
+ "User expects that {string} should match {string}",
1287
+ async (value1, value2) => {
1288
+ await expect(resolveVariable(value1)).toBe(resolveVariable(value2));
1289
+ },
1290
+ );
1291
+
1292
+ Then(
1293
+ "User expects that response body should match {string} schema",
1294
+ async function (expectedSchema) {
1295
+ expectedSchema = await resolveVariable(expectedSchema);
1296
+ if (expectedSchema != "") {
1297
+ const schema = await selector(expectedSchema);
1298
+ const ajv = await new Ajv();
1299
+ const validate = await ajv.compile(schema);
1300
+ const responseBody = await context.response["Response Body"];
1301
+ const valid = await validate(responseBody);
1302
+ await expect(valid).toBe(true);
1303
+ }
1304
+ },
1305
+ );
1306
+
1307
+ Then(
1308
+ "User expects that request should have {int} status code",
1309
+ async function (expectedStatusCode) {
1310
+ expectedStatusCode = await resolveVariable(expectedStatusCode);
1311
+ const actualStatusCode = await context.response.Response.status();
1312
+ expect(actualStatusCode).toBe(expectedStatusCode);
1313
+ },
1314
+ );
1315
+
1316
+ Then(
1317
+ "User expects that response should have {int} status code",
1318
+ async function (expectedStatusCode) {
1319
+ expectedStatusCode = await resolveVariable(expectedStatusCode);
1320
+ const actualStatusCode = await context.response.Response.status();
1321
+ expect(actualStatusCode).toBe(expectedStatusCode);
1322
+ },
1323
+ );
1324
+
1325
+
1326
+ Then("User expects that response should have {string} field", async (field) => {
1327
+ extractVarsFromResponse(context.response["Response Body"], field);
1328
+ const key = pathToCamelCase(field);
1329
+ expect(context.vars[key]).toBeDefined();
1330
+ });
1331
+
1332
+ Then(
1333
+ "User expects that response should not have {string} field",
1334
+ async (field) => {
1335
+ extractVarsFromResponse(context.response["Response Body"], field);
1336
+ const key = pathToCamelCase(field);
1337
+ expect(context.vars[key]).toBeUndefined();
1338
+ },
1339
+ );
1340
+
1341
+ Then(
1342
+ "User expects that {string} array has items more than {int}",
1343
+ (field, count) => {
1344
+ extractVarsFromResponse(context.response["Response Body"], field);
1345
+ const key = pathToCamelCase(field);
1346
+ const resolvedCount = resolveVariable(count)
1347
+ expect(context.vars[key].length).toBeGreaterThan(resolvedCount);
1348
+ },
1349
+ );
1350
+
1351
+ Then(
1352
+ "User expects that {string} array has items less than {int}",
1353
+ (field, count) => {
1354
+ extractVarsFromResponse(context.response["Response Body"], field);
1355
+ const key = pathToCamelCase(field);
1356
+ const resolvedCount = resolveVariable(count)
1357
+ expect(context.vars[key].length).toBeLessThan(resolvedCount);
1358
+ },
1352
1359
  );