codeceptjs 3.2.1 → 3.3.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +67 -0
- package/docs/advanced.md +3 -3
- package/docs/api.md +227 -188
- package/docs/basics.md +26 -1
- package/docs/bdd.md +2 -2
- package/docs/build/ApiDataFactory.js +13 -6
- package/docs/build/Appium.js +98 -36
- package/docs/build/FileSystem.js +11 -1
- package/docs/build/GraphQL.js +11 -0
- package/docs/build/JSONResponse.js +297 -0
- package/docs/build/Nightmare.js +48 -48
- package/docs/build/Playwright.js +282 -151
- package/docs/build/Puppeteer.js +76 -67
- package/docs/build/REST.js +36 -0
- package/docs/build/TestCafe.js +44 -44
- package/docs/build/WebDriver.js +70 -70
- package/docs/changelog.md +17 -0
- package/docs/configuration.md +8 -8
- package/docs/custom-helpers.md +1 -1
- package/docs/data.md +9 -9
- package/docs/helpers/ApiDataFactory.md +7 -0
- package/docs/helpers/Appium.md +240 -198
- package/docs/helpers/FileSystem.md +11 -1
- package/docs/helpers/JSONResponse.md +230 -0
- package/docs/helpers/Playwright.md +283 -216
- package/docs/helpers/Puppeteer.md +9 -1
- package/docs/helpers/REST.md +30 -9
- package/docs/installation.md +3 -1
- package/docs/internal-api.md +265 -0
- package/docs/mobile.md +11 -11
- package/docs/nightmare.md +3 -3
- package/docs/pageobjects.md +2 -0
- package/docs/playwright.md +73 -18
- package/docs/plugins.md +138 -38
- package/docs/puppeteer.md +28 -12
- package/docs/quickstart.md +2 -3
- package/docs/reports.md +44 -3
- package/docs/testcafe.md +1 -1
- package/docs/translation.md +2 -2
- package/docs/videos.md +2 -2
- package/docs/visual.md +2 -2
- package/docs/vue.md +1 -1
- package/docs/webdriver.md +92 -4
- package/lib/actor.js +2 -2
- package/lib/cli.js +25 -20
- package/lib/command/init.js +5 -15
- package/lib/command/workers/runTests.js +25 -7
- package/lib/config.js +17 -13
- package/lib/helper/ApiDataFactory.js +13 -6
- package/lib/helper/Appium.js +65 -3
- package/lib/helper/FileSystem.js +11 -1
- package/lib/helper/GraphQL.js +11 -0
- package/lib/helper/JSONResponse.js +297 -0
- package/lib/helper/Playwright.js +220 -89
- package/lib/helper/Puppeteer.js +12 -3
- package/lib/helper/REST.js +36 -0
- package/lib/helper/WebDriver.js +1 -1
- package/lib/helper/extras/Console.js +8 -0
- package/lib/helper/extras/PlaywrightRestartOpts.js +35 -0
- package/lib/interfaces/bdd.js +3 -1
- package/lib/listener/timeout.js +4 -3
- package/lib/plugin/allure.js +12 -0
- package/lib/plugin/autoLogin.js +1 -1
- package/lib/plugin/eachElement.js +127 -0
- package/lib/plugin/stepTimeout.js +5 -4
- package/lib/plugin/tryTo.js +6 -0
- package/lib/recorder.js +2 -1
- package/lib/step.js +57 -2
- package/lib/utils.js +20 -0
- package/package.json +24 -22
- package/translations/pt-BR.js +8 -0
- package/typings/index.d.ts +4 -0
- package/typings/types.d.ts +345 -110
package/docs/plugins.md
CHANGED
|
@@ -58,6 +58,21 @@ const allure = codeceptjs.container.plugins('allure');
|
|
|
58
58
|
- `addAttachment(name, buffer, type)` - add an attachment to current test / suite
|
|
59
59
|
- `addLabel(name, value)` - adds a label to current test
|
|
60
60
|
- `addParameter(kind, name, value)` - adds a parameter to current test
|
|
61
|
+
- `createStep(name, stepFunc)` - create a step, stepFunc could consist an attachment
|
|
62
|
+
Example of usage:
|
|
63
|
+
|
|
64
|
+
```js
|
|
65
|
+
allure.createStep('New created step', () => {
|
|
66
|
+
allure.addAttachment(
|
|
67
|
+
'Request params',
|
|
68
|
+
'{"clientId":123, "name":"Tom", "age":29}',
|
|
69
|
+
'application/json'
|
|
70
|
+
);
|
|
71
|
+
});
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
![Created Step Image][3]
|
|
75
|
+
|
|
61
76
|
- `severity(value)` - adds severity label
|
|
62
77
|
- `epic(value)` - adds epic label
|
|
63
78
|
- `feature(value)` - adds feature label
|
|
@@ -127,7 +142,7 @@ If a session expires automatically logs in again.
|
|
|
127
142
|
```js
|
|
128
143
|
// inside a test file
|
|
129
144
|
// use login to inject auto-login function
|
|
130
|
-
Before(login => {
|
|
145
|
+
Before(({ login }) => {
|
|
131
146
|
login('user'); // login using user session
|
|
132
147
|
});
|
|
133
148
|
|
|
@@ -434,7 +449,7 @@ Possible config options:
|
|
|
434
449
|
|
|
435
450
|
## customLocator
|
|
436
451
|
|
|
437
|
-
Creates a [custom locator][
|
|
452
|
+
Creates a [custom locator][4] by using special attributes in HTML.
|
|
438
453
|
|
|
439
454
|
If you have a convention to use `data-test-id` or `data-qa` attributes to mark active elements for e2e tests,
|
|
440
455
|
you can enable this plugin to simplify matching elements with these attributes:
|
|
@@ -501,11 +516,76 @@ I.click('=sign-up'); // matches => [data-qa=sign-up]
|
|
|
501
516
|
|
|
502
517
|
- `config`
|
|
503
518
|
|
|
519
|
+
## eachElement
|
|
520
|
+
|
|
521
|
+
Provides `eachElement` global function to iterate over found elements to perform actions on them.
|
|
522
|
+
|
|
523
|
+
`eachElement` takes following args:
|
|
524
|
+
|
|
525
|
+
- `purpose` - the goal of an action. A comment text that will be displayed in output.
|
|
526
|
+
- `locator` - a CSS/XPath locator to match elements
|
|
527
|
+
- `fn(element, index)` - **asynchronous** function which will be executed for each matched element.
|
|
528
|
+
|
|
529
|
+
Example of usage:
|
|
530
|
+
|
|
531
|
+
```js
|
|
532
|
+
// this example works with Playwright and Puppeteer helper
|
|
533
|
+
await eachElement('click all checkboxes', 'form input[type=checkbox]', async (el) => {
|
|
534
|
+
await el.click();
|
|
535
|
+
});
|
|
536
|
+
```
|
|
537
|
+
|
|
538
|
+
Click odd elements:
|
|
539
|
+
|
|
540
|
+
```js
|
|
541
|
+
// this example works with Playwright and Puppeteer helper
|
|
542
|
+
await eachElement('click odd buttons', '.button-select', async (el, index) => {
|
|
543
|
+
if (index % 2) await el.click();
|
|
544
|
+
});
|
|
545
|
+
```
|
|
546
|
+
|
|
547
|
+
Check all elements for visibility:
|
|
548
|
+
|
|
549
|
+
```js
|
|
550
|
+
// this example works with Playwright and Puppeteer helper
|
|
551
|
+
const assert = require('assert');
|
|
552
|
+
await eachElement('check all items are visible', '.item', async (el) => {
|
|
553
|
+
assert(await el.isVisible());
|
|
554
|
+
});
|
|
555
|
+
```
|
|
556
|
+
|
|
557
|
+
This method works with WebDriver, Playwright, Puppeteer, Appium helpers.
|
|
558
|
+
|
|
559
|
+
Function parameter `el` represents a matched element.
|
|
560
|
+
Depending on a helper API of `el` can be different. Refer to API of corresponding browser testing engine for a complete API list:
|
|
561
|
+
|
|
562
|
+
- [Playwright ElementHandle][5]
|
|
563
|
+
- [Puppeteer][6]
|
|
564
|
+
- [webdriverio element][7]
|
|
565
|
+
|
|
566
|
+
#### Configuration
|
|
567
|
+
|
|
568
|
+
- `registerGlobal` - to register `eachElement` function globally, true by default
|
|
569
|
+
|
|
570
|
+
If `registerGlobal` is false you can use eachElement from the plugin:
|
|
571
|
+
|
|
572
|
+
```js
|
|
573
|
+
const eachElement = codeceptjs.container.plugins('eachElement');
|
|
574
|
+
```
|
|
575
|
+
|
|
576
|
+
### Parameters
|
|
577
|
+
|
|
578
|
+
- `purpose` **[string][8]**
|
|
579
|
+
- `locator` **CodeceptJS.LocatorOrString**
|
|
580
|
+
- `fn` **[Function][9]**
|
|
581
|
+
|
|
582
|
+
Returns **([Promise][10]<any> | [undefined][11])**
|
|
583
|
+
|
|
504
584
|
## fakerTransform
|
|
505
585
|
|
|
506
|
-
Use the [faker.js][
|
|
586
|
+
Use the [faker.js][12] package to generate fake data inside examples on your gherkin tests
|
|
507
587
|
|
|
508
|
-
![Faker.js][
|
|
588
|
+
![Faker.js][13]
|
|
509
589
|
|
|
510
590
|
#### Usage
|
|
511
591
|
|
|
@@ -543,7 +623,7 @@ Scenario Outline: ...
|
|
|
543
623
|
|
|
544
624
|
## pauseOnFail
|
|
545
625
|
|
|
546
|
-
Automatically launches [interactive pause][
|
|
626
|
+
Automatically launches [interactive pause][14] when a test fails.
|
|
547
627
|
|
|
548
628
|
Useful for debugging flaky tests on local environment.
|
|
549
629
|
Add this plugin to config file:
|
|
@@ -726,14 +806,14 @@ Possible config options:
|
|
|
726
806
|
|
|
727
807
|
## selenoid
|
|
728
808
|
|
|
729
|
-
[Selenoid][
|
|
809
|
+
[Selenoid][15] plugin automatically starts browsers and video recording.
|
|
730
810
|
Works with WebDriver helper.
|
|
731
811
|
|
|
732
812
|
### Prerequisite
|
|
733
813
|
|
|
734
814
|
This plugin **requires Docker** to be installed.
|
|
735
815
|
|
|
736
|
-
> If you have issues starting Selenoid with this plugin consider using the official [Configuration Manager][
|
|
816
|
+
> If you have issues starting Selenoid with this plugin consider using the official [Configuration Manager][16] tool from Selenoid
|
|
737
817
|
|
|
738
818
|
### Usage
|
|
739
819
|
|
|
@@ -762,7 +842,7 @@ plugins: {
|
|
|
762
842
|
}
|
|
763
843
|
```
|
|
764
844
|
|
|
765
|
-
When `autoCreate` is enabled it will pull the [latest Selenoid from DockerHub][
|
|
845
|
+
When `autoCreate` is enabled it will pull the [latest Selenoid from DockerHub][17] and start Selenoid automatically.
|
|
766
846
|
It will also create `browsers.json` file required by Selenoid.
|
|
767
847
|
|
|
768
848
|
In automatic mode the latest version of browser will be used for tests. It is recommended to specify exact version of each browser inside `browsers.json` file.
|
|
@@ -774,10 +854,10 @@ In automatic mode the latest version of browser will be used for tests. It is re
|
|
|
774
854
|
While this plugin can create containers for you for better control it is recommended to create and launch containers manually.
|
|
775
855
|
This is especially useful for Continous Integration server as you can configure scaling for Selenoid containers.
|
|
776
856
|
|
|
777
|
-
> Use [Selenoid Configuration Manager][
|
|
857
|
+
> Use [Selenoid Configuration Manager][16] to create and start containers semi-automatically.
|
|
778
858
|
|
|
779
859
|
1. Create `browsers.json` file in the same directory `codecept.conf.js` is located
|
|
780
|
-
[Refer to Selenoid documentation][
|
|
860
|
+
[Refer to Selenoid documentation][18] to know more about browsers.json.
|
|
781
861
|
|
|
782
862
|
_Sample browsers.json_
|
|
783
863
|
|
|
@@ -802,7 +882,7 @@ _Sample browsers.json_
|
|
|
802
882
|
|
|
803
883
|
2. Create Selenoid container
|
|
804
884
|
|
|
805
|
-
Run the following command to create a container. To know more [refer here][
|
|
885
|
+
Run the following command to create a container. To know more [refer here][19]
|
|
806
886
|
|
|
807
887
|
```bash
|
|
808
888
|
docker create \
|
|
@@ -835,7 +915,7 @@ When `allure` plugin is enabled a video is attached to report automatically.
|
|
|
835
915
|
| enableVideo | Enable video recording and use `video` folder of output (default: false) |
|
|
836
916
|
| enableLog | Enable log recording and use `logs` folder of output (default: false) |
|
|
837
917
|
| deletePassed | Delete video and logs of passed tests (default : true) |
|
|
838
|
-
| additionalParams | example: `additionalParams: '--env TEST=test'` [Refer here][
|
|
918
|
+
| additionalParams | example: `additionalParams: '--env TEST=test'` [Refer here][20] to know more |
|
|
839
919
|
|
|
840
920
|
### Parameters
|
|
841
921
|
|
|
@@ -843,7 +923,7 @@ When `allure` plugin is enabled a video is attached to report automatically.
|
|
|
843
923
|
|
|
844
924
|
## stepByStepReport
|
|
845
925
|
|
|
846
|
-
![step-by-step-report][
|
|
926
|
+
![step-by-step-report][21]
|
|
847
927
|
|
|
848
928
|
Generates step by step report for a test.
|
|
849
929
|
After each step in a test a screenshot is created. After test executed screenshots are combined into slideshow.
|
|
@@ -898,7 +978,7 @@ Run tests with plugin enabled:
|
|
|
898
978
|
#### Configuration:
|
|
899
979
|
|
|
900
980
|
- `timeout` - global step timeout, default 150 seconds
|
|
901
|
-
- `
|
|
981
|
+
- `overrideStepLimits` - whether to use timeouts set in plugin config to override step timeouts set in code with I.limitTime(x).action(...), default false
|
|
902
982
|
- `noTimeoutSteps` - an array of steps with no timeout. Default:
|
|
903
983
|
|
|
904
984
|
- `amOnPage`
|
|
@@ -915,7 +995,7 @@ Run tests with plugin enabled:
|
|
|
915
995
|
plugins: {
|
|
916
996
|
stepTimeout: {
|
|
917
997
|
enabled: true,
|
|
918
|
-
|
|
998
|
+
overrideStepLimits: true,
|
|
919
999
|
noTimeoutSteps: [
|
|
920
1000
|
'scroll*', // ignore all scroll steps
|
|
921
1001
|
/Cookie/, // ignore all steps with a Cookie in it (by regexp)
|
|
@@ -981,18 +1061,22 @@ Use this plugin if:
|
|
|
981
1061
|
|
|
982
1062
|
#### Multiple Conditional Assertions
|
|
983
1063
|
|
|
1064
|
+
````js
|
|
1065
|
+
Add assert requires first:
|
|
984
1066
|
```js
|
|
1067
|
+
const assert = require('assert');
|
|
1068
|
+
````
|
|
1069
|
+
|
|
1070
|
+
Then use the assert:
|
|
985
1071
|
const result1 = await tryTo(() => I.see('Hello, user'));
|
|
986
1072
|
const result2 = await tryTo(() => I.seeElement('.welcome'));
|
|
987
1073
|
assert.ok(result1 && result2, 'Assertions were not succesful');
|
|
988
|
-
```
|
|
989
1074
|
|
|
990
|
-
##### Optional click
|
|
1075
|
+
##### Optional click
|
|
991
1076
|
|
|
992
|
-
```js
|
|
993
|
-
I.amOnPage('/');
|
|
994
|
-
tryTo(() => I.click('Agree', '.cookies'));
|
|
995
|
-
```
|
|
1077
|
+
```js
|
|
1078
|
+
I.amOnPage('/');
|
|
1079
|
+
tryTo(() => I.click('Agree', '.cookies'));
|
|
996
1080
|
|
|
997
1081
|
#### Configuration
|
|
998
1082
|
|
|
@@ -1020,7 +1104,7 @@ This plugin allows to run webdriverio services like:
|
|
|
1020
1104
|
- browserstack
|
|
1021
1105
|
- appium
|
|
1022
1106
|
|
|
1023
|
-
A complete list of all available services can be found on [webdriverio website][
|
|
1107
|
+
A complete list of all available services can be found on [webdriverio website][22].
|
|
1024
1108
|
|
|
1025
1109
|
#### Setup
|
|
1026
1110
|
|
|
@@ -1032,7 +1116,7 @@ See examples below:
|
|
|
1032
1116
|
|
|
1033
1117
|
#### Selenium Standalone Service
|
|
1034
1118
|
|
|
1035
|
-
Install `@wdio/selenium-standalone-service` package, as [described here][
|
|
1119
|
+
Install `@wdio/selenium-standalone-service` package, as [described here][23].
|
|
1036
1120
|
It is important to make sure it is compatible with current webdriverio version.
|
|
1037
1121
|
|
|
1038
1122
|
Enable `wdio` plugin in plugins list and add `selenium-standalone` service:
|
|
@@ -1051,7 +1135,7 @@ Please note, this service can be used with Protractor helper as well!
|
|
|
1051
1135
|
|
|
1052
1136
|
#### Sauce Service
|
|
1053
1137
|
|
|
1054
|
-
Install `@wdio/sauce-service` package, as [described here][
|
|
1138
|
+
Install `@wdio/sauce-service` package, as [described here][24].
|
|
1055
1139
|
It is important to make sure it is compatible with current webdriverio version.
|
|
1056
1140
|
|
|
1057
1141
|
Enable `wdio` plugin in plugins list and add `sauce` service:
|
|
@@ -1085,30 +1169,46 @@ In the same manner additional services from webdriverio can be installed, enable
|
|
|
1085
1169
|
|
|
1086
1170
|
[2]: https://github.com/allure-framework/allure2/blob/master/plugins/screen-diff-plugin/README.md
|
|
1087
1171
|
|
|
1088
|
-
[3]: https://
|
|
1172
|
+
[3]: https://user-images.githubusercontent.com/63167966/139339384-e6e70a62-3638-406d-a224-f32473071428.png
|
|
1173
|
+
|
|
1174
|
+
[4]: https://codecept.io/locators#custom-locators
|
|
1175
|
+
|
|
1176
|
+
[5]: https://playwright.dev/docs/api/class-elementhandle
|
|
1177
|
+
|
|
1178
|
+
[6]: https://pptr.dev/#?product=Puppeteer&show=api-class-elementhandle
|
|
1179
|
+
|
|
1180
|
+
[7]: https://webdriver.io/docs/api
|
|
1181
|
+
|
|
1182
|
+
[8]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
|
|
1183
|
+
|
|
1184
|
+
[9]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function
|
|
1185
|
+
|
|
1186
|
+
[10]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise
|
|
1187
|
+
|
|
1188
|
+
[11]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined
|
|
1089
1189
|
|
|
1090
|
-
[
|
|
1190
|
+
[12]: https://www.npmjs.com/package/faker
|
|
1091
1191
|
|
|
1092
|
-
[
|
|
1192
|
+
[13]: https://raw.githubusercontent.com/Marak/faker.js/master/logo.png
|
|
1093
1193
|
|
|
1094
|
-
[
|
|
1194
|
+
[14]: /basics/#pause
|
|
1095
1195
|
|
|
1096
|
-
[
|
|
1196
|
+
[15]: https://aerokube.com/selenoid/
|
|
1097
1197
|
|
|
1098
|
-
[
|
|
1198
|
+
[16]: https://aerokube.com/cm/latest/
|
|
1099
1199
|
|
|
1100
|
-
[
|
|
1200
|
+
[17]: https://hub.docker.com/u/selenoid
|
|
1101
1201
|
|
|
1102
|
-
[
|
|
1202
|
+
[18]: https://aerokube.com/selenoid/latest/#_prepare_configuration
|
|
1103
1203
|
|
|
1104
|
-
[
|
|
1204
|
+
[19]: https://aerokube.com/selenoid/latest/#_option_2_start_selenoid_container
|
|
1105
1205
|
|
|
1106
|
-
[
|
|
1206
|
+
[20]: https://docs.docker.com/engine/reference/commandline/create/
|
|
1107
1207
|
|
|
1108
|
-
[
|
|
1208
|
+
[21]: https://codecept.io/img/codeceptjs-slideshow.gif
|
|
1109
1209
|
|
|
1110
|
-
[
|
|
1210
|
+
[22]: https://webdriver.io
|
|
1111
1211
|
|
|
1112
|
-
[
|
|
1212
|
+
[23]: https://webdriver.io/docs/selenium-standalone-service.html
|
|
1113
1213
|
|
|
1114
|
-
[
|
|
1214
|
+
[24]: https://webdriver.io/docs/sauce-service.html
|
package/docs/puppeteer.md
CHANGED
|
@@ -31,7 +31,7 @@ To start you need CodeceptJS with Puppeteer packages installed
|
|
|
31
31
|
npm install codeceptjs puppeteer --save
|
|
32
32
|
```
|
|
33
33
|
|
|
34
|
-
Or see [alternative installation options](
|
|
34
|
+
Or see [alternative installation options](https://codecept.io/installation/)
|
|
35
35
|
|
|
36
36
|
> If you already have CodeceptJS project, just install `puppeteer` package and enable a helper it in config.
|
|
37
37
|
|
|
@@ -80,7 +80,7 @@ By default it is set to `domcontentloaded` which waits for `DOMContentLoaded` ev
|
|
|
80
80
|
When a test runs faster than application it is recommended to increase `waitForAction` config value.
|
|
81
81
|
It will wait for a small amount of time (100ms) by default after each user action is taken.
|
|
82
82
|
|
|
83
|
-
> ▶ More options are listed in [helper reference](
|
|
83
|
+
> ▶ More options are listed in [helper reference](https://codecept.io/helpers/Puppeteer/).
|
|
84
84
|
|
|
85
85
|
## Writing Tests
|
|
86
86
|
|
|
@@ -105,12 +105,11 @@ Tests consist with a scenario of user's action taken on a page. The most widely
|
|
|
105
105
|
* `see`, `dontSee` - to check for a text on a page
|
|
106
106
|
* `seeElement`, `dontSeeElement` - to check for elements on a page
|
|
107
107
|
|
|
108
|
-
> ℹ All actions are listed in [Puppeteer helper reference](
|
|
108
|
+
> ℹ All actions are listed in [Puppeteer helper reference](https://codecept.io/helpers/Puppeteer/).*
|
|
109
109
|
|
|
110
110
|
All actions which interact with elements **support CSS and XPath locators**. Actions like `click` or `fillField` by locate elements by their name or value on a page:
|
|
111
111
|
|
|
112
112
|
```js
|
|
113
|
-
|
|
114
113
|
// search for link or button
|
|
115
114
|
I.click('Login');
|
|
116
115
|
// locate field by its label
|
|
@@ -172,8 +171,10 @@ If you need to get element's value inside a test you can use `grab*` methods. Th
|
|
|
172
171
|
```js
|
|
173
172
|
const assert = require('assert');
|
|
174
173
|
Scenario('get value of current tasks', async ({ I }) => {
|
|
175
|
-
I.
|
|
176
|
-
I.
|
|
174
|
+
I.fillField('.todo', 'my first item');
|
|
175
|
+
I.pressKey('Enter')
|
|
176
|
+
I.fillField('.todo', 'my second item');
|
|
177
|
+
I.pressKey('Enter')
|
|
177
178
|
let numTodos = await I.grabTextFrom('.todo-count strong');
|
|
178
179
|
assert.equal(2, numTodos);
|
|
179
180
|
});
|
|
@@ -185,20 +186,35 @@ In case some actions should be taken inside one element (a container or modal wi
|
|
|
185
186
|
Please take a note that you can't use within inside another within in Puppeteer helper:
|
|
186
187
|
|
|
187
188
|
```js
|
|
188
|
-
within('.todoapp', () => {
|
|
189
|
-
I.
|
|
189
|
+
await within('.todoapp', () => {
|
|
190
|
+
I.fillField('.todo', 'my new item');
|
|
191
|
+
I.pressKey('Enter')
|
|
190
192
|
I.see('1 item left', '.todo-count');
|
|
191
193
|
I.click('.todo-list input.toggle');
|
|
192
194
|
});
|
|
193
195
|
I.see('0 items left', '.todo-count');
|
|
194
196
|
```
|
|
195
197
|
|
|
196
|
-
|
|
198
|
+
### Each Element <Badge text="Since 3.3" type="warning"/>
|
|
199
|
+
|
|
200
|
+
Usually, CodeceptJS performs an action on the first matched element.
|
|
201
|
+
In case you want to do an action on each element found, use the special function `eachElement` which comes from [eachElement](https://codecept.io/plugins/#eachelement) plugin.
|
|
202
|
+
|
|
203
|
+
`eachElement` function matches all elements by locator and performs a callback on each of those element. A callback function receives [ElementHandle instance](https://pptr.dev/#?product=Puppeteer&show=api-class-elementhandle) from Puppeteer API. `eachElement` may perform arbitrary actions on a page, so the first argument should by a description of the actions performed. This description will be used for logging purposes.
|
|
197
204
|
|
|
198
|
-
|
|
205
|
+
Usage example
|
|
199
206
|
|
|
200
|
-
|
|
207
|
+
```js
|
|
208
|
+
await eachElement(
|
|
209
|
+
'click all checkboxes',
|
|
210
|
+
'input.custom-checkbox',
|
|
211
|
+
async (el, index) => {
|
|
212
|
+
await el.click();
|
|
213
|
+
});
|
|
214
|
+
);
|
|
215
|
+
```
|
|
201
216
|
|
|
217
|
+
> ℹ Learn more about [eachElement plugin](/plugins/#eachelement)
|
|
202
218
|
|
|
203
219
|
## Mocking Requests
|
|
204
220
|
|
|
@@ -297,4 +313,4 @@ async renderPageToPdf() {
|
|
|
297
313
|
|
|
298
314
|
The same way you can also access `browser` object to implement more actions or handle events.
|
|
299
315
|
|
|
300
|
-
> [▶ Learn more about Helpers](
|
|
316
|
+
> [▶ Learn more about Helpers](https://codecept.io/helpers/)
|
package/docs/quickstart.md
CHANGED
|
@@ -37,9 +37,6 @@ TestCafe provides cross-browser support without Selenium. TestCafe tests are fas
|
|
|
37
37
|
|
|
38
38
|
# Quickstart
|
|
39
39
|
|
|
40
|
-
> CodeceptJS supports various engines for running browser tests. By default we recommend using **Playwright** which is cross-browser and performant solution.
|
|
41
|
-
|
|
42
|
-
|
|
43
40
|
|
|
44
41
|
Use [CodeceptJS all-in-one installer](https://github.com/codeceptjs/create-codeceptjs) to get CodeceptJS, a demo project, and Playwright.
|
|
45
42
|
|
|
@@ -47,6 +44,8 @@ Use [CodeceptJS all-in-one installer](https://github.com/codeceptjs/create-codec
|
|
|
47
44
|
npx create-codeceptjs .
|
|
48
45
|
```
|
|
49
46
|
|
|
47
|
+
If you prefer not to use Playwright see other [installation options](/installation/).
|
|
48
|
+
|
|
50
49
|

|
|
51
50
|
|
|
52
51
|
> To install codeceptjs into a different folder, like `tests` use `npx create-codeceptjs tests`
|
package/docs/reports.md
CHANGED
|
@@ -141,11 +141,52 @@ npx codecepjs dry-run --debug
|
|
|
141
141
|
|
|
142
142
|
> ℹ If you use custom JavaScript code inside tests, or rely on values from `grab*` commands, dry-run may produce error output.
|
|
143
143
|
|
|
144
|
+
|
|
145
|
+
## Testomat.io
|
|
146
|
+
|
|
147
|
+
[Testomat.io](https://testomat.io) is a modern test management tool focused on CodeceptJS and **created by CodeceptJS team**.
|
|
148
|
+
Testomat.io is commercial SaaS service that can receive run reports from local runs or CI. Out of box Testomat.io supports parallel runs, uploading of screenshots and videos.
|
|
149
|
+
|
|
150
|
+

|
|
151
|
+
|
|
152
|
+
> 😻 **Testomat.io is free** for small teams, so you can use its reporting features with CodeceptJS.
|
|
153
|
+
|
|
154
|
+
To receive run reports you should:
|
|
155
|
+
|
|
156
|
+
* [Sign up](https://app.testomat.io/users/sign_up) at Testomat.io
|
|
157
|
+
* Create a new "Classical" project (select "BDD" project if you use CodeceptJS in BDD mode)
|
|
158
|
+
* Select "Import from Source Code"
|
|
159
|
+
* Select "CodeceptJS" as testing framework and JavaScript or TypeScript as a language. If you use BDD select "Gherkin" as language.
|
|
160
|
+
* Execute provided command in a terminal with your project. This will be "check-tests" or "check-cucmber" command. It scans all your test files and imports them into Testomat.io. This way all your e2e tests will be visible in one UI.
|
|
161
|
+
* After tests are imported, go to Runs tab and select "Setup automated tests".
|
|
162
|
+
* Follow the instructions:
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+

|
|
166
|
+
|
|
167
|
+
* You will need to install `@testomatio/reporter` package and enable it as a plugin in codeceptjs config:
|
|
168
|
+
|
|
169
|
+
```js
|
|
170
|
+
plugins: {
|
|
171
|
+
testomatio: {
|
|
172
|
+
enabled: true,
|
|
173
|
+
require: '@testomatio/reporter/lib/adapter/codecept',
|
|
174
|
+
apiKey: process.env.TESTOMATIO,
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
* Run tests with `TESTOMATIO=` env variable and API key provided by Testomat.io
|
|
180
|
+
* See the run report is created and updated in realtime.
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
[Testomat.io](https://testomat.io) reporter works in the cloud, so it doesn't require you to install additional software. It can be integrated with your CI service to rerun only failed tests, launch new runs from UI, and send report notifications by email or in Slack, MS Teams, or create issue in Jira.
|
|
184
|
+
|
|
185
|
+
|
|
144
186
|
## Allure
|
|
145
187
|
|
|
146
|
-
> ℹ We recommend using Allure reports on CI. Allure is one of the best open-source reporters designed to collect and show test reports in nicest way.
|
|
147
188
|
|
|
148
|
-
[Allure reporter](
|
|
189
|
+
[Allure reporter](https://allure.qatools.ru/#) is a tool to store and display test reports.
|
|
149
190
|
It provides nice web UI which contains all important information on test execution.
|
|
150
191
|
CodeceptJS has built-in support for Allure reports. Inside reports you will have all steps, substeps and screenshots.
|
|
151
192
|
|
|
@@ -201,7 +242,7 @@ npx codeceptjs dry-run --debug -p allure
|
|
|
201
242
|
|
|
202
243
|
## ReportPortal
|
|
203
244
|
|
|
204
|
-
|
|
245
|
+
For enterprise grade we reporting we recommend using [ReportPortal](https://reportportal.io).
|
|
205
246
|
|
|
206
247
|

|
|
207
248
|
|
package/docs/testcafe.md
CHANGED
|
@@ -54,7 +54,7 @@ A first test should be created with `codeceptjs gt` command
|
|
|
54
54
|
npx codeceptjs gt
|
|
55
55
|
```
|
|
56
56
|
|
|
57
|
-
In the next example we will [TodoMVC application](
|
|
57
|
+
In the next example we will [TodoMVC application](https://todomvc.com/examples/angularjs/#/). So let's create a test which will fill in todo list:
|
|
58
58
|
|
|
59
59
|
```js
|
|
60
60
|
Feature('TodoMVC');
|
package/docs/translation.md
CHANGED
|
@@ -38,7 +38,7 @@ This way tests can be written in native language while it is still JavaScript:
|
|
|
38
38
|
|
|
39
39
|
```js
|
|
40
40
|
Сценарий('пробую написать реферат', (Я) => {
|
|
41
|
-
Я.на_странице('
|
|
41
|
+
Я.на_странице('https://yandex.ru/referats');
|
|
42
42
|
Я.вижу("Написать реферат по");
|
|
43
43
|
Я.выбираю_опцию('Психологии');
|
|
44
44
|
Я.кликаю("Написать реферат");
|
|
@@ -57,7 +57,7 @@ To write your tests in portuguese you can enable the portuguese translation in c
|
|
|
57
57
|
Now you can write test like this:
|
|
58
58
|
|
|
59
59
|
```js
|
|
60
|
-
|
|
60
|
+
Cenário('Efetuar login', ({ Eu }) => {
|
|
61
61
|
Eu.estouNaPagina('http://minhaAplicacao.com.br');
|
|
62
62
|
Eu.preenchoOCampo("login", "usuario@minhaAplicacao.com.br");
|
|
63
63
|
Eu.preenchoOCampo("senha", "123456");
|
package/docs/videos.md
CHANGED
|
@@ -7,7 +7,7 @@ editLink: false
|
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
> Add your own videos to our [Wiki Page](https://github.com/codeceptjs/CodeceptJS/wiki/Videos)
|
|
10
|
-
[](https://www.youtube.com/watch?v=BRMWstiOTks)
|
|
11
11
|
|
|
12
12
|
## [An Introduction, Getting started and working with CodeceptJS & Puppeteer (EAWeekend)](https://www.youtube.com/watch?v=BRMWstiOTks)
|
|
13
13
|
|
|
@@ -15,7 +15,7 @@ editLink: false
|
|
|
15
15
|
|
|
16
16
|
## [Introductory Videos](https://www.youtube.com/watch?v=FPFG1rBNJ64&list=PLcFXthgti9Lt4SjSvL1ALDg6dOeTC0TvT)
|
|
17
17
|
|
|
18
|
-
Free educational videos provided by our community member **[@ontytoom](
|
|
18
|
+
Free educational videos provided by our community member **[@ontytoom](https://github.com/ontytoom)**.
|
|
19
19
|
|
|
20
20
|
1. [Installation](https://www.youtube.com/watch?v=FPFG1rBNJ64)
|
|
21
21
|
1. [Creating a Test](https://www.youtube.com/watch?v=mdQZjL3h9d0)
|
package/docs/visual.md
CHANGED
|
@@ -58,7 +58,7 @@ Base Image is compared with the screenshot image and test results are derived ba
|
|
|
58
58
|
|
|
59
59
|
### Example
|
|
60
60
|
|
|
61
|
-
Lets consider visual testing for [CodeceptJS Home](
|
|
61
|
+
Lets consider visual testing for [CodeceptJS Home](https://codecept.io)
|
|
62
62
|
|
|
63
63
|
```js
|
|
64
64
|
Feature('To test screen comparison with resemble Js Example test');
|
|
@@ -183,7 +183,7 @@ The first time you run this test a new baseline will be created, and subsequent
|
|
|
183
183
|
|
|
184
184
|
### Example
|
|
185
185
|
|
|
186
|
-
Lets consider visual testing for [CodeceptJS Home](
|
|
186
|
+
Lets consider visual testing for [CodeceptJS Home](https://codecept.io).
|
|
187
187
|
You can also find example repo here: https://github.com/PeterNgTr/codeceptjs-applitoolshelper
|
|
188
188
|
|
|
189
189
|
```js
|
package/docs/vue.md
CHANGED
|
@@ -111,7 +111,7 @@ If you agreed to create a demo component, you will also see `TestMe` component i
|
|
|
111
111
|
* [Learn CodeceptJS basics](/basics)
|
|
112
112
|
* [Learn how to write CodeceptJS tests with Puppeteer](/puppeteer)
|
|
113
113
|
* [See full reference for CodeceptJS Puppeteer Helper](/helpers/Puppeteer)
|
|
114
|
-
* Ask your questions in [Slack](
|
|
114
|
+
* Ask your questions in [Slack](https://bit.ly/chat-codeceptjs) & [Forum](https://codecept.discourse.group/)
|
|
115
115
|
|
|
116
116
|
## Enjoy testing!
|
|
117
117
|
|