codeceptjs 3.4.0 → 3.5.0
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 +70 -0
- package/README.md +9 -7
- package/bin/codecept.js +1 -1
- package/docs/ai.md +246 -0
- package/docs/build/Appium.js +47 -7
- package/docs/build/JSONResponse.js +4 -4
- package/docs/build/Nightmare.js +3 -1
- package/docs/build/OpenAI.js +122 -0
- package/docs/build/Playwright.js +193 -45
- package/docs/build/Protractor.js +3 -1
- package/docs/build/Puppeteer.js +45 -12
- package/docs/build/REST.js +15 -5
- package/docs/build/TestCafe.js +3 -1
- package/docs/build/WebDriver.js +30 -5
- package/docs/changelog.md +70 -0
- package/docs/helpers/Appium.md +152 -147
- package/docs/helpers/JSONResponse.md +4 -4
- package/docs/helpers/Nightmare.md +2 -0
- package/docs/helpers/OpenAI.md +70 -0
- package/docs/helpers/Playwright.md +194 -152
- package/docs/helpers/Puppeteer.md +6 -0
- package/docs/helpers/REST.md +6 -5
- package/docs/helpers/TestCafe.md +2 -0
- package/docs/helpers/WebDriver.md +10 -4
- package/docs/mobile.md +49 -2
- package/docs/parallel.md +56 -0
- package/docs/plugins.md +87 -33
- package/docs/secrets.md +6 -0
- package/docs/tutorial.md +5 -5
- package/docs/webapi/appendField.mustache +2 -0
- package/docs/webapi/type.mustache +3 -0
- package/lib/ai.js +171 -0
- package/lib/cli.js +1 -1
- package/lib/codecept.js +4 -0
- package/lib/command/dryRun.js +9 -1
- package/lib/command/generate.js +46 -3
- package/lib/command/init.js +13 -1
- package/lib/command/interactive.js +15 -1
- package/lib/command/run-workers.js +2 -1
- package/lib/container.js +13 -3
- package/lib/helper/Appium.js +45 -7
- package/lib/helper/JSONResponse.js +4 -4
- package/lib/helper/Nightmare.js +1 -1
- package/lib/helper/OpenAI.js +122 -0
- package/lib/helper/Playwright.js +190 -38
- package/lib/helper/Protractor.js +1 -1
- package/lib/helper/Puppeteer.js +40 -12
- package/lib/helper/REST.js +15 -5
- package/lib/helper/TestCafe.js +1 -1
- package/lib/helper/WebDriver.js +25 -5
- package/lib/helper/scripts/highlightElement.js +20 -0
- package/lib/html.js +258 -0
- package/lib/listener/retry.js +2 -1
- package/lib/pause.js +73 -17
- package/lib/plugin/debugErrors.js +67 -0
- package/lib/plugin/fakerTransform.js +4 -6
- package/lib/plugin/heal.js +179 -0
- package/lib/plugin/screenshotOnFail.js +11 -2
- package/lib/plugin/wdio.js +4 -12
- package/lib/recorder.js +4 -4
- package/lib/scenario.js +6 -4
- package/lib/secret.js +5 -4
- package/lib/step.js +6 -1
- package/lib/ui.js +4 -3
- package/lib/utils.js +4 -0
- package/lib/workers.js +57 -9
- package/package.json +26 -14
- package/translations/ja-JP.js +9 -9
- package/typings/index.d.ts +43 -9
- package/typings/promiseBasedTypes.d.ts +124 -24
- package/typings/types.d.ts +138 -30
|
@@ -56,6 +56,7 @@ Type: [object][4]
|
|
|
56
56
|
- `manualStart` **[boolean][17]?** do not start browser before a test, start it manually inside a helper with `this.helpers["Puppeteer"]._startBrowser()`.
|
|
57
57
|
- `browser` **[string][6]?** can be changed to `firefox` when using [puppeteer-firefox][2].
|
|
58
58
|
- `chrome` **[object][4]?** pass additional [Puppeteer run options][22].
|
|
59
|
+
- `highlightElement` **[boolean][17]?** highlight the interacting elements
|
|
59
60
|
|
|
60
61
|
|
|
61
62
|
|
|
@@ -296,6 +297,8 @@ Field is located by name, label, CSS or XPath
|
|
|
296
297
|
|
|
297
298
|
```js
|
|
298
299
|
I.appendField('#myTextField', 'appended');
|
|
300
|
+
// typing secret
|
|
301
|
+
I.appendField('password', secret('123456'));
|
|
299
302
|
```
|
|
300
303
|
|
|
301
304
|
#### Parameters
|
|
@@ -1786,6 +1789,9 @@ I.type('4141555311111111', 100);
|
|
|
1786
1789
|
|
|
1787
1790
|
// passing in an array
|
|
1788
1791
|
I.type(['T', 'E', 'X', 'T']);
|
|
1792
|
+
|
|
1793
|
+
// passing a secret
|
|
1794
|
+
I.type(secret('123456'));
|
|
1789
1795
|
```
|
|
1790
1796
|
|
|
1791
1797
|
#### Parameters
|
package/docs/helpers/REST.md
CHANGED
|
@@ -41,7 +41,8 @@ Type: [object][4]
|
|
|
41
41
|
endpoint: 'http://site.com/api',
|
|
42
42
|
prettyPrintJson: true,
|
|
43
43
|
onRequest: (request) => {
|
|
44
|
-
|
|
44
|
+
request.headers.auth = '123';
|
|
45
|
+
}
|
|
45
46
|
}
|
|
46
47
|
}
|
|
47
48
|
}
|
|
@@ -114,7 +115,7 @@ I.sendDeleteRequest('/api/users/1');
|
|
|
114
115
|
#### Parameters
|
|
115
116
|
|
|
116
117
|
- `url` **any**
|
|
117
|
-
- `headers` **[object][4]** the headers object to be sent. By default it is sent as an empty object
|
|
118
|
+
- `headers` **[object][4]** the headers object to be sent. By default, it is sent as an empty object
|
|
118
119
|
|
|
119
120
|
Returns **[Promise][2]<any>** response
|
|
120
121
|
|
|
@@ -129,7 +130,7 @@ I.sendGetRequest('/api/users.json');
|
|
|
129
130
|
#### Parameters
|
|
130
131
|
|
|
131
132
|
- `url` **any**
|
|
132
|
-
- `headers` **[object][4]** the headers object to be sent. By default it is sent as an empty object
|
|
133
|
+
- `headers` **[object][4]** the headers object to be sent. By default, it is sent as an empty object
|
|
133
134
|
|
|
134
135
|
Returns **[Promise][2]<any>** response
|
|
135
136
|
|
|
@@ -166,8 +167,8 @@ I.sendPostRequest('/api/users.json', secret({ "email": "user@user.com" }));
|
|
|
166
167
|
#### Parameters
|
|
167
168
|
|
|
168
169
|
- `url` **any**
|
|
169
|
-
- `payload` **any** the payload to be sent. By default it is sent as an empty object
|
|
170
|
-
- `headers` **[object][4]** the headers object to be sent. By default it is sent as an empty object
|
|
170
|
+
- `payload` **any** the payload to be sent. By default, it is sent as an empty object
|
|
171
|
+
- `headers` **[object][4]** the headers object to be sent. By default, it is sent as an empty object
|
|
171
172
|
|
|
172
173
|
Returns **[Promise][2]<any>** response
|
|
173
174
|
|
package/docs/helpers/TestCafe.md
CHANGED
|
@@ -27,7 +27,7 @@ Type: [object][16]
|
|
|
27
27
|
### Properties
|
|
28
28
|
|
|
29
29
|
- `url` **[string][17]** base url of website to be tested.
|
|
30
|
-
- `browser` **[string][17]**
|
|
30
|
+
- `browser` **[string][17]** Browser in which to perform testing.
|
|
31
31
|
- `basicAuth` **[string][17]?** (optional) the basic authentication to pass to base url. Example: {username: 'username', password: 'password'}
|
|
32
32
|
- `host` **[string][17]?** WebDriver host to connect.
|
|
33
33
|
- `port` **[number][20]?** WebDriver port to connect.
|
|
@@ -45,6 +45,7 @@ Type: [object][16]
|
|
|
45
45
|
- `desiredCapabilities` **[object][16]?** Selenium's [desired capabilities][6].
|
|
46
46
|
- `manualStart` **[boolean][29]?** do not start browser before a test, start it manually inside a helper with `this.helpers["WebDriver"]._startBrowser()`.
|
|
47
47
|
- `timeouts` **[object][16]?** [WebDriver timeouts][34] defined as hash.
|
|
48
|
+
- `highlightElement` **[boolean][29]?** highlight the interacting elements
|
|
48
49
|
|
|
49
50
|
|
|
50
51
|
|
|
@@ -382,7 +383,7 @@ this.helpers['WebDriver']._locate({name: 'password'}).then //...
|
|
|
382
383
|
|
|
383
384
|
### _locateCheckable
|
|
384
385
|
|
|
385
|
-
Find a checkbox by providing human
|
|
386
|
+
Find a checkbox by providing human-readable text:
|
|
386
387
|
|
|
387
388
|
```js
|
|
388
389
|
this.helpers['WebDriver']._locateCheckable('I agree with terms and conditions').then // ...
|
|
@@ -394,7 +395,7 @@ this.helpers['WebDriver']._locateCheckable('I agree with terms and conditions').
|
|
|
394
395
|
|
|
395
396
|
### _locateClickable
|
|
396
397
|
|
|
397
|
-
Find a clickable element by providing human
|
|
398
|
+
Find a clickable element by providing human-readable text:
|
|
398
399
|
|
|
399
400
|
```js
|
|
400
401
|
const els = await this.helpers.WebDriver._locateClickable('Next page');
|
|
@@ -408,7 +409,7 @@ const els = await this.helpers.WebDriver._locateClickable('Next page', '.pages')
|
|
|
408
409
|
|
|
409
410
|
### _locateFields
|
|
410
411
|
|
|
411
|
-
Find field elements by providing human
|
|
412
|
+
Find field elements by providing human-readable text:
|
|
412
413
|
|
|
413
414
|
```js
|
|
414
415
|
this.helpers['WebDriver']._locateFields('Your email').then // ...
|
|
@@ -464,6 +465,8 @@ Field is located by name, label, CSS or XPath
|
|
|
464
465
|
|
|
465
466
|
```js
|
|
466
467
|
I.appendField('#myTextField', 'appended');
|
|
468
|
+
// typing secret
|
|
469
|
+
I.appendField('password', secret('123456'));
|
|
467
470
|
```
|
|
468
471
|
|
|
469
472
|
#### Parameters
|
|
@@ -1985,6 +1988,9 @@ I.type('4141555311111111', 100);
|
|
|
1985
1988
|
|
|
1986
1989
|
// passing in an array
|
|
1987
1990
|
I.type(['T', 'E', 'X', 'T']);
|
|
1991
|
+
|
|
1992
|
+
// passing a secret
|
|
1993
|
+
I.type(secret('123456'));
|
|
1988
1994
|
```
|
|
1989
1995
|
|
|
1990
1996
|
#### Parameters
|
package/docs/mobile.md
CHANGED
|
@@ -45,22 +45,69 @@ To install Appium use npm:
|
|
|
45
45
|
npm i -g appium
|
|
46
46
|
```
|
|
47
47
|
|
|
48
|
+
To use Appium 2.x:
|
|
49
|
+
```sh
|
|
50
|
+
npm i -g appium@next
|
|
51
|
+
```
|
|
52
|
+
Appium 2x (still beta) reenvisions Appium as a platform where “drivers” and “plugins” can be easily created and shared independently.
|
|
53
|
+
Install an Appium driver and its dependencies
|
|
54
|
+
To install the Appium driver and its dependencies, we'll be using the uiautomator2 (Android), XCUITest (iOS) drivers.
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
appium driver install xcuitest
|
|
58
|
+
appium driver install uiautomator2
|
|
59
|
+
```
|
|
60
|
+
To make sure that all the drivers are installed successfully, run the following command:
|
|
61
|
+
|
|
62
|
+
```
|
|
63
|
+
appium driver list
|
|
64
|
+
|
|
65
|
+
tth~$appium driver list
|
|
66
|
+
✔ Listing available drivers
|
|
67
|
+
- espresso@2.17.0 [installed (NPM)]
|
|
68
|
+
- uiautomator2@2.12.6 [installed (NPM)]
|
|
69
|
+
- xcuitest@4.19.1 [installed (NPM)]
|
|
70
|
+
- mac2 [not installed]
|
|
71
|
+
- safari [not installed]
|
|
72
|
+
- gecko [not installed]
|
|
73
|
+
- chromium [not installed]
|
|
74
|
+
```
|
|
75
|
+
|
|
48
76
|
Then you need to prepare application for execution.
|
|
49
77
|
It should be packed into apk (for Android) or .ipa (for iOS) or zip.
|
|
50
78
|
|
|
51
|
-
Next, is to launch the emulator or connect physical device.
|
|
79
|
+
Next, is to launch the emulator or connect a physical device.
|
|
52
80
|
Once they are prepared, launch Appium:
|
|
53
81
|
|
|
54
82
|
```sh
|
|
55
83
|
appium
|
|
56
84
|
```
|
|
57
85
|
|
|
86
|
+
To use Appium 2.x:
|
|
87
|
+
```sh
|
|
88
|
+
tth~$npx appium --base-path=/wd/hub
|
|
89
|
+
[Appium] Welcome to Appium v2.0.0-beta.57 (REV 3e675c32ae71dc0b00749d5d29213e2ea5b53c5b)
|
|
90
|
+
[Appium] Non-default server args:
|
|
91
|
+
[Appium] {
|
|
92
|
+
[Appium] basePath: '/wd/hub'
|
|
93
|
+
[Appium] }
|
|
94
|
+
[Appium] Attempting to load driver espresso...
|
|
95
|
+
[debug] [Appium] Requiring driver at /Users/trung-thanh/Desktop/thanh-nguyen/task2/node_modules/appium-espresso-driver
|
|
96
|
+
[Appium] Attempting to load driver uiautomator2...
|
|
97
|
+
[debug] [Appium] Requiring driver at /Users/trung-thanh/Desktop/thanh-nguyen/task2/node_modules/appium-uiautomator2-driver
|
|
98
|
+
[Appium] Appium REST http interface listener started on 0.0.0.0:4723
|
|
99
|
+
[Appium] Available drivers:
|
|
100
|
+
[Appium] - espresso@2.17.0 (automationName 'Espresso')
|
|
101
|
+
[Appium] - uiautomator2@2.12.6 (automationName 'UiAutomator2')
|
|
102
|
+
[Appium] No plugins have been installed. Use the "appium plugin" command to install the one(s) you want to use.
|
|
103
|
+
```
|
|
104
|
+
|
|
58
105
|
To run mobile test you need either an device emulator (available with Android SDK or iOS), real device connected for mobile testing. Alternatively, you may execute Appium with device emulator inside Docker container.
|
|
59
106
|
|
|
60
107
|
CodeceptJS should be installed with webdriverio support:
|
|
61
108
|
|
|
62
109
|
```bash
|
|
63
|
-
npm install codeceptjs webdriverio --save
|
|
110
|
+
npm install codeceptjs webdriverio@8.6.3 --save
|
|
64
111
|
```
|
|
65
112
|
|
|
66
113
|
## Configuring
|
package/docs/parallel.md
CHANGED
|
@@ -32,6 +32,62 @@ By default the tests are assigned one by one to the available workers this may l
|
|
|
32
32
|
npx codeceptjs run-workers --suites 2
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
+
## Parallel Execution by Workers on Multiple Browsers
|
|
36
|
+
|
|
37
|
+
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.
|
|
38
|
+
|
|
39
|
+
Start with modifying the `codecept.conf.js` file. Add multiple key inside the config which will be used to configure multiple profiles.
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
exports.config = {
|
|
43
|
+
helpers: {
|
|
44
|
+
WebDriver: {
|
|
45
|
+
url: 'http://localhost:3000',
|
|
46
|
+
desiredCapabilties: {}
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
multiple: {
|
|
50
|
+
profile1: {
|
|
51
|
+
browsers: [
|
|
52
|
+
{
|
|
53
|
+
browser: "firefox",
|
|
54
|
+
desiredCapabilties: {
|
|
55
|
+
// override capabilties related to firefox
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
browser: "chrome",
|
|
60
|
+
desiredCapabilties: {
|
|
61
|
+
// override capabilties related to chrome
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
]
|
|
65
|
+
},
|
|
66
|
+
profile2: {
|
|
67
|
+
browsers: [
|
|
68
|
+
{
|
|
69
|
+
browser: "safari",
|
|
70
|
+
desiredCapabilties: {
|
|
71
|
+
// override capabilties related to safari
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
]
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
```
|
|
79
|
+
To trigger tests on all the profiles configured, you can use the following command:
|
|
80
|
+
```
|
|
81
|
+
npx codeceptjs run-workers 3 all -c codecept.conf.js
|
|
82
|
+
```
|
|
83
|
+
This will run your tests across all browsers configured from profile1 & profile2 on 3 workers.
|
|
84
|
+
|
|
85
|
+
To trigger tests on specific profile, you can use the following command:
|
|
86
|
+
```
|
|
87
|
+
npx codeceptjs run-workers 2 profile1 -c codecept.conf.js
|
|
88
|
+
```
|
|
89
|
+
This will run your tests across 2 browsers from profile1 on 2 workers.
|
|
90
|
+
|
|
35
91
|
## Custom Parallel Execution
|
|
36
92
|
|
|
37
93
|
To get a full control of parallelization create a custom execution script to match your needs.
|
package/docs/plugins.md
CHANGED
|
@@ -479,6 +479,30 @@ I.click('=sign-up'); // matches => [data-qa=sign-up],[data-test=sign-up]
|
|
|
479
479
|
|
|
480
480
|
- `config`
|
|
481
481
|
|
|
482
|
+
## debugErrors
|
|
483
|
+
|
|
484
|
+
Prints errors found in HTML code after each failed test.
|
|
485
|
+
|
|
486
|
+
It scans HTML and searches for elements with error classes.
|
|
487
|
+
If an element found prints a text from it to console and adds as artifact to the test.
|
|
488
|
+
|
|
489
|
+
Enable this plugin in config:
|
|
490
|
+
|
|
491
|
+
```js
|
|
492
|
+
plugins: {
|
|
493
|
+
debugErrors: {
|
|
494
|
+
enabled: true,
|
|
495
|
+
}
|
|
496
|
+
```
|
|
497
|
+
|
|
498
|
+
Additional config options:
|
|
499
|
+
|
|
500
|
+
- `errorClasses` - list of classes to search for errors (default: `['error', 'warning', 'alert', 'danger']`)
|
|
501
|
+
|
|
502
|
+
### Parameters
|
|
503
|
+
|
|
504
|
+
- `config` (optional, default `{}`)
|
|
505
|
+
|
|
482
506
|
## eachElement
|
|
483
507
|
|
|
484
508
|
Provides `eachElement` global function to iterate over found elements to perform actions on them.
|
|
@@ -546,17 +570,15 @@ Returns **([Promise][7]<any> | [undefined][8])**
|
|
|
546
570
|
|
|
547
571
|
## fakerTransform
|
|
548
572
|
|
|
549
|
-
Use the
|
|
550
|
-
|
|
551
|
-
![Faker.js][10]
|
|
573
|
+
Use the `@faker-js/faker` package to generate fake data inside examples on your gherkin tests
|
|
552
574
|
|
|
553
575
|
#### Usage
|
|
554
576
|
|
|
555
|
-
To start please install
|
|
577
|
+
To start please install `@faker-js/faker` package
|
|
556
578
|
|
|
557
|
-
npm install -D faker
|
|
579
|
+
npm install -D @faker-js/faker
|
|
558
580
|
|
|
559
|
-
yarn add -D faker
|
|
581
|
+
yarn add -D @faker-js/faker
|
|
560
582
|
|
|
561
583
|
Add this plugin to config file:
|
|
562
584
|
|
|
@@ -584,9 +606,45 @@ Scenario Outline: ...
|
|
|
584
606
|
|
|
585
607
|
- `config`
|
|
586
608
|
|
|
609
|
+
## heal
|
|
610
|
+
|
|
611
|
+
Self-healing tests with OpenAI.
|
|
612
|
+
|
|
613
|
+
This plugin is experimental and requires OpenAI API key.
|
|
614
|
+
|
|
615
|
+
To use it you need to set OPENAI_API_KEY env variable and enable plugin inside condig.
|
|
616
|
+
|
|
617
|
+
```js
|
|
618
|
+
plugins: {
|
|
619
|
+
heal: {
|
|
620
|
+
enabled: true,
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
```
|
|
624
|
+
|
|
625
|
+
More config options are available:
|
|
626
|
+
|
|
627
|
+
- `healLimit` - how many steps can be healed in a single test (default: 2)
|
|
628
|
+
- `healSteps` - which steps can be healed (default: all steps that interact with UI, see list below)
|
|
629
|
+
|
|
630
|
+
Steps to heal:
|
|
631
|
+
|
|
632
|
+
- `click`
|
|
633
|
+
- `fillField`
|
|
634
|
+
- `appendField`
|
|
635
|
+
- `selectOption`
|
|
636
|
+
- `attachFile`
|
|
637
|
+
- `checkOption`
|
|
638
|
+
- `uncheckOption`
|
|
639
|
+
- `doubleClick`
|
|
640
|
+
|
|
641
|
+
### Parameters
|
|
642
|
+
|
|
643
|
+
- `config` (optional, default `{}`)
|
|
644
|
+
|
|
587
645
|
## pauseOnFail
|
|
588
646
|
|
|
589
|
-
Automatically launches [interactive pause][
|
|
647
|
+
Automatically launches [interactive pause][9] when a test fails.
|
|
590
648
|
|
|
591
649
|
Useful for debugging flaky tests on local environment.
|
|
592
650
|
Add this plugin to config file:
|
|
@@ -769,14 +827,14 @@ Possible config options:
|
|
|
769
827
|
|
|
770
828
|
## selenoid
|
|
771
829
|
|
|
772
|
-
[Selenoid][
|
|
830
|
+
[Selenoid][10] plugin automatically starts browsers and video recording.
|
|
773
831
|
Works with WebDriver helper.
|
|
774
832
|
|
|
775
833
|
### Prerequisite
|
|
776
834
|
|
|
777
835
|
This plugin **requires Docker** to be installed.
|
|
778
836
|
|
|
779
|
-
> If you have issues starting Selenoid with this plugin consider using the official [Configuration Manager][
|
|
837
|
+
> If you have issues starting Selenoid with this plugin consider using the official [Configuration Manager][11] tool from Selenoid
|
|
780
838
|
|
|
781
839
|
### Usage
|
|
782
840
|
|
|
@@ -805,7 +863,7 @@ plugins: {
|
|
|
805
863
|
}
|
|
806
864
|
```
|
|
807
865
|
|
|
808
|
-
When `autoCreate` is enabled it will pull the [latest Selenoid from DockerHub][
|
|
866
|
+
When `autoCreate` is enabled it will pull the [latest Selenoid from DockerHub][12] and start Selenoid automatically.
|
|
809
867
|
It will also create `browsers.json` file required by Selenoid.
|
|
810
868
|
|
|
811
869
|
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.
|
|
@@ -817,10 +875,10 @@ In automatic mode the latest version of browser will be used for tests. It is re
|
|
|
817
875
|
While this plugin can create containers for you for better control it is recommended to create and launch containers manually.
|
|
818
876
|
This is especially useful for Continous Integration server as you can configure scaling for Selenoid containers.
|
|
819
877
|
|
|
820
|
-
> Use [Selenoid Configuration Manager][
|
|
878
|
+
> Use [Selenoid Configuration Manager][11] to create and start containers semi-automatically.
|
|
821
879
|
|
|
822
880
|
1. Create `browsers.json` file in the same directory `codecept.conf.js` is located
|
|
823
|
-
[Refer to Selenoid documentation][
|
|
881
|
+
[Refer to Selenoid documentation][13] to know more about browsers.json.
|
|
824
882
|
|
|
825
883
|
_Sample browsers.json_
|
|
826
884
|
|
|
@@ -845,7 +903,7 @@ _Sample browsers.json_
|
|
|
845
903
|
|
|
846
904
|
2. Create Selenoid container
|
|
847
905
|
|
|
848
|
-
Run the following command to create a container. To know more [refer here][
|
|
906
|
+
Run the following command to create a container. To know more [refer here][14]
|
|
849
907
|
|
|
850
908
|
```bash
|
|
851
909
|
docker create \
|
|
@@ -878,7 +936,7 @@ When `allure` plugin is enabled a video is attached to report automatically.
|
|
|
878
936
|
| enableVideo | Enable video recording and use `video` folder of output (default: false) |
|
|
879
937
|
| enableLog | Enable log recording and use `logs` folder of output (default: false) |
|
|
880
938
|
| deletePassed | Delete video and logs of passed tests (default : true) |
|
|
881
|
-
| additionalParams | example: `additionalParams: '--env TEST=test'` [Refer here][
|
|
939
|
+
| additionalParams | example: `additionalParams: '--env TEST=test'` [Refer here][15] to know more |
|
|
882
940
|
|
|
883
941
|
### Parameters
|
|
884
942
|
|
|
@@ -886,7 +944,7 @@ When `allure` plugin is enabled a video is attached to report automatically.
|
|
|
886
944
|
|
|
887
945
|
## stepByStepReport
|
|
888
946
|
|
|
889
|
-
![step-by-step-report][
|
|
947
|
+
![step-by-step-report][16]
|
|
890
948
|
|
|
891
949
|
Generates step by step report for a test.
|
|
892
950
|
After each step in a test a screenshot is created. After test executed screenshots are combined into slideshow.
|
|
@@ -1067,7 +1125,7 @@ This plugin allows to run webdriverio services like:
|
|
|
1067
1125
|
- browserstack
|
|
1068
1126
|
- appium
|
|
1069
1127
|
|
|
1070
|
-
A complete list of all available services can be found on [webdriverio website][
|
|
1128
|
+
A complete list of all available services can be found on [webdriverio website][17].
|
|
1071
1129
|
|
|
1072
1130
|
#### Setup
|
|
1073
1131
|
|
|
@@ -1079,7 +1137,7 @@ See examples below:
|
|
|
1079
1137
|
|
|
1080
1138
|
#### Selenium Standalone Service
|
|
1081
1139
|
|
|
1082
|
-
Install `@wdio/selenium-standalone-service` package, as [described here][
|
|
1140
|
+
Install `@wdio/selenium-standalone-service` package, as [described here][18].
|
|
1083
1141
|
It is important to make sure it is compatible with current webdriverio version.
|
|
1084
1142
|
|
|
1085
1143
|
Enable `wdio` plugin in plugins list and add `selenium-standalone` service:
|
|
@@ -1098,7 +1156,7 @@ Please note, this service can be used with Protractor helper as well!
|
|
|
1098
1156
|
|
|
1099
1157
|
#### Sauce Service
|
|
1100
1158
|
|
|
1101
|
-
Install `@wdio/sauce-service` package, as [described here][
|
|
1159
|
+
Install `@wdio/sauce-service` package, as [described here][19].
|
|
1102
1160
|
It is important to make sure it is compatible with current webdriverio version.
|
|
1103
1161
|
|
|
1104
1162
|
Enable `wdio` plugin in plugins list and add `sauce` service:
|
|
@@ -1144,28 +1202,24 @@ In the same manner additional services from webdriverio can be installed, enable
|
|
|
1144
1202
|
|
|
1145
1203
|
[8]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined
|
|
1146
1204
|
|
|
1147
|
-
[9]:
|
|
1148
|
-
|
|
1149
|
-
[10]: https://raw.githubusercontent.com/Marak/faker.js/master/logo.png
|
|
1150
|
-
|
|
1151
|
-
[11]: /basics/#pause
|
|
1205
|
+
[9]: /basics/#pause
|
|
1152
1206
|
|
|
1153
|
-
[
|
|
1207
|
+
[10]: https://aerokube.com/selenoid/
|
|
1154
1208
|
|
|
1155
|
-
[
|
|
1209
|
+
[11]: https://aerokube.com/cm/latest/
|
|
1156
1210
|
|
|
1157
|
-
[
|
|
1211
|
+
[12]: https://hub.docker.com/u/selenoid
|
|
1158
1212
|
|
|
1159
|
-
[
|
|
1213
|
+
[13]: https://aerokube.com/selenoid/latest/#_prepare_configuration
|
|
1160
1214
|
|
|
1161
|
-
[
|
|
1215
|
+
[14]: https://aerokube.com/selenoid/latest/#_option_2_start_selenoid_container
|
|
1162
1216
|
|
|
1163
|
-
[
|
|
1217
|
+
[15]: https://docs.docker.com/engine/reference/commandline/create/
|
|
1164
1218
|
|
|
1165
|
-
[
|
|
1219
|
+
[16]: https://codecept.io/img/codeceptjs-slideshow.gif
|
|
1166
1220
|
|
|
1167
|
-
[
|
|
1221
|
+
[17]: https://webdriver.io
|
|
1168
1222
|
|
|
1169
|
-
[
|
|
1223
|
+
[18]: https://webdriver.io/docs/selenium-standalone-service.html
|
|
1170
1224
|
|
|
1171
|
-
[
|
|
1225
|
+
[19]: https://webdriver.io/docs/sauce-service.html
|
package/docs/secrets.md
CHANGED
|
@@ -15,6 +15,12 @@ When executed it will be printed like this:
|
|
|
15
15
|
```
|
|
16
16
|
I fill field "password" "*****"
|
|
17
17
|
```
|
|
18
|
+
**Other Examples**
|
|
19
|
+
```js
|
|
20
|
+
I.fillField('password', secret('123456'));
|
|
21
|
+
I.append('password', secret('123456'));
|
|
22
|
+
I.type('password', secret('123456'));
|
|
23
|
+
```
|
|
18
24
|
|
|
19
25
|
For an object, which can be a payload to POST request, specify which fields should be masked:
|
|
20
26
|
|
package/docs/tutorial.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
---
|
|
2
2
|
permalink: /tutorial
|
|
3
|
-
title:
|
|
3
|
+
title: CodeceptJS Complete Tutorial
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
# Tutorial: Writing Tests for Checkout Page
|
|
7
7
|
|
|
8
|
-
CodeceptJS
|
|
8
|
+
**[CodeceptJS](https://codecept.io) is a popular open-source testing framework** for JavaScript. It is designed to simplify writing and maintain end-to-end tests for web applications, using a readable and intuitive syntax. To run tests in browser it uses **[Playwright](https://playwright.dev)** by default but ca execute tests via WebDriver, Puppeteer or Appium.
|
|
9
9
|
|
|
10
10
|
## Let's get CodeceptJS installed!
|
|
11
11
|
|
|
@@ -216,7 +216,7 @@ module.exports = {
|
|
|
216
216
|
Feels really empty. What should we do about it? Should we write more code? No, we already have it. Let's copy code blocks from a test we have it and place them under a corredponnding function names:
|
|
217
217
|
|
|
218
218
|
```js
|
|
219
|
-
|
|
219
|
+
const { I } = inject();
|
|
220
220
|
|
|
221
221
|
module.exports = {
|
|
222
222
|
|
|
@@ -266,6 +266,6 @@ By applying more and more cases you can test a website to all behaviors.
|
|
|
266
266
|
|
|
267
267
|
## Summary
|
|
268
268
|
|
|
269
|
-
|
|
269
|
+
If you think on just starting test automation, CodeceptJS is the best choice for you as it uses native language to pass commands to browser.
|
|
270
270
|
|
|
271
271
|
If you already skilled in JavaScript, with CodeceptJS you can focus on business level of your test, instead of writing code for browser. This way you can keep your tests stable and maintainable.
|
|
@@ -3,6 +3,8 @@ Field is located by name, label, CSS or XPath
|
|
|
3
3
|
|
|
4
4
|
```js
|
|
5
5
|
I.appendField('#myTextField', 'appended');
|
|
6
|
+
// typing secret
|
|
7
|
+
I.appendField('password', secret('123456'));
|
|
6
8
|
```
|
|
7
9
|
@param {CodeceptJS.LocatorOrString} field located by label|name|CSS|XPath|strict locator
|
|
8
10
|
@param {string} value text value to append.
|