codeceptjs 3.5.9 → 3.5.11

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 (52) hide show
  1. package/README.md +14 -16
  2. package/docs/build/Appium.js +49 -49
  3. package/docs/build/Expect.js +33 -33
  4. package/docs/build/Nightmare.js +50 -50
  5. package/docs/build/Playwright.js +239 -133
  6. package/docs/build/Protractor.js +59 -59
  7. package/docs/build/Puppeteer.js +127 -107
  8. package/docs/build/TestCafe.js +48 -48
  9. package/docs/build/WebDriver.js +112 -93
  10. package/docs/helpers/Appium.md +3 -3
  11. package/docs/helpers/Expect.md +33 -33
  12. package/docs/helpers/Playwright.md +431 -325
  13. package/docs/helpers/Puppeteer.md +50 -24
  14. package/docs/helpers/WebDriver.md +41 -13
  15. package/docs/internal-api.md +1 -0
  16. package/docs/parallel.md +114 -2
  17. package/docs/plugins.md +7 -5
  18. package/docs/react.md +2 -1
  19. package/docs/vue.md +22 -0
  20. package/docs/webapi/grabWebElement.mustache +9 -0
  21. package/docs/webapi/grabWebElements.mustache +9 -0
  22. package/docs/webapi/scrollIntoView.mustache +1 -1
  23. package/lib/ai.js +12 -3
  24. package/lib/colorUtils.js +10 -0
  25. package/lib/command/run-multiple.js +1 -1
  26. package/lib/command/run-workers.js +30 -4
  27. package/lib/command/workers/runTests.js +39 -0
  28. package/lib/event.js +2 -0
  29. package/lib/helper/Appium.js +13 -13
  30. package/lib/helper/Expect.js +33 -33
  31. package/lib/helper/Playwright.js +125 -37
  32. package/lib/helper/Puppeteer.js +49 -38
  33. package/lib/helper/WebDriver.js +29 -19
  34. package/lib/helper/extras/PlaywrightReactVueLocator.js +38 -0
  35. package/lib/html.js +3 -3
  36. package/lib/interfaces/gherkin.js +8 -1
  37. package/lib/interfaces/scenarioConfig.js +1 -0
  38. package/lib/locator.js +2 -2
  39. package/lib/pause.js +6 -3
  40. package/lib/plugin/autoLogin.js +4 -2
  41. package/lib/plugin/heal.js +40 -7
  42. package/lib/plugin/retryFailedStep.js +6 -1
  43. package/lib/plugin/stepByStepReport.js +2 -2
  44. package/lib/plugin/tryTo.js +5 -4
  45. package/lib/recorder.js +12 -5
  46. package/lib/ui.js +1 -0
  47. package/lib/workers.js +2 -0
  48. package/package.json +28 -25
  49. package/typings/index.d.ts +1 -1
  50. package/typings/promiseBasedTypes.d.ts +195 -76
  51. package/typings/types.d.ts +191 -145
  52. package/lib/helper/extras/PlaywrightReact.js +0 -9
@@ -44,7 +44,7 @@ Type: [object][4]
44
44
  - `disableScreenshots` **[boolean][20]?** don't save screenshot on failure.
45
45
  - `fullPageScreenshots` **[boolean][20]?** make full page screenshots on failure.
46
46
  - `uniqueScreenshotNames` **[boolean][20]?** option to prevent screenshot override if you have scenarios with the same name in different suites.
47
- - `trace` **[boolean][20]?** record [tracing information][25] with screenshots.
47
+ - `trace` **[boolean][20]?** record [tracing information][24] with screenshots.
48
48
  - `keepTraceForPassedTests` **[boolean][20]?** save trace for passed tests.
49
49
  - `keepBrowserState` **[boolean][20]?** keep browser state between tests when `restart` is set to false.
50
50
  - `keepCookies` **[boolean][20]?** keep cookies between tests when `restart` is set to false.
@@ -57,7 +57,7 @@ Type: [object][4]
57
57
  - `userAgent` **[string][6]?** user-agent string.
58
58
  - `manualStart` **[boolean][20]?** do not start browser before a test, start it manually inside a helper with `this.helpers["Puppeteer"]._startBrowser()`.
59
59
  - `browser` **[string][6]?** can be changed to `firefox` when using [puppeteer-firefox][2].
60
- - `chrome` **[object][4]?** pass additional [Puppeteer run options][26].
60
+ - `chrome` **[object][4]?** pass additional [Puppeteer run options][25].
61
61
  - `highlightElement` **[boolean][20]?** highlight the interacting elements. Default: false. Note: only activate under verbose mode (--verbose).
62
62
 
63
63
 
@@ -211,7 +211,7 @@ This action supports [React locators](https://codecept.io/react#locators)
211
211
 
212
212
  ### _locateCheckable
213
213
 
214
- Find a checkbox by providing human readable text:
214
+ Find a checkbox by providing human-readable text:
215
215
  NOTE: Assumes the checkable element exists
216
216
 
217
217
  ```js
@@ -225,7 +225,7 @@ this.helpers['Puppeteer']._locateCheckable('I agree with terms and conditions').
225
225
 
226
226
  ### _locateClickable
227
227
 
228
- Find a clickable element by providing human readable text:
228
+ Find a clickable element by providing human-readable text:
229
229
 
230
230
  ```js
231
231
  this.helpers['Puppeteer']._locateClickable('Next page').then // ...
@@ -237,7 +237,7 @@ this.helpers['Puppeteer']._locateClickable('Next page').then // ...
237
237
 
238
238
  ### _locateFields
239
239
 
240
- Find field elements by providing human readable text:
240
+ Find field elements by providing human-readable text:
241
241
 
242
242
  ```js
243
243
  this.helpers['Puppeteer']._locateFields('Your email').then // ...
@@ -324,6 +324,8 @@ This action supports [React locators](https://codecept.io/react#locators)
324
324
 
325
325
  ### attachFile
326
326
 
327
+ > ⚠ There is an [issue with file upload in Puppeteer 2.1.0 & 2.1.1][7], downgrade to 2.0.0 if you face it.
328
+
327
329
  Attaches a file to element located by label, name, CSS or XPath
328
330
  Path to file is relative current codecept directory (where codecept.conf.ts or codecept.conf.js is located).
329
331
  File will be uploaded to remote system (if tests are running remotely).
@@ -338,7 +340,7 @@ I.attachFile('form input[name=avatar]', 'data/avatar.jpg');
338
340
  - `locator` **([string][6] | [object][4])** field located by label|name|CSS|XPath|strict locator.
339
341
  - `pathToFile` **[string][6]** local file path relative to codecept.conf.ts or codecept.conf.js config file.
340
342
 
341
- Returns **void** automatically synchronized promise through #recorder> ⚠ There is an [issue with file upload in Puppeteer 2.1.0 & 2.1.1][7], downgrade to 2.0.0 if you face it.
343
+ Returns **void** automatically synchronized promise through #recorder
342
344
 
343
345
  ### blur
344
346
 
@@ -718,6 +720,7 @@ This action supports [React locators](https://codecept.io/react#locators)
718
720
 
719
721
  ### executeAsyncScript
720
722
 
723
+ Asynchronous scripts can also be executed with `executeScript` if a function returns a Promise.
721
724
  Executes async script on page.
722
725
  Provided function should execute a passed callback (as first argument) to signal it is finished.
723
726
 
@@ -744,10 +747,12 @@ let val = await I.executeAsyncScript(function(url, done) {
744
747
  - `args` **...any** to be passed to function.
745
748
  - `fn` **([string][6] | [function][12])** function to be executed in browser context.
746
749
 
747
- Returns **[Promise][13]<any>** script return valueAsynchronous scripts can also be executed with `executeScript` if a function returns a Promise.
750
+ Returns **[Promise][13]<any>** script return value
748
751
 
749
752
  ### executeScript
750
753
 
754
+ If a function returns a Promise, tt will wait for its resolution.
755
+
751
756
  Executes sync script on a page.
752
757
  Pass arguments to function as additional parameters.
753
758
  Will return execution result to a test.
@@ -777,7 +782,7 @@ let date = await I.executeScript(function(el) {
777
782
  - `args` **...any** to be passed to function.
778
783
  - `fn` **([string][6] | [function][12])** function to be executed in browser context.
779
784
 
780
- Returns **[Promise][13]<any>** script return valueIf a function returns a Promise It will wait for it resolution.
785
+ Returns **[Promise][13]<any>** script return value
781
786
 
782
787
  ### fillField
783
788
 
@@ -1216,12 +1221,27 @@ let inputs = await I.grabValueFromAll('//form/input');
1216
1221
 
1217
1222
  Returns **[Promise][13]<[Array][15]<[string][6]>>** attribute value
1218
1223
 
1224
+ ### grabWebElements
1225
+
1226
+ Grab WebElements for given locator
1227
+ Resumes test execution, so **should be used inside an async function with `await`** operator.
1228
+
1229
+ ```js
1230
+ const webElements = await I.grabWebElements('#button');
1231
+ ```
1232
+
1233
+ #### Parameters
1234
+
1235
+ - `locator` **([string][6] | [object][4])** element located by CSS|XPath|strict locator.
1236
+
1237
+ Returns **[Promise][13]<any>** WebElement of being used Web helper
1238
+
1219
1239
  ### handleDownloads
1220
1240
 
1221
1241
  Sets a directory to where save files. Allows to test file downloads.
1222
1242
  Should be used with [FileSystem helper][16] to check that file were downloaded correctly.
1223
1243
 
1224
- By default files are saved to `output/downloads`.
1244
+ By default, files are saved to `output/downloads`.
1225
1245
  This directory is cleaned on every `handleDownloads` call, to ensure no old files are kept.
1226
1246
 
1227
1247
  ```js
@@ -1267,9 +1287,11 @@ I.openNewTab();
1267
1287
 
1268
1288
  ### pressKey
1269
1289
 
1290
+ _Note:_ Shortcuts like `'Meta'` + `'A'` do not work on macOS ([GoogleChrome/puppeteer#1313][17]).
1291
+
1270
1292
  Presses a key in the browser (on a focused element).
1271
1293
 
1272
- _Hint:_ For populating text field or textarea, it is recommended to use [`fillField`][17].
1294
+ _Hint:_ For populating text field or textarea, it is recommended to use [`fillField`][18].
1273
1295
 
1274
1296
  ```js
1275
1297
  I.pressKey('Backspace');
@@ -1330,7 +1352,7 @@ Some of the supported key names are:
1330
1352
 
1331
1353
  - `key` **([string][6] | [Array][15]<[string][6]>)** key or array of keys to press.
1332
1354
 
1333
- Returns **void** automatically synchronized promise through #recorder_Note:_ Shortcuts like `'Meta'` + `'A'` do not work on macOS ([GoogleChrome/puppeteer#1313][18]).
1355
+ Returns **void** automatically synchronized promise through #recorder
1334
1356
 
1335
1357
  ### pressKeyDown
1336
1358
 
@@ -1380,6 +1402,10 @@ Returns **void** automatically synchronized promise through #recorder
1380
1402
 
1381
1403
  ### resizeWindow
1382
1404
 
1405
+ Unlike other drivers Puppeteer changes the size of a viewport, not the window!
1406
+ Puppeteer does not control the window of a browser, so it can't adjust its real size.
1407
+ It also can't maximize a window.
1408
+
1383
1409
  Resize the current window to provided width and height.
1384
1410
  First parameter can be set to `maximize`.
1385
1411
 
@@ -1388,9 +1414,7 @@ First parameter can be set to `maximize`.
1388
1414
  - `width` **[number][10]** width in pixels or `maximize`.
1389
1415
  - `height` **[number][10]** height in pixels.
1390
1416
 
1391
- Returns **void** automatically synchronized promise through #recorderUnlike other drivers Puppeteer changes the size of a viewport, not the window!
1392
- Puppeteer does not control the window of a browser so it can't adjust its real size.
1393
- It also can't maximize a window.
1417
+ Returns **void** automatically synchronized promise through #recorder
1394
1418
 
1395
1419
  ### rightClick
1396
1420
 
@@ -1883,7 +1907,7 @@ I.switchToPreviousTab(2);
1883
1907
 
1884
1908
  Types out the given text into an active field.
1885
1909
  To slow down typing use a second parameter, to set interval between key presses.
1886
- _Note:_ Should be used when [`fillField`][17] is not an option.
1910
+ _Note:_ Should be used when [`fillField`][18] is not an option.
1887
1911
 
1888
1912
  ```js
1889
1913
  // passing in a string
@@ -2069,9 +2093,9 @@ Returns **void** automatically synchronized promise through #recorder
2069
2093
 
2070
2094
  ### waitForNavigation
2071
2095
 
2072
- Waits for navigation to finish. By default takes configured `waitForNavigation` option.
2096
+ Waits for navigation to finish. By default, takes configured `waitForNavigation` option.
2073
2097
 
2074
- See [Pupeteer's reference][23]
2098
+ See [Puppeteer's reference][23]
2075
2099
 
2076
2100
  #### Parameters
2077
2101
 
@@ -2154,7 +2178,11 @@ I.waitForVisible('#popup');
2154
2178
  - `locator` **([string][6] | [object][4])** element located by CSS|XPath|strict locator.
2155
2179
  - `sec` **[number][10]** (optional, `1` by default) time in seconds to wait
2156
2180
 
2157
- Returns **void** automatically synchronized promise through #recorderThis method accepts [React selectors][24].
2181
+ Returns **void** automatically synchronized promise through #recorder
2182
+
2183
+
2184
+ This action supports [React locators](https://codecept.io/react#locators)
2185
+
2158
2186
 
2159
2187
  ### waitInUrl
2160
2188
 
@@ -2255,9 +2283,9 @@ Returns **void** automatically synchronized promise through #recorder
2255
2283
 
2256
2284
  [16]: https://codecept.io/helpers/FileSystem
2257
2285
 
2258
- [17]: #fillfield
2286
+ [17]: https://github.com/GoogleChrome/puppeteer/issues/1313
2259
2287
 
2260
- [18]: https://github.com/GoogleChrome/puppeteer/issues/1313
2288
+ [18]: #fillfield
2261
2289
 
2262
2290
  [19]: #click
2263
2291
 
@@ -2269,8 +2297,6 @@ Returns **void** automatically synchronized promise through #recorder
2269
2297
 
2270
2298
  [23]: https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#pagewaitfornavigationoptions
2271
2299
 
2272
- [24]: https://codecept.io/react
2273
-
2274
- [25]: https://pptr.dev/api/puppeteer.tracing
2300
+ [24]: https://pptr.dev/api/puppeteer.tracing
2275
2301
 
2276
- [26]: https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#puppeteerlaunchoptions
2302
+ [25]: https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#puppeteerlaunchoptions
@@ -482,6 +482,8 @@ This action supports [React locators](https://codecept.io/react#locators)
482
482
 
483
483
  ### attachFile
484
484
 
485
+ Appium: not tested
486
+
485
487
  Attaches a file to element located by label, name, CSS or XPath
486
488
  Path to file is relative current codecept directory (where codecept.conf.ts or codecept.conf.js is located).
487
489
  File will be uploaded to remote system (if tests are running remotely).
@@ -496,7 +498,7 @@ I.attachFile('form input[name=avatar]', 'data/avatar.jpg');
496
498
  - `locator` **([string][17] | [object][16])** field located by label|name|CSS|XPath|strict locator.
497
499
  - `pathToFile` **[string][17]** local file path relative to codecept.conf.ts or codecept.conf.js config file.
498
500
 
499
- Returns **void** automatically synchronized promise through #recorderAppium: not tested
501
+ Returns **void** automatically synchronized promise through #recorder
500
502
 
501
503
  ### blur
502
504
 
@@ -525,10 +527,11 @@ Returns **void** automatically synchronized promise through #recorder
525
527
 
526
528
  ### cancelPopup
527
529
 
528
- Dismisses the active JavaScript popup, as created by window.alert|window.confirm|window.prompt.
530
+ Dismisses the active JavaScript popup, as created by `window.alert|window.confirm|window.prompt`.
529
531
 
530
532
  ### checkOption
531
533
 
534
+ Appium: not tested
532
535
  Selects a checkbox or radio button.
533
536
  Element is located by label or name or CSS or XPath.
534
537
 
@@ -545,7 +548,7 @@ I.checkOption('agree', '//form');
545
548
  - `field` **([string][17] | [object][16])** checkbox located by label | name | CSS | XPath | strict locator.
546
549
  - `context` **([string][17]? | [object][16])** (optional, `null` by default) element located by CSS | XPath | strict locator.
547
550
 
548
- Returns **void** automatically synchronized promise through #recorderAppium: not tested
551
+ Returns **void** automatically synchronized promise through #recorder
549
552
 
550
553
  ### clearCookie
551
554
 
@@ -671,6 +674,7 @@ This action supports [React locators](https://codecept.io/react#locators)
671
674
 
672
675
  ### dontSeeCheckboxIsChecked
673
676
 
677
+ Appium: not tested
674
678
  Verifies that the specified checkbox is not checked.
675
679
 
676
680
  ```js
@@ -683,7 +687,7 @@ I.dontSeeCheckboxIsChecked('agree'); // located by name
683
687
 
684
688
  - `field` **([string][17] | [object][16])** located by label|name|CSS|XPath|strict locator.
685
689
 
686
- Returns **void** automatically synchronized promise through #recorderAppium: not tested
690
+ Returns **void** automatically synchronized promise through #recorder
687
691
 
688
692
  ### dontSeeCookie
689
693
 
@@ -828,6 +832,7 @@ This action supports [React locators](https://codecept.io/react#locators)
828
832
 
829
833
  ### dragAndDrop
830
834
 
835
+ Appium: not tested
831
836
  Drag an item to a destination element.
832
837
 
833
838
  ```js
@@ -839,7 +844,7 @@ I.dragAndDrop('#dragHandle', '#container');
839
844
  - `srcElement` **([string][17] | [object][16])** located by CSS|XPath|strict locator.
840
845
  - `destElement` **([string][17] | [object][16])** located by CSS|XPath|strict locator.
841
846
 
842
- Returns **void** automatically synchronized promise through #recorderAppium: not tested
847
+ Returns **void** automatically synchronized promise through #recorder
843
848
 
844
849
  ### dragSlider
845
850
 
@@ -890,6 +895,8 @@ Returns **[Promise][25]<any>** script return value
890
895
 
891
896
  ### executeScript
892
897
 
898
+ Wraps [execute][26] command.
899
+
893
900
  Executes sync script on a page.
894
901
  Pass arguments to function as additional parameters.
895
902
  Will return execution result to a test.
@@ -919,7 +926,7 @@ let date = await I.executeScript(function(el) {
919
926
  - `args` **...any** to be passed to function.
920
927
  - `fn` **([string][17] | [function][24])** function to be executed in browser context.
921
928
 
922
- Returns **[Promise][25]<any>** script return valueWraps [execute][26] command.
929
+ Returns **[Promise][25]<any>** script return value
923
930
 
924
931
  ### fillField
925
932
 
@@ -1367,6 +1374,21 @@ let inputs = await I.grabValueFromAll('//form/input');
1367
1374
 
1368
1375
  Returns **[Promise][25]<[Array][28]<[string][17]>>** attribute value
1369
1376
 
1377
+ ### grabWebElements
1378
+
1379
+ Grab WebElements for given locator
1380
+ Resumes test execution, so **should be used inside an async function with `await`** operator.
1381
+
1382
+ ```js
1383
+ const webElements = await I.grabWebElements('#button');
1384
+ ```
1385
+
1386
+ #### Parameters
1387
+
1388
+ - `locator` **([string][17] | [object][16])** element located by CSS|XPath|strict locator.
1389
+
1390
+ Returns **[Promise][25]<any>** WebElement of being used Web helper
1391
+
1370
1392
  ### moveCursorTo
1371
1393
 
1372
1394
  Moves cursor to element matched by locator.
@@ -1404,6 +1426,8 @@ Returns **void** automatically synchronized promise through #recorder
1404
1426
 
1405
1427
  ### pressKey
1406
1428
 
1429
+ _Note:_ In case a text field or textarea is focused be aware that some browsers do not respect active modifier when combining modifier keys with other keys.
1430
+
1407
1431
  Presses a key in the browser (on a focused element).
1408
1432
 
1409
1433
  _Hint:_ For populating text field or textarea, it is recommended to use [`fillField`][30].
@@ -1467,7 +1491,7 @@ Some of the supported key names are:
1467
1491
 
1468
1492
  - `key` **([string][17] | [Array][28]<[string][17]>)** key or array of keys to press.
1469
1493
 
1470
- Returns **void** automatically synchronized promise through #recorder_Note:_ In case a text field or textarea is focused be aware that some browsers do not respect active modifier when combining modifier keys with other keys.
1494
+ Returns **void** automatically synchronized promise through #recorder
1471
1495
 
1472
1496
  ### pressKeyDown
1473
1497
 
@@ -1517,6 +1541,8 @@ Returns **void** automatically synchronized promise through #recorder
1517
1541
 
1518
1542
  ### resizeWindow
1519
1543
 
1544
+ Appium: not tested in web, in apps doesn't work
1545
+
1520
1546
  Resize the current window to provided width and height.
1521
1547
  First parameter can be set to `maximize`.
1522
1548
 
@@ -1525,7 +1551,7 @@ First parameter can be set to `maximize`.
1525
1551
  - `width` **[number][22]** width in pixels or `maximize`.
1526
1552
  - `height` **[number][22]** height in pixels.
1527
1553
 
1528
- Returns **void** automatically synchronized promise through #recorderAppium: not tested in web, in apps doesn't work
1554
+ Returns **void** automatically synchronized promise through #recorder
1529
1555
 
1530
1556
  ### rightClick
1531
1557
 
@@ -1624,7 +1650,7 @@ I.scrollIntoView('#submit', { behavior: "smooth", block: "center", inline: "cent
1624
1650
  #### Parameters
1625
1651
 
1626
1652
  - `locator` **([string][17] | [object][16])** located by CSS|XPath|strict locator.
1627
- - `scrollIntoViewOptions` **ScrollIntoViewOptions** see [https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView][33].
1653
+ - `scrollIntoViewOptions` **(ScrollIntoViewOptions | [boolean][32])** either alignToTop=true|false or scrollIntoViewOptions. See [https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView][33].
1628
1654
 
1629
1655
  Returns **void** automatically synchronized promise through #recorder
1630
1656
 
@@ -1705,6 +1731,7 @@ Returns **void** automatically synchronized promise through #recorder
1705
1731
 
1706
1732
  ### seeCheckboxIsChecked
1707
1733
 
1734
+ Appium: not tested
1708
1735
  Verifies that the specified checkbox is checked.
1709
1736
 
1710
1737
  ```js
@@ -1717,7 +1744,7 @@ I.seeCheckboxIsChecked({css: '#signup_form input[type=checkbox]'});
1717
1744
 
1718
1745
  - `field` **([string][17] | [object][16])** located by label|name|CSS|XPath|strict locator.
1719
1746
 
1720
- Returns **void** automatically synchronized promise through #recorderAppium: not tested
1747
+ Returns **void** automatically synchronized promise through #recorder
1721
1748
 
1722
1749
  ### seeCookie
1723
1750
 
@@ -1968,6 +1995,7 @@ Returns **void** automatically synchronized promise through #recorder
1968
1995
 
1969
1996
  ### setCookie
1970
1997
 
1998
+ Uses Selenium's JSON [cookie format][34].
1971
1999
  Sets cookie(s).
1972
2000
 
1973
2001
  Can be a single cookie object or an array of cookies:
@@ -1986,8 +2014,7 @@ I.setCookie([
1986
2014
 
1987
2015
  - `cookie` **(Cookie | [Array][28]<Cookie>)** a cookie object or array of cookie objects.
1988
2016
 
1989
- Returns **void** automatically synchronized promise through #recorderUses Selenium's JSON [cookie
1990
- format][34].
2017
+ Returns **void** automatically synchronized promise through #recorder
1991
2018
 
1992
2019
  ### setGeoLocation
1993
2020
 
@@ -2101,6 +2128,7 @@ Returns **void** automatically synchronized promise through #recorder
2101
2128
 
2102
2129
  ### uncheckOption
2103
2130
 
2131
+ Appium: not tested
2104
2132
  Unselects a checkbox or radio button.
2105
2133
  Element is located by label or name or CSS or XPath.
2106
2134
 
@@ -2117,7 +2145,7 @@ I.uncheckOption('agree', '//form');
2117
2145
  - `field` **([string][17] | [object][16])** checkbox located by label | name | CSS | XPath | strict locator.
2118
2146
  - `context` **([string][17]? | [object][16])** (optional, `null` by default) element located by CSS | XPath | strict locator.
2119
2147
 
2120
- Returns **void** automatically synchronized promise through #recorderAppium: not tested
2148
+ Returns **void** automatically synchronized promise through #recorder
2121
2149
 
2122
2150
  ### useWebDriverTo
2123
2151
 
@@ -119,6 +119,7 @@ Available events:
119
119
  * `event.all.result` - when results are printed
120
120
  * `event.workers.before` - before spawning workers in parallel run
121
121
  * `event.workers.after` - after workers finished in parallel run
122
+ * `event.workers.result` - test results after workers finished in parallel run
122
123
 
123
124
 
124
125
  > *sync* - means that event is fired in the moment of the action happening.
package/docs/parallel.md CHANGED
@@ -26,12 +26,124 @@ This command is similar to `run`, however, steps output can't be shown in worker
26
26
 
27
27
  Each worker spins an instance of CodeceptJS, executes a group of tests, and sends back report to the main process.
28
28
 
29
- By default the tests are assigned one by one to the available workers this may lead to multiple execution of `BeforeSuite()`. Use the option `--suites` to assigne the suites one by one to the workers.
29
+ By default, the tests are assigned one by one to the available workers this may lead to multiple execution of `BeforeSuite()`. Use the option `--suites` to assign the suites one by one to the workers.
30
30
 
31
31
  ```sh
32
32
  npx codeceptjs run-workers --suites 2
33
33
  ```
34
34
 
35
+ ## Test stats with Parallel Execution by Workers
36
+
37
+ ```js
38
+ const { event } = require('codeceptjs');
39
+
40
+ module.exports = function() {
41
+
42
+ event.dispatcher.on(event.workers.result, function (result) {
43
+
44
+ console.log(result);
45
+
46
+ });
47
+ }
48
+
49
+ // in console log
50
+ FAIL | 7 passed, 1 failed, 1 skipped // 2s
51
+ {
52
+ "tests": {
53
+ "passed": [
54
+ {
55
+ "type": "test",
56
+ "title": "Assert @C3",
57
+ "body": "() => { }",
58
+ "async": 0,
59
+ "sync": true,
60
+ "_timeout": 2000,
61
+ "_slow": 75,
62
+ "_retries": -1,
63
+ "timedOut": false,
64
+ "_currentRetry": 0,
65
+ "pending": false,
66
+ "opts": {},
67
+ "tags": [
68
+ "@C3"
69
+ ],
70
+ "uid": "xe4q1HdqpRrZG5dPe0JG+A",
71
+ "workerIndex": 3,
72
+ "retries": -1,
73
+ "duration": 493,
74
+ "err": null,
75
+ "parent": {
76
+ "title": "My",
77
+ "ctx": {},
78
+ "suites": [],
79
+ "tests": [],
80
+ "root": false,
81
+ "pending": false,
82
+ "_retries": -1,
83
+ "_beforeEach": [],
84
+ "_beforeAll": [],
85
+ "_afterEach": [],
86
+ "_afterAll": [],
87
+ "_timeout": 2000,
88
+ "_slow": 75,
89
+ "_bail": false,
90
+ "_onlyTests": [],
91
+ "_onlySuites": [],
92
+ "delayed": false
93
+ },
94
+ "steps": [
95
+ {
96
+ "actor": "I",
97
+ "name": "amOnPage",
98
+ "status": "success",
99
+ "args": [
100
+ "https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST"
101
+ ],
102
+ "startedAt": 1698760652610,
103
+ "startTime": 1698760652611,
104
+ "endTime": 1698760653098,
105
+ "finishedAt": 1698760653098,
106
+ "duration": 488
107
+ },
108
+ {
109
+ "actor": "I",
110
+ "name": "grabCurrentUrl",
111
+ "status": "success",
112
+ "args": [],
113
+ "startedAt": 1698760653098,
114
+ "startTime": 1698760653098,
115
+ "endTime": 1698760653099,
116
+ "finishedAt": 1698760653099,
117
+ "duration": 1
118
+ }
119
+ ]
120
+ }
121
+ ],
122
+ "failed": [],
123
+ "skipped": []
124
+ }
125
+ }
126
+ ```
127
+
128
+ CodeceptJS also exposes the env var `process.env.RUNS_WITH_WORKERS` when running tests with `run-workers` command so that you could handle the events better in your plugins/helpers
129
+
130
+ ```js
131
+ const { event } = require('codeceptjs');
132
+
133
+ module.exports = function() {
134
+ // this event would trigger the `_publishResultsToTestrail` when running `run-workers` command
135
+ event.dispatcher.on(event.workers.result, async () => {
136
+ await _publishResultsToTestrail();
137
+ });
138
+
139
+ // this event would not trigger the `_publishResultsToTestrail` multiple times when running `run-workers` command
140
+ event.dispatcher.on(event.all.result, async () => {
141
+ // when running `run` command, this env var is undefined
142
+ if (!process.env.RUNS_WITH_WORKERS) await _publishResultsToTestrail();
143
+ });
144
+ }
145
+ ```
146
+
35
147
  ## Parallel Execution by Workers on Multiple Browsers
36
148
 
37
149
  To run tests in parallel across multiple browsers, modify your `codecept.conf.js` file to configure multiple browsers on which you want to run your tests and your tests will run across multiple browsers.
@@ -236,7 +348,7 @@ customWorkers.on(event.all.result, () => {
236
348
 
237
349
  ### Emitting messages to the parent worker
238
350
 
239
- Child workers can send non test events to the main process. This is useful if you want to pass along information not related to the tests event cycles itself such as `event.test.success`.
351
+ Child workers can send non-test events to the main process. This is useful if you want to pass along information not related to the tests event cycles itself such as `event.test.success`.
240
352
 
241
353
  ```js
242
354
  // inside main process
package/docs/plugins.md CHANGED
@@ -65,12 +65,14 @@ If a session expires automatically logs in again.
65
65
  ```js
66
66
  // inside a test file
67
67
  // use login to inject auto-login function
68
+ Feature('Login');
69
+
68
70
  Before(({ login }) => {
69
71
  login('user'); // login using user session
70
72
  });
71
73
 
72
- // Alternatively log in for one scenario
73
- Scenario('log me in', ( {I, login} ) => {
74
+ // Alternatively log in for one scenario.
75
+ Scenario('log me in', ( { I, login } ) => {
74
76
  login('admin');
75
77
  I.see('I am logged in');
76
78
  });
@@ -719,7 +721,7 @@ Run tests with plugin enabled:
719
721
  - `factor` - The exponential factor to use. Default is 1.5.
720
722
  - `minTimeout` - The number of milliseconds before starting the first retry. Default is 1000.
721
723
  - `maxTimeout` - The maximum number of milliseconds between two retries. Default is Infinity.
722
- - `randomize` - Randomizes the timeouts by multiplying with a factor between 1 to 2. Default is false.
724
+ - `randomize` - Randomizes the timeouts by multiplying with a factor from 1 to 2. Default is false.
723
725
  - `defaultIgnoredSteps` - an array of steps to be ignored for retry. Includes:
724
726
  - `amOnPage`
725
727
  - `wait*`
@@ -1083,7 +1085,7 @@ plugins: {
1083
1085
 
1084
1086
  ## tryTo
1085
1087
 
1086
- Adds global `tryTo` function inside of which all failed steps won't fail a test but will return true/false.
1088
+ Adds global `tryTo` function in which all failed steps won't fail a test but will return true/false.
1087
1089
 
1088
1090
  Enable this plugin in `codecept.conf.js` (enabled by default for new setups):
1089
1091
 
@@ -1122,7 +1124,7 @@ Add assert requires first:
1122
1124
  const assert = require('assert');
1123
1125
  ````
1124
1126
 
1125
- Then use the assert:
1127
+ Then use the assertion:
1126
1128
  const result1 = await tryTo(() => I.see('Hello, user'));
1127
1129
  const result2 = await tryTo(() => I.seeElement('.welcome'));
1128
1130
  assert.ok(result1 && result2, 'Assertions were not succesful');
package/docs/react.md CHANGED
@@ -66,4 +66,5 @@ To find React element names and props in a tree use [React DevTools](https://chr
66
66
 
67
67
  > Turn off minification for application builds otherwise component names will be uglified as well
68
68
 
69
- React locators work via [resq](https://github.com/baruchvlz/resq) library, which handles React 16 and above.
69
+ - With WebDriver and Puppeteer, React locators work via [resq](https://github.com/baruchvlz/resq) library, which handles React 16 and above.
70
+ - With Playwright, React locators work via [Playwright React Locator](https://playwright.dev/docs/other-locators#react-locator).
package/docs/vue.md CHANGED
@@ -104,6 +104,28 @@ tests
104
104
 
105
105
  If you agreed to create a demo component, you will also see `TestMe` component in `src/components` folder.
106
106
 
107
+ ## Locators
108
+
109
+ For Vue apps a special `vue` locator is available. It allows to select an element by its component name, and props.
110
+
111
+ ```js
112
+ { vue: 'MyComponent' }
113
+ { vue: 'Button', props: { title: 'Click Me' }}
114
+ ```
115
+
116
+ With Playwright, you can use Vue locators in any method where locator is required:
117
+
118
+ ```js
119
+ I.click({ vue: 'Tab', props: { title: 'Click Me!' }});
120
+ I.seeElement({ vue: 't', props: { title: 'Clicked' }});
121
+ ```
122
+
123
+ To find Vue element names and props in a tree use [Vue DevTools](https://chromewebstore.google.com/detail/vuejs-devtools/nhdogjmejiglipccpnnnanhbledajbpd) extension.
124
+
125
+ > Turn off minification for application builds otherwise component names will be uglified as well
126
+
127
+ Vue locators work via [Playwright Vue Locator](https://playwright.dev/docs/other-locators#vue-locator).
128
+
107
129
  ## How to write tests?
108
130
 
109
131
  * Open `tests/e2e/app_js` and see the demo test
@@ -0,0 +1,9 @@
1
+ Grab WebElement for given locator
2
+ Resumes test execution, so **should be used inside an async function with `await`** operator.
3
+
4
+ ```js
5
+ const webElement = await I.grabWebElement('#button');
6
+ ```
7
+
8
+ @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
9
+ @returns {Promise<*>} WebElement of being used Web helper
@@ -0,0 +1,9 @@
1
+ Grab WebElements for given locator
2
+ Resumes test execution, so **should be used inside an async function with `await`** operator.
3
+
4
+ ```js
5
+ const webElements = await I.grabWebElements('#button');
6
+ ```
7
+
8
+ @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
9
+ @returns {Promise<*>} WebElement of being used Web helper
@@ -7,5 +7,5 @@ I.scrollIntoView('#submit', { behavior: "smooth", block: "center", inline: "cent
7
7
  ```
8
8
 
9
9
  @param {LocatorOrString} locator located by CSS|XPath|strict locator.
10
- @param {ScrollIntoViewOptions} scrollIntoViewOptions see https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView.
10
+ @param {ScrollIntoViewOptions|boolean} scrollIntoViewOptions either alignToTop=true|false or scrollIntoViewOptions. See https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView.
11
11
  @returns {void} automatically synchronized promise through #recorder