codeceptjs 3.0.3 → 3.0.7
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 +114 -18
- package/bin/codecept.js +1 -0
- package/docs/basics.md +2 -2
- package/docs/bdd.md +12 -1
- package/docs/build/Appium.js +2 -1
- package/docs/build/GraphQL.js +9 -10
- package/docs/build/Nightmare.js +4 -5
- package/docs/build/Playwright.js +164 -37
- package/docs/build/Protractor.js +1 -1
- package/docs/build/Puppeteer.js +1 -1
- package/docs/build/REST.js +24 -4
- package/docs/build/TestCafe.js +1 -1
- package/docs/build/WebDriver.js +85 -17
- package/docs/changelog.md +114 -18
- package/docs/data.md +5 -5
- package/docs/detox.md +2 -2
- package/docs/docker.md +11 -11
- package/docs/email.md +8 -8
- package/docs/helpers/Appium.md +1 -1
- package/docs/helpers/Nightmare.md +4 -5
- package/docs/helpers/Playwright.md +94 -64
- package/docs/helpers/Protractor.md +1 -1
- package/docs/helpers/Puppeteer.md +1 -1
- package/docs/helpers/REST.md +9 -0
- package/docs/helpers/TestCafe.md +1 -1
- package/docs/helpers/WebDriver.md +2 -1
- package/docs/locators.md +29 -2
- package/docs/mobile-react-native-locators.md +2 -2
- package/docs/mobile.md +3 -3
- package/docs/nightmare.md +0 -5
- package/docs/pageobjects.md +3 -1
- package/docs/parallel.md +35 -10
- package/docs/playwright.md +55 -8
- package/docs/plugins.md +73 -29
- package/docs/reports.md +8 -7
- package/docs/typescript.md +47 -5
- package/docs/webapi/fillField.mustache +1 -1
- package/lib/cli.js +25 -10
- package/lib/codecept.js +9 -1
- package/lib/command/interactive.js +10 -9
- package/lib/command/run.js +1 -1
- package/lib/command/workers/runTests.js +11 -6
- package/lib/config.js +8 -3
- package/lib/event.js +2 -0
- package/lib/helper/Appium.js +1 -0
- package/lib/helper/GraphQL.js +9 -10
- package/lib/helper/Nightmare.js +1 -1
- package/lib/helper/Playwright.js +131 -38
- package/lib/helper/REST.js +24 -4
- package/lib/helper/WebDriver.js +84 -16
- package/lib/interfaces/gherkin.js +11 -4
- package/lib/output.js +7 -4
- package/lib/plugin/allure.js +3 -7
- package/lib/plugin/fakerTransform.js +51 -0
- package/lib/plugin/screenshotOnFail.js +6 -2
- package/lib/recorder.js +9 -0
- package/lib/step.js +2 -1
- package/lib/transform.js +26 -0
- package/lib/ui.js +6 -2
- package/lib/within.js +1 -1
- package/lib/workers.js +39 -25
- package/package.json +14 -9
- package/typings/index.d.ts +49 -21
- package/typings/types.d.ts +72 -26
package/docs/locators.md
CHANGED
|
@@ -21,7 +21,7 @@ If the locator is an object, it should have a single element, with the key signi
|
|
|
21
21
|
|
|
22
22
|
Examples:
|
|
23
23
|
|
|
24
|
-
* {
|
|
24
|
+
* {id: 'foo'} matches `<div id="foo">`
|
|
25
25
|
* {name: 'foo'} matches `<div name="foo">`
|
|
26
26
|
* {css: 'input[type=input][value=foo]'} matches `<input type="input" value="foo">`
|
|
27
27
|
* {xpath: "//input[@type='submit'][contains(@value, 'foo')]"} matches `<input type="submit" value="foobar">`
|
|
@@ -229,7 +229,7 @@ locate('button').after('.btn-cancel');
|
|
|
229
229
|
|
|
230
230
|
ID locators are best to select the exact semantic element in web and mobile testing:
|
|
231
231
|
|
|
232
|
-
* `#user` or `{
|
|
232
|
+
* `#user` or `{ id: 'user' }` finds element with id="user"
|
|
233
233
|
* `~user` finds element with accessibility id "user" (in Mobile testing) or with `aria-label=user`.
|
|
234
234
|
|
|
235
235
|
## Custom Locators
|
|
@@ -297,8 +297,35 @@ codeceptjs.locator.addFilter((providedLocator, locatorObj) => {
|
|
|
297
297
|
```
|
|
298
298
|
New locator strategy is ready to use:
|
|
299
299
|
|
|
300
|
+
|
|
300
301
|
```js
|
|
301
302
|
I.click('=Login');
|
|
302
303
|
```
|
|
303
304
|
|
|
305
|
+
#### Custom Strategy Locators
|
|
306
|
+
|
|
307
|
+
CodeceptJS provides the option to specify custom locators that uses Custom Locator Strategies defined in the WebDriver configuration. It uses the WebDriverIO's [custom$](https://webdriver.io/docs/api/browser/custom$.html) locators internally to locate the elements on page.
|
|
308
|
+
To use the defined Custom Locator Strategy add your custom strategy to your configuration.
|
|
309
|
+
|
|
310
|
+
```js
|
|
311
|
+
// in codecept.conf.js
|
|
312
|
+
|
|
313
|
+
const myStrat = (selector) => {
|
|
314
|
+
return document.querySelectorAll(selector)
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
// under WebDriver Helpers Configuration
|
|
318
|
+
WebDriver: {
|
|
319
|
+
...
|
|
320
|
+
customLocatorStrategies: {
|
|
321
|
+
custom: myStrat
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
```js
|
|
327
|
+
I.click({custom: 'my-shadow-element-unique-css'})
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
|
|
304
331
|
> For more details on locator object see [Locator](https://github.com/codeceptjs/CodeceptJS/blob/master/lib/locator.js) class implementation.
|
|
@@ -46,14 +46,14 @@ You could do it just by changing `automationName` in the `helpers` section of th
|
|
|
46
46
|
```
|
|
47
47
|
Then you could locate components using XPath expression:
|
|
48
48
|
```js
|
|
49
|
-
I.tap({android:
|
|
49
|
+
I.tap({android: '//*[@view-tag="someButton"]', ios: '~someButton'})
|
|
50
50
|
```
|
|
51
51
|
This way test would work for both platforms without any changes in code.
|
|
52
52
|
To simplify things further you could write a helper function:
|
|
53
53
|
```js
|
|
54
54
|
function tid(id) {
|
|
55
55
|
return {
|
|
56
|
-
android:
|
|
56
|
+
android: `//*[@view-tag="${id}"]`,
|
|
57
57
|
ios: '~' + id
|
|
58
58
|
}
|
|
59
59
|
}
|
package/docs/mobile.md
CHANGED
|
@@ -19,7 +19,7 @@ I.see('davert@codecept.io', '~email of the customer'));
|
|
|
19
19
|
I.clearField('~email of the customer'));
|
|
20
20
|
I.dontSee('Nothing special', '~email of the customer'));
|
|
21
21
|
I.seeElement({
|
|
22
|
-
android:
|
|
22
|
+
android: 'android.widget.Button',
|
|
23
23
|
ios: '//UIAApplication[1]/UIAWindow[1]/UIAButton[1]'
|
|
24
24
|
});
|
|
25
25
|
```
|
|
@@ -118,6 +118,7 @@ helpers: {
|
|
|
118
118
|
app: "bs://<hashed app-id>",
|
|
119
119
|
host: "hub-cloud.browserstack.com",
|
|
120
120
|
port: 4444,
|
|
121
|
+
platform: "ios",
|
|
121
122
|
user: "BROWSERSTACK_USER",
|
|
122
123
|
key: "BROWSERSTACK_KEY",
|
|
123
124
|
device: "iPhone 7"
|
|
@@ -262,7 +263,7 @@ It is often happen that mobile applications behave similarly on different platfo
|
|
|
262
263
|
CodeceptJS provides a way to specify different locators for Android and iOS platforms:
|
|
263
264
|
|
|
264
265
|
```js
|
|
265
|
-
I.click({android:
|
|
266
|
+
I.click({android: '//android.widget.Button', ios: '//UIAApplication[1]/UIAWindow[1]/UIAButton[1]'});
|
|
266
267
|
```
|
|
267
268
|
|
|
268
269
|
In case some code should be executed on one platform and ignored on others use `runOnAndroid` and `runOnIOS` methods:
|
|
@@ -293,4 +294,3 @@ Just as you can specify android, and ios-specific locators, you can do so for we
|
|
|
293
294
|
```js
|
|
294
295
|
I.click({web: '#login', ios: '//UIAApplication[1]/UIAWindow[1]/UIAButton[1]'});
|
|
295
296
|
```
|
|
296
|
-
|
package/docs/nightmare.md
CHANGED
|
@@ -221,8 +221,3 @@ I.seeAttributeContains('#main img', 'src', '/cat.jpg');
|
|
|
221
221
|
This sample assertion used `_locate` helper method which searched for elements
|
|
222
222
|
by CSS/XPath or a strict locator. Then `browser.evaluate` method was called to
|
|
223
223
|
use locate found elements on a page and return attribute from the first of them.
|
|
224
|
-
|
|
225
|
-
## Additional Links
|
|
226
|
-
|
|
227
|
-
* [Nightmare Tutorial](http://codenroll.it/acceptance-testing-with-codecept-js/) by jploskonka.
|
|
228
|
-
|
package/docs/pageobjects.md
CHANGED
|
@@ -32,7 +32,9 @@ const { I, myPage, mySteps } = inject();
|
|
|
32
32
|
// inject objects for a test by name
|
|
33
33
|
Scenario('sample test', ({ I, myPage, mySteps }) => {
|
|
34
34
|
// ...
|
|
35
|
-
|
|
35
|
+
});
|
|
36
|
+
```
|
|
37
|
+
|
|
36
38
|
## Actor
|
|
37
39
|
|
|
38
40
|
During initialization you were asked to create a custom steps file. If you accepted this option, you are now able to use the `custom_steps.js` file to extend `I`. See how the `login` method can be added to `I`:
|
package/docs/parallel.md
CHANGED
|
@@ -26,7 +26,7 @@ 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
|
|
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.
|
|
30
30
|
|
|
31
31
|
```sh
|
|
32
32
|
npx codeceptjs run-workers --suites 2
|
|
@@ -74,9 +74,11 @@ const testGroups = workers.createGroupsOfSuites(2);
|
|
|
74
74
|
const browsers = ['firefox', 'chrome'];
|
|
75
75
|
|
|
76
76
|
const configs = browsers.map(browser => {
|
|
77
|
-
return
|
|
78
|
-
|
|
79
|
-
|
|
77
|
+
return {
|
|
78
|
+
helpers: {
|
|
79
|
+
WebDriver: { browser }
|
|
80
|
+
}
|
|
81
|
+
};
|
|
80
82
|
});
|
|
81
83
|
|
|
82
84
|
for (const config of configs) {
|
|
@@ -176,24 +178,41 @@ customWorkers.on(event.all.result, () => {
|
|
|
176
178
|
});
|
|
177
179
|
```
|
|
178
180
|
|
|
181
|
+
### Emitting messages to the parent worker
|
|
182
|
+
|
|
183
|
+
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`.
|
|
184
|
+
|
|
185
|
+
```js
|
|
186
|
+
// inside main process
|
|
187
|
+
// listen for any non test related events
|
|
188
|
+
workers.on('message', (data) => {
|
|
189
|
+
console.log(data)
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
workers.on(event.all.result, (status, completedTests, workerStats) => {
|
|
193
|
+
// logic
|
|
194
|
+
});
|
|
195
|
+
```
|
|
196
|
+
|
|
179
197
|
## Sharing Data Between Workers
|
|
180
198
|
|
|
181
|
-
NodeJS Workers can communicate between each other via messaging system. It may happen that you want to pass some data from one of workers to other. For instance, you may want to share user credentials accross all tests. Data will be appended to a container.
|
|
199
|
+
NodeJS Workers can communicate between each other via messaging system. It may happen that you want to pass some data from one of the workers to other. For instance, you may want to share user credentials accross all tests. Data will be appended to a container.
|
|
182
200
|
|
|
183
|
-
However, you can't access uninitialized data from a container, so to start, you need to
|
|
201
|
+
However, you can't access uninitialized data from a container, so to start, you need to initialize data first. Inside `bootstrap` function of the config we execute the `share` to initialize value:
|
|
184
202
|
|
|
185
203
|
|
|
186
204
|
```js
|
|
187
205
|
// inside codecept.conf.js
|
|
188
206
|
exports.config = {
|
|
189
207
|
bootstrap() {
|
|
190
|
-
// append empty userData to container
|
|
191
|
-
share({ userData: false }
|
|
208
|
+
// append empty userData to container
|
|
209
|
+
share({ userData: false });
|
|
192
210
|
}
|
|
193
211
|
}
|
|
194
212
|
```
|
|
213
|
+
|
|
195
214
|
Now each worker has `userData` inside a container. However, it is empty.
|
|
196
|
-
When you obtain real data in one of tests you can this data accross tests. Use `inject` function to access data inside a container:
|
|
215
|
+
When you obtain real data in one of the tests you can now `share` this data accross tests. Use `inject` function to access data inside a container:
|
|
197
216
|
|
|
198
217
|
```js
|
|
199
218
|
// get current value of userData
|
|
@@ -202,6 +221,12 @@ let { userData } = inject();
|
|
|
202
221
|
if (!userData) {
|
|
203
222
|
userData = { name: 'user', password: '123456' };
|
|
204
223
|
// now new userData will be shared accross all workers
|
|
205
|
-
share(userData);
|
|
224
|
+
share({userData : userData});
|
|
206
225
|
}
|
|
207
226
|
```
|
|
227
|
+
|
|
228
|
+
If you want to share data only within same worker, and not across all workers, you need to add option `local: true` every time you run `share`
|
|
229
|
+
|
|
230
|
+
```js
|
|
231
|
+
share({ userData: false }, {local: true });
|
|
232
|
+
```
|
package/docs/playwright.md
CHANGED
|
@@ -5,9 +5,9 @@ title: Testing with Playwright
|
|
|
5
5
|
|
|
6
6
|
# Testing with Playwright <Badge text="Since 2.5" type="warning"/>
|
|
7
7
|
|
|
8
|
-
Playwright is a Node library to automate the [Chromium](https://www.chromium.org/Home), [WebKit](https://webkit.org/) and [Firefox](https://www.mozilla.org/en-US/firefox/new/) browsers with a single API. It enables **cross-browser** web automation that is **ever-green**, **capable**, **reliable** and **fast**.
|
|
8
|
+
Playwright is a Node library to automate the [Chromium](https://www.chromium.org/Home), [WebKit](https://webkit.org/) and [Firefox](https://www.mozilla.org/en-US/firefox/new/) browsers as well as [Electron](https://www.electronjs.org/) apps with a single API. It enables **cross-browser** web automation that is **ever-green**, **capable**, **reliable** and **fast**.
|
|
9
9
|
|
|
10
|
-
Playwright was built similarly to [Puppeteer](https://github.com/puppeteer/puppeteer), using its API and so is very different in usage. However, Playwright has cross browser support with better design for test
|
|
10
|
+
Playwright was built similarly to [Puppeteer](https://github.com/puppeteer/puppeteer), using its API and so is very different in usage. However, Playwright has cross browser support with better design for test automation.
|
|
11
11
|
|
|
12
12
|
Take a look at a sample test:
|
|
13
13
|
|
|
@@ -202,7 +202,7 @@ CodeceptJS allows you to implement custom actions like `I.createTodo` or use **P
|
|
|
202
202
|
|
|
203
203
|
## Multi Session Testing
|
|
204
204
|
|
|
205
|
-
|
|
205
|
+
To launch additional browser context (or incognito window) use `session` command.
|
|
206
206
|
|
|
207
207
|
```js
|
|
208
208
|
Scenario('I try to open this site as anonymous user', ({ I }) => {
|
|
@@ -217,13 +217,60 @@ Scenario('I try to open this site as anonymous user', ({ I }) => {
|
|
|
217
217
|
|
|
218
218
|
> ℹ Learn more about [multi-session testing](/basics/#multiple-sessions)
|
|
219
219
|
|
|
220
|
+
## Electron Testing
|
|
221
|
+
|
|
222
|
+
CodeceptJS allows you to make use of [Playwright's Electron flavor](https://github.com/microsoft/playwright/blob/master/packages/playwright-electron/README.md).
|
|
223
|
+
To use this functionality, all you need to do is set the browser to `electron` in the CodeceptJS configuration file and, according to the [Playwright BrowserType API](https://playwright.dev/docs/api/class-browsertype/#browsertypelaunchoptions), set the launch options to point to your Electron application.
|
|
224
|
+
|
|
225
|
+
`main.js` - main Electron application file
|
|
226
|
+
```js
|
|
227
|
+
const { app, BrowserWindow } = require("electron");
|
|
228
|
+
|
|
229
|
+
function createWindow() {
|
|
230
|
+
const window = new BrowserWindow({ width: 800, height: 600 });
|
|
231
|
+
window.loadURL("https://example.com");
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
app.whenReady().then(createWindow);
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
`codecept.conf.js` - CodeceptJS configuration file
|
|
238
|
+
```js
|
|
239
|
+
const path = require("path");
|
|
240
|
+
|
|
241
|
+
exports.config = {
|
|
242
|
+
helpers: {
|
|
243
|
+
Playwright: {
|
|
244
|
+
browser: "electron",
|
|
245
|
+
electron: {
|
|
246
|
+
executablePath: require("electron"),
|
|
247
|
+
args: [path.join(__dirname, "main.js")],
|
|
248
|
+
},
|
|
249
|
+
},
|
|
250
|
+
},
|
|
251
|
+
// rest of config
|
|
252
|
+
}
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
### Headless Mode
|
|
256
|
+
|
|
257
|
+
With Electron, headless mode must be set when creating the window. Therefore, CodeceptJS's `show` configuration parameter will not work. However, you can set it in the `main.js` file as shown below:
|
|
258
|
+
|
|
259
|
+
```js
|
|
260
|
+
function createWindow() {
|
|
261
|
+
const window = new BrowserWindow({ width: 800, height: 600, show: false });
|
|
262
|
+
window.loadURL("https://example.com");
|
|
263
|
+
}
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
|
|
220
267
|
## Device Emulation
|
|
221
268
|
|
|
222
269
|
Playwright can emulate browsers of mobile devices. Instead of paying for expensive devices for mobile tests you can adjust Playwright settings so it could emulate mobile browsers on iPhone, Samsung Galaxy, etc.
|
|
223
270
|
|
|
224
271
|
Device emulation can be enabled in CodeceptJS globally in a config or per session.
|
|
225
272
|
|
|
226
|
-
Playwright contains a [list of predefined devices](https://github.com/
|
|
273
|
+
Playwright contains a [list of predefined devices](https://github.com/microsoft/playwright/blob/master/src/server/deviceDescriptors.js) to emulate, for instance this is how you can enable iPhone 6 emulation for all tests:
|
|
227
274
|
|
|
228
275
|
```js
|
|
229
276
|
const { devices } = require('playwright');
|
|
@@ -235,7 +282,7 @@ helpers: {
|
|
|
235
282
|
}
|
|
236
283
|
}
|
|
237
284
|
```
|
|
238
|
-
To adjust browser settings you can pass [custom options](https://github.com/microsoft/playwright/blob/master/docs/api.md
|
|
285
|
+
To adjust browser settings you can pass [custom options](https://github.com/microsoft/playwright/blob/master/docs/src/api/class-browsercontext.md)
|
|
239
286
|
|
|
240
287
|
```js
|
|
241
288
|
helpers: {
|
|
@@ -275,7 +322,7 @@ Playwright can be added to GitHub Actions using [official action](https://github
|
|
|
275
322
|
|
|
276
323
|
## Accessing Playwright API
|
|
277
324
|
|
|
278
|
-
To get [Playwright API](https://github.com/microsoft/playwright/
|
|
325
|
+
To get [Playwright API](https://github.com/microsoft/playwright/tree/master/docs/src/api) inside a test use `I.usePlaywrightTo` method with a callback.
|
|
279
326
|
To keep test readable provide a description of a callback inside the first parameter.
|
|
280
327
|
|
|
281
328
|
```js
|
|
@@ -338,6 +385,6 @@ async setPermissions() {
|
|
|
338
385
|
}
|
|
339
386
|
```
|
|
340
387
|
|
|
341
|
-
> [▶ Learn more about BrowserContext](https://github.com/microsoft/playwright/blob/master/docs/api
|
|
388
|
+
> [▶ Learn more about BrowserContext](https://github.com/microsoft/playwright/blob/master/docs/src/api/class-browsercontext.md)
|
|
342
389
|
|
|
343
|
-
> [▶ Learn more about Helpers](
|
|
390
|
+
> [▶ Learn more about Helpers](https://codecept.io/helpers/)
|
package/docs/plugins.md
CHANGED
|
@@ -478,9 +478,49 @@ I.click('=sign-up'); // matches => [data-qa=sign-up]
|
|
|
478
478
|
|
|
479
479
|
- `config`
|
|
480
480
|
|
|
481
|
+
## fakerTransform
|
|
482
|
+
|
|
483
|
+
Use the [faker.js][4] package to generate fake data inside examples on your gherkin tests
|
|
484
|
+
|
|
485
|
+
![Faker.js][5]
|
|
486
|
+
|
|
487
|
+
#### Usage
|
|
488
|
+
|
|
489
|
+
To start please install `faker.js` package
|
|
490
|
+
|
|
491
|
+
npm install -D faker
|
|
492
|
+
|
|
493
|
+
yarn add -D faker
|
|
494
|
+
|
|
495
|
+
Add this plugin to config file:
|
|
496
|
+
|
|
497
|
+
```js
|
|
498
|
+
plugins: {
|
|
499
|
+
fakerTransform: {
|
|
500
|
+
enabled: true
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
```
|
|
504
|
+
|
|
505
|
+
Add the faker API using a mustache string format inside examples tables in your gherkin scenario outline
|
|
506
|
+
|
|
507
|
+
```feature
|
|
508
|
+
Scenario Outline: ...
|
|
509
|
+
Given ...
|
|
510
|
+
When ...
|
|
511
|
+
Then ...
|
|
512
|
+
Examples:
|
|
513
|
+
| productName | customer | email | anythingMore |
|
|
514
|
+
| {{commerce.product}} | Dr. {{name.findName}} | {{internet.email}} | staticData |
|
|
515
|
+
```
|
|
516
|
+
|
|
517
|
+
### Parameters
|
|
518
|
+
|
|
519
|
+
- `config`
|
|
520
|
+
|
|
481
521
|
## pauseOnFail
|
|
482
522
|
|
|
483
|
-
Automatically launches [interactive pause][
|
|
523
|
+
Automatically launches [interactive pause][6] when a test fails.
|
|
484
524
|
|
|
485
525
|
Useful for debugging flaky tests on local environment.
|
|
486
526
|
Add this plugin to config file:
|
|
@@ -527,9 +567,9 @@ Possible config options:
|
|
|
527
567
|
|
|
528
568
|
Links:
|
|
529
569
|
|
|
530
|
-
- [https://github.com/GoogleChrome/puppeteer/blob/v1.12.2/docs/api.md#class-coverage][
|
|
531
|
-
- [https://github.com/istanbuljs/puppeteer-to-istanbul][
|
|
532
|
-
- [https://github.com/gotwarlost/istanbul][
|
|
570
|
+
- [https://github.com/GoogleChrome/puppeteer/blob/v1.12.2/docs/api.md#class-coverage][7]
|
|
571
|
+
- [https://github.com/istanbuljs/puppeteer-to-istanbul][8]
|
|
572
|
+
- [https://github.com/gotwarlost/istanbul][9]
|
|
533
573
|
|
|
534
574
|
### Parameters
|
|
535
575
|
|
|
@@ -633,14 +673,14 @@ Possible config options:
|
|
|
633
673
|
|
|
634
674
|
## selenoid
|
|
635
675
|
|
|
636
|
-
[Selenoid][
|
|
676
|
+
[Selenoid][10] plugin automatically starts browsers and video recording.
|
|
637
677
|
Works with WebDriver helper.
|
|
638
678
|
|
|
639
679
|
### Prerequisite
|
|
640
680
|
|
|
641
681
|
This plugin **requires Docker** to be installed.
|
|
642
682
|
|
|
643
|
-
> If you have issues starting Selenoid with this plugin consider using the official [Configuration Manager][
|
|
683
|
+
> If you have issues starting Selenoid with this plugin consider using the official [Configuration Manager][11] tool from Selenoid
|
|
644
684
|
|
|
645
685
|
### Usage
|
|
646
686
|
|
|
@@ -669,7 +709,7 @@ plugins: {
|
|
|
669
709
|
}
|
|
670
710
|
```
|
|
671
711
|
|
|
672
|
-
When `autoCreate` is enabled it will pull the [latest Selenoid from DockerHub][
|
|
712
|
+
When `autoCreate` is enabled it will pull the [latest Selenoid from DockerHub][12] and start Selenoid automatically.
|
|
673
713
|
It will also create `browsers.json` file required by Selenoid.
|
|
674
714
|
|
|
675
715
|
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.
|
|
@@ -681,10 +721,10 @@ In automatic mode the latest version of browser will be used for tests. It is re
|
|
|
681
721
|
While this plugin can create containers for you for better control it is recommended to create and launch containers manually.
|
|
682
722
|
This is especially useful for Continous Integration server as you can configure scaling for Selenoid containers.
|
|
683
723
|
|
|
684
|
-
> Use [Selenoid Configuration Manager][
|
|
724
|
+
> Use [Selenoid Configuration Manager][11] to create and start containers semi-automatically.
|
|
685
725
|
|
|
686
726
|
1. Create `browsers.json` file in the same directory `codecept.conf.js` is located
|
|
687
|
-
[Refer to Selenoid documentation][
|
|
727
|
+
[Refer to Selenoid documentation][13] to know more about browsers.json.
|
|
688
728
|
|
|
689
729
|
_Sample browsers.json_
|
|
690
730
|
|
|
@@ -709,7 +749,7 @@ _Sample browsers.json_
|
|
|
709
749
|
|
|
710
750
|
2. Create Selenoid container
|
|
711
751
|
|
|
712
|
-
Run the following command to create a container. To know more [refer here][
|
|
752
|
+
Run the following command to create a container. To know more [refer here][14]
|
|
713
753
|
|
|
714
754
|
```bash
|
|
715
755
|
docker create \
|
|
@@ -742,7 +782,7 @@ When `allure` plugin is enabled a video is attached to report automatically.
|
|
|
742
782
|
| enableVideo | Enable video recording and use `video` folder of output (default: false) |
|
|
743
783
|
| enableLog | Enable log recording and use `logs` folder of output (default: false) |
|
|
744
784
|
| deletePassed | Delete video and logs of passed tests (default : true) |
|
|
745
|
-
| additionalParams | example: `additionalParams: '--env TEST=test'` [Refer here][
|
|
785
|
+
| additionalParams | example: `additionalParams: '--env TEST=test'` [Refer here][15] to know more |
|
|
746
786
|
|
|
747
787
|
### Parameters
|
|
748
788
|
|
|
@@ -750,7 +790,7 @@ When `allure` plugin is enabled a video is attached to report automatically.
|
|
|
750
790
|
|
|
751
791
|
## stepByStepReport
|
|
752
792
|
|
|
753
|
-
![step-by-step-report][
|
|
793
|
+
![step-by-step-report][16]
|
|
754
794
|
|
|
755
795
|
Generates step by step report for a test.
|
|
756
796
|
After each step in a test a screenshot is created. After test executed screenshots are combined into slideshow.
|
|
@@ -857,7 +897,7 @@ This plugin allows to run webdriverio services like:
|
|
|
857
897
|
- browserstack
|
|
858
898
|
- appium
|
|
859
899
|
|
|
860
|
-
A complete list of all available services can be found on [webdriverio website][
|
|
900
|
+
A complete list of all available services can be found on [webdriverio website][17].
|
|
861
901
|
|
|
862
902
|
#### Setup
|
|
863
903
|
|
|
@@ -869,7 +909,7 @@ See examples below:
|
|
|
869
909
|
|
|
870
910
|
#### Selenium Standalone Service
|
|
871
911
|
|
|
872
|
-
Install `@wdio/selenium-standalone-service` package, as [described here][
|
|
912
|
+
Install `@wdio/selenium-standalone-service` package, as [described here][18].
|
|
873
913
|
It is important to make sure it is compatible with current webdriverio version.
|
|
874
914
|
|
|
875
915
|
Enable `wdio` plugin in plugins list and add `selenium-standalone` service:
|
|
@@ -888,7 +928,7 @@ Please note, this service can be used with Protractor helper as well!
|
|
|
888
928
|
|
|
889
929
|
#### Sauce Service
|
|
890
930
|
|
|
891
|
-
Install `@wdio/sauce-service` package, as [described here][
|
|
931
|
+
Install `@wdio/sauce-service` package, as [described here][19].
|
|
892
932
|
It is important to make sure it is compatible with current webdriverio version.
|
|
893
933
|
|
|
894
934
|
Enable `wdio` plugin in plugins list and add `sauce` service:
|
|
@@ -924,30 +964,34 @@ In the same manner additional services from webdriverio can be installed, enable
|
|
|
924
964
|
|
|
925
965
|
[3]: https://codecept.io/locators#custom-locators
|
|
926
966
|
|
|
927
|
-
[4]: /
|
|
967
|
+
[4]: https://www.npmjs.com/package/faker
|
|
968
|
+
|
|
969
|
+
[5]: https://raw.githubusercontent.com/Marak/faker.js/master/logo.png
|
|
970
|
+
|
|
971
|
+
[6]: /basics/#pause
|
|
928
972
|
|
|
929
|
-
[
|
|
973
|
+
[7]: https://github.com/GoogleChrome/puppeteer/blob/v1.12.2/docs/api.md#class-coverage
|
|
930
974
|
|
|
931
|
-
[
|
|
975
|
+
[8]: https://github.com/istanbuljs/puppeteer-to-istanbul
|
|
932
976
|
|
|
933
|
-
[
|
|
977
|
+
[9]: https://github.com/gotwarlost/istanbul
|
|
934
978
|
|
|
935
|
-
[
|
|
979
|
+
[10]: https://aerokube.com/selenoid/
|
|
936
980
|
|
|
937
|
-
[
|
|
981
|
+
[11]: https://aerokube.com/cm/latest/
|
|
938
982
|
|
|
939
|
-
[
|
|
983
|
+
[12]: https://hub.docker.com/u/selenoid
|
|
940
984
|
|
|
941
|
-
[
|
|
985
|
+
[13]: https://aerokube.com/selenoid/latest/#_prepare_configuration
|
|
942
986
|
|
|
943
|
-
[
|
|
987
|
+
[14]: https://aerokube.com/selenoid/latest/#_option_2_start_selenoid_container
|
|
944
988
|
|
|
945
|
-
[
|
|
989
|
+
[15]: https://docs.docker.com/engine/reference/commandline/create/
|
|
946
990
|
|
|
947
|
-
[
|
|
991
|
+
[16]: https://codecept.io/img/codeceptjs-slideshow.gif
|
|
948
992
|
|
|
949
|
-
[
|
|
993
|
+
[17]: https://webdriver.io
|
|
950
994
|
|
|
951
|
-
[
|
|
995
|
+
[18]: https://webdriver.io/docs/selenium-standalone-service.html
|
|
952
996
|
|
|
953
|
-
[
|
|
997
|
+
[19]: https://webdriver.io/docs/sauce-service.html
|
package/docs/reports.md
CHANGED
|
@@ -352,17 +352,18 @@ Configure mocha-multi with reports that you want:
|
|
|
352
352
|
}
|
|
353
353
|
},
|
|
354
354
|
"mochawesome": {
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
355
|
+
"stdout": "./output/console.log",
|
|
356
|
+
"options": {
|
|
357
|
+
"reportDir": "./output",
|
|
358
|
+
"reportFilename": "report"
|
|
359
|
+
}
|
|
359
360
|
},
|
|
360
361
|
"mocha-junit-reporter": {
|
|
361
362
|
"stdout": "./output/console.log",
|
|
362
363
|
"options": {
|
|
363
|
-
"mochaFile": "./output/result.xml"
|
|
364
|
-
|
|
365
|
-
|
|
364
|
+
"mochaFile": "./output/result.xml",
|
|
365
|
+
"attachments": true //add screenshot for a failed test
|
|
366
|
+
}
|
|
366
367
|
}
|
|
367
368
|
}
|
|
368
369
|
}
|
package/docs/typescript.md
CHANGED
|
@@ -19,10 +19,10 @@ Example:
|
|
|
19
19
|
|
|
20
20
|

|
|
21
21
|
|
|
22
|
-
- Checks types - thanks to TypeScript support in CodeceptJS now allow to tests your tests. TypeScript can prevent some errors:
|
|
22
|
+
- Checks types - thanks to TypeScript support in CodeceptJS now allow to tests your tests. TypeScript can prevent some errors:
|
|
23
23
|
- invalid type of variables passed to function;
|
|
24
24
|
- calls no-exist method from PageObject or `I` object;
|
|
25
|
-
- incorrectly used CodeceptJS features;
|
|
25
|
+
- incorrectly used CodeceptJS features;
|
|
26
26
|
|
|
27
27
|
|
|
28
28
|
## Getting Started
|
|
@@ -106,7 +106,7 @@ declare namespace CodeceptJS {
|
|
|
106
106
|
|
|
107
107
|
## Types for custom helper or page object
|
|
108
108
|
|
|
109
|
-
If you want to get types for your [custom helper](https://codecept.io/helpers/#configuration), you can add their automatically with CodeceptJS command `npx codeceptjs def`.
|
|
109
|
+
If you want to get types for your [custom helper](https://codecept.io/helpers/#configuration), you can add their automatically with CodeceptJS command `npx codeceptjs def`.
|
|
110
110
|
|
|
111
111
|
For example, if you add the new step `printMessage` for your custom helper like this:
|
|
112
112
|
```js
|
|
@@ -121,9 +121,9 @@ export = CustomHelper
|
|
|
121
121
|
```
|
|
122
122
|
|
|
123
123
|
Then you need to add this helper to your `codecept.conf.js` like in this [docs](https://codecept.io/helpers/#configuration).
|
|
124
|
-
And then run the command `npx codeceptjs def`.
|
|
124
|
+
And then run the command `npx codeceptjs def`.
|
|
125
125
|
|
|
126
|
-
As result our `steps.d.ts` file will be updated like this:
|
|
126
|
+
As result our `steps.d.ts` file will be updated like this:
|
|
127
127
|
```ts
|
|
128
128
|
/// <reference types='codeceptjs' />
|
|
129
129
|
type CustomHelper = import('./CustomHelper');
|
|
@@ -156,3 +156,45 @@ declare namespace CodeceptJS {
|
|
|
156
156
|
}
|
|
157
157
|
}
|
|
158
158
|
```
|
|
159
|
+
|
|
160
|
+
## Types for custom strict locators
|
|
161
|
+
|
|
162
|
+
You can define [custom strict locators](https://codecept.io/locators/#custom-strict-locators) that can be used in all methods taking a locator (parameter type `LocatorOrString`).
|
|
163
|
+
|
|
164
|
+
Example: A custom strict locator with a `data` property, which can be used like this:
|
|
165
|
+
|
|
166
|
+
```ts
|
|
167
|
+
I.click({ data: 'user-login' });
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
In order to use the custom locator in TypeScript code, its type shape needs to be registered in the interface `CustomLocators` in your `steps.d.ts` file:
|
|
171
|
+
|
|
172
|
+
```ts
|
|
173
|
+
/// <reference types='codeceptjs' />
|
|
174
|
+
...
|
|
175
|
+
|
|
176
|
+
declare namespace CodeceptJS {
|
|
177
|
+
...
|
|
178
|
+
|
|
179
|
+
interface CustomLocators {
|
|
180
|
+
data: { data: string };
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
The property keys used in the `CustomLocators` interface do not matter (only the *types* of the interface properties are used). For simplicity it is recommended to use the name that is also used in your custom locator itself.
|
|
186
|
+
|
|
187
|
+
You can also define more complicated custom locators with multiple (also optional) properties:
|
|
188
|
+
|
|
189
|
+
```ts
|
|
190
|
+
/// <reference types='codeceptjs' />
|
|
191
|
+
...
|
|
192
|
+
|
|
193
|
+
declare namespace CodeceptJS {
|
|
194
|
+
...
|
|
195
|
+
|
|
196
|
+
interface CustomLocators {
|
|
197
|
+
data: { data: string, value?: number, flag?: boolean };
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
```
|
|
@@ -12,4 +12,4 @@ I.fillField('form#login input[name=username]', 'John');
|
|
|
12
12
|
I.fillField({css: 'form#login input[name=username]'}, 'John');
|
|
13
13
|
```
|
|
14
14
|
@param {CodeceptJS.LocatorOrString} field located by label|name|CSS|XPath|strict locator.
|
|
15
|
-
@param {
|
|
15
|
+
@param {CodeceptJS.StringOrSecret} value text value to fill.
|