codeceptjs 3.4.1 → 3.5.1-2.beta.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/README.md +31 -30
- package/bin/codecept.js +1 -1
- package/lib/actor.js +6 -3
- package/lib/ai.js +180 -0
- package/lib/cli.js +13 -3
- package/lib/codecept.js +8 -0
- package/lib/colorUtils.js +10 -0
- package/lib/command/definitions.js +2 -7
- package/lib/command/dryRun.js +11 -2
- package/lib/command/generate.js +46 -3
- package/lib/command/info.js +24 -0
- package/lib/command/init.js +64 -6
- package/lib/command/interactive.js +15 -1
- package/lib/command/run-multiple/collection.js +17 -5
- package/lib/command/run-multiple.js +4 -2
- package/lib/command/run-workers.js +68 -5
- package/lib/command/run.js +7 -0
- package/lib/command/workers/runTests.js +39 -0
- package/lib/container.js +13 -3
- package/lib/data/context.js +14 -6
- package/lib/event.js +4 -0
- package/lib/helper/ApiDataFactory.js +2 -1
- package/lib/helper/Appium.js +116 -29
- package/lib/helper/Expect.js +422 -0
- package/lib/helper/FileSystem.js +1 -1
- package/lib/helper/GraphQL.js +25 -0
- package/lib/helper/JSONResponse.js +4 -4
- package/lib/helper/Nightmare.js +10 -5
- package/lib/helper/OpenAI.js +126 -0
- package/lib/helper/Playwright.js +1298 -229
- package/lib/helper/Protractor.js +12 -7
- package/lib/helper/Puppeteer.js +204 -64
- package/lib/helper/REST.js +15 -5
- package/lib/helper/TestCafe.js +45 -10
- package/lib/helper/WebDriver.js +252 -83
- package/lib/helper/errors/ElementNotFound.js +2 -1
- package/lib/helper/extras/PlaywrightReactVueLocator.js +38 -0
- package/lib/helper/scripts/blurElement.js +17 -0
- package/lib/helper/scripts/focusElement.js +17 -0
- package/lib/helper/scripts/highlightElement.js +20 -0
- package/lib/html.js +258 -0
- package/lib/interfaces/bdd.js +1 -1
- package/lib/interfaces/gherkin.js +37 -3
- package/lib/interfaces/scenarioConfig.js +1 -0
- package/lib/listener/retry.js +2 -1
- package/lib/locator.js +17 -4
- package/lib/mochaFactory.js +2 -1
- package/lib/output.js +1 -1
- package/lib/pause.js +78 -19
- package/lib/plugin/autoLogin.js +45 -10
- package/lib/plugin/debugErrors.js +67 -0
- package/lib/plugin/fakerTransform.js +4 -6
- package/lib/plugin/heal.js +209 -0
- package/lib/plugin/retryFailedStep.js +10 -1
- package/lib/plugin/retryTo.js +2 -4
- package/lib/plugin/screenshotOnFail.js +11 -2
- package/lib/plugin/selenoid.js +6 -1
- package/lib/plugin/standardActingHelpers.js +0 -2
- package/lib/plugin/stepByStepReport.js +2 -2
- package/lib/plugin/tryTo.js +5 -7
- package/lib/plugin/wdio.js +0 -1
- package/lib/recorder.js +22 -11
- package/lib/secret.js +5 -4
- package/lib/session.js +1 -1
- package/lib/step.js +36 -12
- package/lib/ui.js +5 -3
- package/lib/utils.js +22 -1
- package/lib/workers.js +83 -10
- package/package.json +117 -95
- package/translations/de-DE.js +5 -0
- package/translations/fr-FR.js +14 -1
- package/translations/it-IT.js +1 -0
- package/translations/ja-JP.js +14 -9
- package/translations/pl-PL.js +5 -0
- package/translations/pt-BR.js +1 -0
- package/translations/ru-RU.js +1 -0
- package/translations/zh-CN.js +5 -0
- package/translations/zh-TW.js +5 -0
- package/typings/index.d.ts +51 -15
- package/typings/promiseBasedTypes.d.ts +864 -802
- package/typings/types.d.ts +1339 -744
- package/CHANGELOG.md +0 -2427
- package/docs/advanced.md +0 -351
- package/docs/api.md +0 -323
- package/docs/basics.md +0 -980
- package/docs/bdd.md +0 -535
- package/docs/best.md +0 -237
- package/docs/books.md +0 -37
- package/docs/bootstrap.md +0 -135
- package/docs/build/ApiDataFactory.js +0 -409
- package/docs/build/Appium.js +0 -1938
- package/docs/build/FileSystem.js +0 -228
- package/docs/build/GraphQL.js +0 -204
- package/docs/build/GraphQLDataFactory.js +0 -309
- package/docs/build/JSONResponse.js +0 -338
- package/docs/build/Mochawesome.js +0 -71
- package/docs/build/Nightmare.js +0 -2145
- package/docs/build/Playwright.js +0 -3986
- package/docs/build/Polly.js +0 -42
- package/docs/build/Protractor.js +0 -2699
- package/docs/build/Puppeteer.js +0 -3710
- package/docs/build/REST.js +0 -334
- package/docs/build/SeleniumWebdriver.js +0 -76
- package/docs/build/TestCafe.js +0 -2057
- package/docs/build/WebDriver.js +0 -4017
- package/docs/changelog.md +0 -2436
- package/docs/commands.md +0 -254
- package/docs/community-helpers.md +0 -58
- package/docs/configuration.md +0 -157
- package/docs/continuous-integration.md +0 -22
- package/docs/custom-helpers.md +0 -306
- package/docs/data.md +0 -375
- package/docs/detox.md +0 -235
- package/docs/docker.md +0 -137
- package/docs/email.md +0 -183
- package/docs/examples.md +0 -149
- package/docs/helpers/ApiDataFactory.md +0 -266
- package/docs/helpers/Appium.md +0 -1312
- package/docs/helpers/Detox.md +0 -586
- package/docs/helpers/FileSystem.md +0 -152
- package/docs/helpers/GraphQL.md +0 -130
- package/docs/helpers/GraphQLDataFactory.md +0 -226
- package/docs/helpers/JSONResponse.md +0 -254
- package/docs/helpers/Mochawesome.md +0 -8
- package/docs/helpers/MockRequest.md +0 -377
- package/docs/helpers/Nightmare.md +0 -1256
- package/docs/helpers/Playwright.md +0 -2208
- package/docs/helpers/Polly.md +0 -44
- package/docs/helpers/Puppeteer-firefox.md +0 -86
- package/docs/helpers/Puppeteer.md +0 -2141
- package/docs/helpers/REST.md +0 -217
- package/docs/helpers/TestCafe.md +0 -1222
- package/docs/helpers/WebDriver.md +0 -2319
- package/docs/hooks.md +0 -340
- package/docs/index.md +0 -111
- package/docs/installation.md +0 -75
- package/docs/internal-api.md +0 -265
- package/docs/locators.md +0 -331
- package/docs/mobile-react-native-locators.md +0 -67
- package/docs/mobile.md +0 -297
- package/docs/nightmare.md +0 -223
- package/docs/pageobjects.md +0 -291
- package/docs/parallel.md +0 -232
- package/docs/playwright.md +0 -609
- package/docs/plugins.md +0 -1171
- package/docs/puppeteer.md +0 -316
- package/docs/quickstart.md +0 -163
- package/docs/react.md +0 -69
- package/docs/reports.md +0 -392
- package/docs/secrets.md +0 -30
- package/docs/shadow.md +0 -68
- package/docs/shared/keys.mustache +0 -31
- package/docs/shared/react.mustache +0 -1
- package/docs/testcafe.md +0 -174
- package/docs/translation.md +0 -247
- package/docs/tutorial.md +0 -271
- package/docs/typescript.md +0 -180
- package/docs/ui.md +0 -59
- package/docs/videos.md +0 -28
- package/docs/visual.md +0 -202
- package/docs/vue.md +0 -121
- package/docs/webapi/amOnPage.mustache +0 -11
- package/docs/webapi/appendField.mustache +0 -9
- package/docs/webapi/attachFile.mustache +0 -12
- package/docs/webapi/checkOption.mustache +0 -13
- package/docs/webapi/clearCookie.mustache +0 -10
- package/docs/webapi/clearField.mustache +0 -9
- package/docs/webapi/click.mustache +0 -25
- package/docs/webapi/clickLink.mustache +0 -8
- package/docs/webapi/closeCurrentTab.mustache +0 -7
- package/docs/webapi/closeOtherTabs.mustache +0 -8
- package/docs/webapi/dontSee.mustache +0 -11
- package/docs/webapi/dontSeeCheckboxIsChecked.mustache +0 -10
- package/docs/webapi/dontSeeCookie.mustache +0 -8
- package/docs/webapi/dontSeeCurrentUrlEquals.mustache +0 -10
- package/docs/webapi/dontSeeElement.mustache +0 -8
- package/docs/webapi/dontSeeElementInDOM.mustache +0 -8
- package/docs/webapi/dontSeeInCurrentUrl.mustache +0 -4
- package/docs/webapi/dontSeeInField.mustache +0 -11
- package/docs/webapi/dontSeeInSource.mustache +0 -8
- package/docs/webapi/dontSeeInTitle.mustache +0 -8
- package/docs/webapi/doubleClick.mustache +0 -13
- package/docs/webapi/downloadFile.mustache +0 -12
- package/docs/webapi/dragAndDrop.mustache +0 -9
- package/docs/webapi/dragSlider.mustache +0 -11
- package/docs/webapi/executeAsyncScript.mustache +0 -24
- package/docs/webapi/executeScript.mustache +0 -26
- package/docs/webapi/fillField.mustache +0 -16
- package/docs/webapi/forceClick.mustache +0 -28
- package/docs/webapi/forceRightClick.mustache +0 -18
- package/docs/webapi/grabAllWindowHandles.mustache +0 -7
- package/docs/webapi/grabAttributeFrom.mustache +0 -10
- package/docs/webapi/grabAttributeFromAll.mustache +0 -9
- package/docs/webapi/grabBrowserLogs.mustache +0 -9
- package/docs/webapi/grabCookie.mustache +0 -11
- package/docs/webapi/grabCssPropertyFrom.mustache +0 -11
- package/docs/webapi/grabCssPropertyFromAll.mustache +0 -10
- package/docs/webapi/grabCurrentUrl.mustache +0 -9
- package/docs/webapi/grabCurrentWindowHandle.mustache +0 -6
- package/docs/webapi/grabDataFromPerformanceTiming.mustache +0 -20
- package/docs/webapi/grabElementBoundingRect.mustache +0 -20
- package/docs/webapi/grabGeoLocation.mustache +0 -8
- package/docs/webapi/grabHTMLFrom.mustache +0 -10
- package/docs/webapi/grabHTMLFromAll.mustache +0 -9
- package/docs/webapi/grabNumberOfOpenTabs.mustache +0 -8
- package/docs/webapi/grabNumberOfVisibleElements.mustache +0 -9
- package/docs/webapi/grabPageScrollPosition.mustache +0 -8
- package/docs/webapi/grabPopupText.mustache +0 -5
- package/docs/webapi/grabSource.mustache +0 -8
- package/docs/webapi/grabTextFrom.mustache +0 -10
- package/docs/webapi/grabTextFromAll.mustache +0 -9
- package/docs/webapi/grabTitle.mustache +0 -8
- package/docs/webapi/grabValueFrom.mustache +0 -9
- package/docs/webapi/grabValueFromAll.mustache +0 -8
- package/docs/webapi/moveCursorTo.mustache +0 -12
- package/docs/webapi/openNewTab.mustache +0 -7
- package/docs/webapi/pressKey.mustache +0 -12
- package/docs/webapi/pressKeyDown.mustache +0 -12
- package/docs/webapi/pressKeyUp.mustache +0 -12
- package/docs/webapi/pressKeyWithKeyNormalization.mustache +0 -60
- package/docs/webapi/refreshPage.mustache +0 -6
- package/docs/webapi/resizeWindow.mustache +0 -6
- package/docs/webapi/rightClick.mustache +0 -14
- package/docs/webapi/saveElementScreenshot.mustache +0 -10
- package/docs/webapi/saveScreenshot.mustache +0 -12
- package/docs/webapi/say.mustache +0 -10
- package/docs/webapi/scrollIntoView.mustache +0 -11
- package/docs/webapi/scrollPageToBottom.mustache +0 -6
- package/docs/webapi/scrollPageToTop.mustache +0 -6
- package/docs/webapi/scrollTo.mustache +0 -12
- package/docs/webapi/see.mustache +0 -11
- package/docs/webapi/seeAttributesOnElements.mustache +0 -9
- package/docs/webapi/seeCheckboxIsChecked.mustache +0 -10
- package/docs/webapi/seeCookie.mustache +0 -8
- package/docs/webapi/seeCssPropertiesOnElements.mustache +0 -9
- package/docs/webapi/seeCurrentUrlEquals.mustache +0 -11
- package/docs/webapi/seeElement.mustache +0 -8
- package/docs/webapi/seeElementInDOM.mustache +0 -8
- package/docs/webapi/seeInCurrentUrl.mustache +0 -8
- package/docs/webapi/seeInField.mustache +0 -12
- package/docs/webapi/seeInPopup.mustache +0 -8
- package/docs/webapi/seeInSource.mustache +0 -7
- package/docs/webapi/seeInTitle.mustache +0 -8
- package/docs/webapi/seeNumberOfElements.mustache +0 -11
- package/docs/webapi/seeNumberOfVisibleElements.mustache +0 -10
- package/docs/webapi/seeTextEquals.mustache +0 -9
- package/docs/webapi/seeTitleEquals.mustache +0 -8
- package/docs/webapi/selectOption.mustache +0 -21
- package/docs/webapi/setCookie.mustache +0 -16
- package/docs/webapi/setGeoLocation.mustache +0 -12
- package/docs/webapi/switchTo.mustache +0 -9
- package/docs/webapi/switchToNextTab.mustache +0 -10
- package/docs/webapi/switchToPreviousTab.mustache +0 -10
- package/docs/webapi/type.mustache +0 -18
- package/docs/webapi/uncheckOption.mustache +0 -13
- package/docs/webapi/wait.mustache +0 -8
- package/docs/webapi/waitForClickable.mustache +0 -11
- package/docs/webapi/waitForDetached.mustache +0 -10
- package/docs/webapi/waitForElement.mustache +0 -11
- package/docs/webapi/waitForEnabled.mustache +0 -6
- package/docs/webapi/waitForFunction.mustache +0 -17
- package/docs/webapi/waitForInvisible.mustache +0 -10
- package/docs/webapi/waitForText.mustache +0 -13
- package/docs/webapi/waitForValue.mustache +0 -10
- package/docs/webapi/waitForVisible.mustache +0 -10
- package/docs/webapi/waitInUrl.mustache +0 -9
- package/docs/webapi/waitNumberOfVisibleElements.mustache +0 -10
- package/docs/webapi/waitToHide.mustache +0 -10
- package/docs/webapi/waitUrlEquals.mustache +0 -10
- package/docs/webdriver.md +0 -657
- package/docs/wiki/Books-&-Posts.md +0 -27
- package/docs/wiki/Community-Helpers-&-Plugins.md +0 -49
- package/docs/wiki/Converting-Playwright-to-Istanbul-Coverage.md +0 -29
- package/docs/wiki/Examples.md +0 -139
- package/docs/wiki/Google-Summer-of-Code-(GSoC)-2020.md +0 -68
- package/docs/wiki/Home.md +0 -16
- package/docs/wiki/Release-Process.md +0 -24
- package/docs/wiki/Roadmap.md +0 -23
- package/docs/wiki/Tests.md +0 -1393
- package/docs/wiki/Upgrading-to-CodeceptJS-3.md +0 -153
- package/docs/wiki/Videos.md +0 -19
package/docs/reports.md
DELETED
|
@@ -1,392 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
permalink: /reports
|
|
3
|
-
title: Reporters
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Reporters
|
|
7
|
-
|
|
8
|
-
## Cli
|
|
9
|
-
|
|
10
|
-
By default, CodeceptJS provides cli reporter with console output.
|
|
11
|
-
Test names and failures will be printed out on screen.
|
|
12
|
-
|
|
13
|
-
```sh
|
|
14
|
-
GitHub --
|
|
15
|
-
✓ search in 2577ms
|
|
16
|
-
✓ signin in 2170ms
|
|
17
|
-
✖ register in 1306ms
|
|
18
|
-
|
|
19
|
-
-- FAILURES:
|
|
20
|
-
|
|
21
|
-
1) GitHub: register:
|
|
22
|
-
Field q not found by name|text|CSS|XPath
|
|
23
|
-
|
|
24
|
-
Scenario Steps:
|
|
25
|
-
|
|
26
|
-
- I.fillField("q", "aaa") at examples/github_test.js:29:7
|
|
27
|
-
- I.fillField("user[password]", "user@user.com") at examples/github_test.js:28:7
|
|
28
|
-
- I.fillField("user[email]", "user@user.com") at examples/github_test.js:27:7
|
|
29
|
-
- I.fillField("user[login]", "User") at examples/github_test.js:26:7
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
Run with --verbose flag to see NodeJS stacktrace
|
|
34
|
-
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
output steps use `--steps` option:
|
|
38
|
-
```
|
|
39
|
-
npx codeceptjs run --steps
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
Output:
|
|
43
|
-
|
|
44
|
-
```sh
|
|
45
|
-
GitHub --
|
|
46
|
-
search
|
|
47
|
-
• I am on page "https://github.com"
|
|
48
|
-
• I am on page "https://github.com/search"
|
|
49
|
-
• I fill field "Search GitHub", "CodeceptJS"
|
|
50
|
-
• I press key "Enter"
|
|
51
|
-
• I see "Codeception/CodeceptJS", "a"
|
|
52
|
-
✓ OK in 2681ms
|
|
53
|
-
|
|
54
|
-
signin
|
|
55
|
-
• I am on page "https://github.com"
|
|
56
|
-
• I click "Sign in"
|
|
57
|
-
• I see "Sign in to GitHub"
|
|
58
|
-
• I fill field "Username or email address", "something@totest.com"
|
|
59
|
-
• I fill field "Password", "123456"
|
|
60
|
-
• I click "Sign in"
|
|
61
|
-
• I see "Incorrect username or password.", ".flash-error"
|
|
62
|
-
✓ OK in 2252ms
|
|
63
|
-
|
|
64
|
-
register
|
|
65
|
-
• I am on page "https://github.com"
|
|
66
|
-
Within .js-signup-form:
|
|
67
|
-
• I fill field "user[login]", "User"
|
|
68
|
-
• I fill field "user[email]", "user@user.com"
|
|
69
|
-
• I fill field "user[password]", "user@user.com"
|
|
70
|
-
• I fill field "q", "aaa"
|
|
71
|
-
✖ FAILED in 1260ms
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
To get additional information about test execution use `--debug` option.
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
```
|
|
78
|
-
npx codeceptjs run --debug
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
This will show execution steps
|
|
83
|
-
as well as notices from test runner. To get even more information with more technical details like error stack traces,
|
|
84
|
-
and global promises, or events use `--verbose` mode.
|
|
85
|
-
|
|
86
|
-
```
|
|
87
|
-
npx codeceptjs run --verbose
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
```sh
|
|
91
|
-
GitHub --
|
|
92
|
-
register
|
|
93
|
-
[1] Starting recording promises
|
|
94
|
-
Emitted | test.before
|
|
95
|
-
> WebDriver._before
|
|
96
|
-
[1] Queued | hook WebDriver._before()
|
|
97
|
-
[1] Queued | amOnPage: https://github.com
|
|
98
|
-
Emitted | step.before (I am on page "https://github.com")
|
|
99
|
-
• I am on page "https://github.com"
|
|
100
|
-
Emitted | step.after (I am on page "https://github.com")
|
|
101
|
-
Emitted | test.start ([object Object])
|
|
102
|
-
...
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
Please use verbose output when reporting issues to GitHub.
|
|
106
|
-
|
|
107
|
-
### Dry Run
|
|
108
|
-
|
|
109
|
-
There is a way to list all tests and their steps without actually executing them. Execute tests in `dry-run` mode to see all available tests:
|
|
110
|
-
|
|
111
|
-
```
|
|
112
|
-
npx codeceptjs dry-run
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
Output:
|
|
116
|
-
|
|
117
|
-
```
|
|
118
|
-
Tests from /home/davert/projects/codeceptjs/examples:
|
|
119
|
-
|
|
120
|
-
Business rules --
|
|
121
|
-
☐ do something
|
|
122
|
-
Google --
|
|
123
|
-
☐ test @123
|
|
124
|
-
GitHub -- /home/davert/projects/codeceptjs/examples/github_test.js
|
|
125
|
-
☐ Visit Home Page @retry
|
|
126
|
-
☐ search @grop
|
|
127
|
-
☐ signin @normal @important @slow
|
|
128
|
-
☐ signin2
|
|
129
|
-
☐ register
|
|
130
|
-
|
|
131
|
-
Total: 3 suites | 7 tests
|
|
132
|
-
|
|
133
|
-
--- DRY MODE: No tests were executed ---
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
Pass `--steps` or `--debug` option as in `run` command to also get steps and substeps to be printed. In this mode **tests will be executed** but all helpers and plugins disabled, so no real actions will be performed.
|
|
137
|
-
|
|
138
|
-
```
|
|
139
|
-
npx codecepjs dry-run --debug
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
> ℹ If you use custom JavaScript code inside tests, or rely on values from `grab*` commands, dry-run may produce error output.
|
|
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
|
-
|
|
186
|
-
|
|
187
|
-
## ReportPortal
|
|
188
|
-
|
|
189
|
-
For enterprise grade we reporting we recommend using [ReportPortal](https://reportportal.io).
|
|
190
|
-
|
|
191
|
-

|
|
192
|
-
|
|
193
|
-
[ReportPortal](https://reportportal.io) is open-source self-hosted service for aggregating test execution reports.
|
|
194
|
-
Think of it as Kibana but for test reports.
|
|
195
|
-
|
|
196
|
-
Use official [CodeceptJS Agent for ReportPortal](https://github.com/reportportal/agent-js-codecept/) to start publishing your test results.
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
## XML
|
|
200
|
-
|
|
201
|
-
Use default xunit reporter of Mocha to print xml reports. Provide `--reporter xunit` to get the report to screen.
|
|
202
|
-
It is recommended to use more powerful [`mocha-junit-reporter`](https://www.npmjs.com/package/mocha-junit-reporter) package
|
|
203
|
-
to get better support for Jenkins CI.
|
|
204
|
-
|
|
205
|
-
Install it via NPM (locally or globally, depending on CodeceptJS installation type):
|
|
206
|
-
|
|
207
|
-
```sh
|
|
208
|
-
npm i mocha-junit-reporter
|
|
209
|
-
```
|
|
210
|
-
|
|
211
|
-
Additional configuration should be added to `codecept.conf.js` to print xml report to `output` directory:
|
|
212
|
-
|
|
213
|
-
```json
|
|
214
|
-
"mocha": {
|
|
215
|
-
"reporterOptions": {
|
|
216
|
-
"mochaFile": "output/result.xml"
|
|
217
|
-
}
|
|
218
|
-
},
|
|
219
|
-
```
|
|
220
|
-
|
|
221
|
-
Execute CodeceptJS with JUnit reporter:
|
|
222
|
-
|
|
223
|
-
```sh
|
|
224
|
-
codeceptjs run --reporter mocha-junit-reporter
|
|
225
|
-
```
|
|
226
|
-
|
|
227
|
-
Result will be located at `output/result.xml` file.
|
|
228
|
-
|
|
229
|
-
## Html
|
|
230
|
-
|
|
231
|
-
Best HTML reports could be produced with [mochawesome](https://www.npmjs.com/package/mochawesome) reporter.
|
|
232
|
-
|
|
233
|
-

|
|
234
|
-
|
|
235
|
-
Install it via NPM:
|
|
236
|
-
|
|
237
|
-
```sh
|
|
238
|
-
npm i mochawesome
|
|
239
|
-
```
|
|
240
|
-
|
|
241
|
-
If you get an error like this
|
|
242
|
-
```sh
|
|
243
|
-
"mochawesome" reporter not found
|
|
244
|
-
|
|
245
|
-
invalid reporter "mochawesome"
|
|
246
|
-
```
|
|
247
|
-
|
|
248
|
-
Make sure to have mocha installed or install it:
|
|
249
|
-
|
|
250
|
-
```sh
|
|
251
|
-
npm i mocha -D
|
|
252
|
-
```
|
|
253
|
-
|
|
254
|
-
Configure it to use `output` directory to print HTML reports:
|
|
255
|
-
|
|
256
|
-
```json
|
|
257
|
-
"mocha": {
|
|
258
|
-
"reporterOptions": {
|
|
259
|
-
"reportDir": "output"
|
|
260
|
-
}
|
|
261
|
-
},
|
|
262
|
-
```
|
|
263
|
-
|
|
264
|
-
Execute CodeceptJS with HTML reporter:
|
|
265
|
-
|
|
266
|
-
```sh
|
|
267
|
-
codeceptjs run --reporter mochawesome
|
|
268
|
-
```
|
|
269
|
-
|
|
270
|
-
Result will be located at `output/index.html` file.
|
|
271
|
-
|
|
272
|
-
### Advanced usage
|
|
273
|
-
|
|
274
|
-
Want to have screenshots for failed tests?
|
|
275
|
-
Then add Mochawesome helper to your config:
|
|
276
|
-
|
|
277
|
-
```json
|
|
278
|
-
"helpers": {
|
|
279
|
-
"Mochawesome": {
|
|
280
|
-
"uniqueScreenshotNames": "true"
|
|
281
|
-
}
|
|
282
|
-
},
|
|
283
|
-
```
|
|
284
|
-
|
|
285
|
-
Then tests with failure will have screenshots.
|
|
286
|
-
|
|
287
|
-
### Configuration
|
|
288
|
-
|
|
289
|
-
This helper should be configured in codecept.conf.ts
|
|
290
|
-
|
|
291
|
-
- `uniqueScreenshotNames` (optional, default: false) - option to prevent screenshot override if you have scenarios with the same name in different suites. This option should be the same as in common helper.
|
|
292
|
-
- `disableScreenshots` (optional, default: false) - don't save screenshot on failure. This option should be the same as in common helper.
|
|
293
|
-
|
|
294
|
-
Also if you will add Mochawesome helper, then you will able to add custom context in report:
|
|
295
|
-
|
|
296
|
-
#### addMochawesomeContext
|
|
297
|
-
|
|
298
|
-
Adds context to executed test in HTML report:
|
|
299
|
-
|
|
300
|
-
```js
|
|
301
|
-
I.addMochawesomeContext('simple string');
|
|
302
|
-
I.addMochawesomeContext('http://www.url.com/pathname');
|
|
303
|
-
I.addMochawesomeContext('http://www.url.com/screenshot-maybe.jpg');
|
|
304
|
-
I.addMochawesomeContext({title: 'expected output',
|
|
305
|
-
value: {
|
|
306
|
-
a: 1,
|
|
307
|
-
b: '2',
|
|
308
|
-
c: 'd'
|
|
309
|
-
}
|
|
310
|
-
});
|
|
311
|
-
```
|
|
312
|
-
|
|
313
|
-
##### Parameters
|
|
314
|
-
|
|
315
|
-
- `context` string, url, path to screenshot, object. See [this](https://www.npmjs.com/package/mochawesome#adding-test-context)
|
|
316
|
-
|
|
317
|
-
## Multi Reports
|
|
318
|
-
|
|
319
|
-
Want to use several reporters in the same time? Try to use [mocha-multi](https://www.npmjs.com/package/mocha-multi) reporter
|
|
320
|
-
|
|
321
|
-
Install it via NPM:
|
|
322
|
-
|
|
323
|
-
```sh
|
|
324
|
-
npm i mocha-multi
|
|
325
|
-
```
|
|
326
|
-
|
|
327
|
-
Configure mocha-multi with reports that you want:
|
|
328
|
-
|
|
329
|
-
```json
|
|
330
|
-
"mocha": {
|
|
331
|
-
"reporterOptions": {
|
|
332
|
-
"codeceptjs-cli-reporter": {
|
|
333
|
-
"stdout": "-",
|
|
334
|
-
"options": {
|
|
335
|
-
"verbose": true,
|
|
336
|
-
"steps": true,
|
|
337
|
-
}
|
|
338
|
-
},
|
|
339
|
-
"mochawesome": {
|
|
340
|
-
"stdout": "./output/console.log",
|
|
341
|
-
"options": {
|
|
342
|
-
"reportDir": "./output",
|
|
343
|
-
"reportFilename": "report"
|
|
344
|
-
}
|
|
345
|
-
},
|
|
346
|
-
"mocha-junit-reporter": {
|
|
347
|
-
"stdout": "./output/console.log",
|
|
348
|
-
"options": {
|
|
349
|
-
"mochaFile": "./output/result.xml",
|
|
350
|
-
"attachments": true //add screenshot for a failed test
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
```
|
|
356
|
-
|
|
357
|
-
Execute CodeceptJS with mocha-multi reporter:
|
|
358
|
-
|
|
359
|
-
```sh
|
|
360
|
-
npx codeceptjs run --reporter mocha-multi
|
|
361
|
-
```
|
|
362
|
-
|
|
363
|
-
This will give you cli with steps in console and HTML report in `output` directory.
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
## Testrail
|
|
367
|
-
|
|
368
|
-
Testrail integration with CodeceptJS is now so seamless. The test run is created automatically afterwards. The screenshots of failed tests are also attached to test results.
|
|
369
|
-
|
|
370
|
-
Try to use [codeceptjs-testrail](https://www.npmjs.com/package/codeceptjs-testrail) plugin
|
|
371
|
-
|
|
372
|
-
Install it via NPM:
|
|
373
|
-
|
|
374
|
-
```sh
|
|
375
|
-
npm i codeceptjs-testrail --save
|
|
376
|
-
```
|
|
377
|
-
|
|
378
|
-

|
|
379
|
-
|
|
380
|
-
Now there is new feature, add the configuration to test run of test plan
|
|
381
|
-

|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
## Tesults
|
|
385
|
-
|
|
386
|
-
Submit test results data from CodeceptJS to [Tesults](https://www.tesults.com) easily with the [codeceptjs-tesults](https://www.npmjs.com/package/codeceptjs-tesults) plugin. Test results data is submitted automatically after a test run completes.
|
|
387
|
-
|
|
388
|
-
```sh
|
|
389
|
-
npm i codeceptjs-tesults --save
|
|
390
|
-
```
|
|
391
|
-
|
|
392
|
-
Once installed, follow the [quick and easy integration instructions](https://www.tesults.com/docs/codeceptjs) to get setup in no time.
|
package/docs/secrets.md
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
# Secrets
|
|
2
|
-
|
|
3
|
-
It is possible to **mask out sensitive data** when passing it to steps. This is important when filling password fields, or sending secure keys to API endpoint.
|
|
4
|
-
|
|
5
|
-
Wrap data in `secret` function to mask sensitive values in output and logs.
|
|
6
|
-
|
|
7
|
-
For basic string `secret` just wrap a value into a string:
|
|
8
|
-
|
|
9
|
-
```js
|
|
10
|
-
I.fillField('password', secret('123456'));
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
When executed it will be printed like this:
|
|
14
|
-
|
|
15
|
-
```
|
|
16
|
-
I fill field "password" "*****"
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
For an object, which can be a payload to POST request, specify which fields should be masked:
|
|
20
|
-
|
|
21
|
-
```js
|
|
22
|
-
I.sendPostRequest('/login', secret({
|
|
23
|
-
name: 'davert',
|
|
24
|
-
password: '123456'
|
|
25
|
-
}, 'password'))
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
The object created from `secret` is as Proxy to the object passed in. When printed password will be replaced with ****.
|
|
29
|
-
|
|
30
|
-
> ⚠️ Only direct properties of the object can be masked via `secret`
|
package/docs/shadow.md
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
permalink: /shadow
|
|
3
|
-
title: Locating Shadow Dom Elements
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Locating Shadow Dom Elements
|
|
7
|
-
|
|
8
|
-
> ℹ Shadow DOM locators is supported only in WebDriver helper
|
|
9
|
-
|
|
10
|
-
Shadow DOM is one of the key browser features that make up web components. Web components are a really great way to build reusable elements, and are able to scale all the way up to complete web applications. Style encapsulation, the feature that gives shadow DOM it's power, has been a bit of a pain when it comes to E2E or UI testing. Things just got a little easier though, as CodeceptJS introduced built-in support for shadow DOM via locators of type `shadow`. Let's dig into what they're all about.
|
|
11
|
-
|
|
12
|
-
Generated HTML code may often look like this (ref: [Salesforce's Lighting Web Components](https://github.com/salesforce/lwc)):
|
|
13
|
-
|
|
14
|
-
```js
|
|
15
|
-
<body>
|
|
16
|
-
<my-app>
|
|
17
|
-
<recipe-hello>
|
|
18
|
-
<button>Click Me!</button>
|
|
19
|
-
</recipe-hello>
|
|
20
|
-
<recipe-hello-binding>
|
|
21
|
-
<ui-input>
|
|
22
|
-
<input type="text" class="input">
|
|
23
|
-
</ui-input>
|
|
24
|
-
</recipe-hello-binding>
|
|
25
|
-
</my-app>
|
|
26
|
-
</body>
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
This uses custom elements, `my-app`, `recipe-hello`, `recipe-hello-binding` and `ui-input`. It's quite common that clickable elements are not actual `a` or `button` elements but custom elements. This way `I.click('Click Me!');` won't work, as well as `fillField('.input', 'value)`. Finding a correct locator for such cases turns to be almost impossible until `shadow` element support is added to CodeceptJS.
|
|
30
|
-
|
|
31
|
-
## Locate Shadow Dom
|
|
32
|
-
|
|
33
|
-
For Web Components or [Salesforce's Lighting Web Components](https://github.com/salesforce/lwc) with Shadow DOM's, a special `shadow` locator is available. It allows to select an element by its shadow dom sequences and sequences are defined as an Array of `elements`. Elements defined in the array of `elements` must be in the ordered the shadow elements appear in the DOM.
|
|
34
|
-
|
|
35
|
-
```js
|
|
36
|
-
{ shadow: ['my-app', 'recipe-hello', 'button'] }
|
|
37
|
-
{ shadow: ['my-app', 'recipe-hello-binding', 'ui-input', 'input.input'] }
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
In WebDriver, you can use shadow locators in any method where locator is required.
|
|
41
|
-
|
|
42
|
-
For example, to fill value in `input` field or to click the `Click Me!` button, in above HTML code:
|
|
43
|
-
|
|
44
|
-
```js
|
|
45
|
-
I.fillField({ shadow: ['my-app', 'recipe-hello-binding', 'ui-input', 'input.input'] }, 'value');
|
|
46
|
-
I.click({ shadow: ['my-app', 'recipe-hello', 'button'] });
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
## Example
|
|
50
|
-
|
|
51
|
-
```js
|
|
52
|
-
Feature('Shadow Dom Locators');
|
|
53
|
-
|
|
54
|
-
Scenario('should fill input field within shadow elements', ({I}) => {
|
|
55
|
-
|
|
56
|
-
// navigate to LWC webpage containing shadow dom
|
|
57
|
-
I.amOnPage('https://recipes.lwc.dev/');
|
|
58
|
-
|
|
59
|
-
// click Click Me! button
|
|
60
|
-
I.click({ shadow: ['my-app', 'recipe-hello', 'button'] });
|
|
61
|
-
|
|
62
|
-
// fill the input field
|
|
63
|
-
I.fillField({ shadow: ['my-app', 'recipe-hello-binding', 'ui-input', 'input.input'] }, 'value');
|
|
64
|
-
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
```
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
[Valid key names](https://w3c.github.io/webdriver/#keyboard-actions) are:
|
|
2
|
-
|
|
3
|
-
- `'Add'`,
|
|
4
|
-
- `'Alt'`,
|
|
5
|
-
- `'ArrowDown'` or `'Down arrow'`,
|
|
6
|
-
- `'ArrowLeft'` or `'Left arrow'`,
|
|
7
|
-
- `'ArrowRight'` or `'Right arrow'`,
|
|
8
|
-
- `'ArrowUp'` or `'Up arrow'`,
|
|
9
|
-
- `'Backspace'`,
|
|
10
|
-
- `'Command'`,
|
|
11
|
-
- `'Control'`,
|
|
12
|
-
- `'Del'`,
|
|
13
|
-
- `'Divide'`,
|
|
14
|
-
- `'End'`,
|
|
15
|
-
- `'Enter'`,
|
|
16
|
-
- `'Equals'`,
|
|
17
|
-
- `'Escape'`,
|
|
18
|
-
- `'F1 to F12'`,
|
|
19
|
-
- `'Home'`,
|
|
20
|
-
- `'Insert'`,
|
|
21
|
-
- `'Meta'`,
|
|
22
|
-
- `'Multiply'`,
|
|
23
|
-
- `'Numpad 0'` to `'Numpad 9'`,
|
|
24
|
-
- `'Pagedown'` or `'PageDown'`,
|
|
25
|
-
- `'Pageup'` or `'PageUp'`,
|
|
26
|
-
- `'Pause'`,
|
|
27
|
-
- `'Semicolon'`,
|
|
28
|
-
- `'Shift'`,
|
|
29
|
-
- `'Space'`,
|
|
30
|
-
- `'Subtract'`,
|
|
31
|
-
- `'Tab'`.
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
This action supports [React locators](https://codecept.io/react#locators)
|
package/docs/testcafe.md
DELETED
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
permalink: /testcafe
|
|
3
|
-
title: Testing with TestCafe
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Testing with TestCafe
|
|
7
|
-
|
|
8
|
-
[TestCafe](https://devexpress.github.io/testcafe/) is another alternative engine for driving browsers. It is driven by unique technology which provides fast and simple cross browser testing for desktop and mobile browsers. Unlike WebDriver or Puppeteer, TestCafe doesn't control a browser at all. It is not a browser itself, like [Nightmare](/nightmare) or Cypress. **TestCafe core is a proxy server** that runs behind the scene, and transforms all HTML and JS to include code that is needed for test automation.
|
|
9
|
-
|
|
10
|
-

|
|
11
|
-
|
|
12
|
-
This is very smart idea. But to use TestCafe on daily basis you need to clearly understand its benefits and limitations:
|
|
13
|
-
|
|
14
|
-
### Pros
|
|
15
|
-
|
|
16
|
-
* **Fast**. Browser is controlled from inside a web page. This makes test run inside a browser as fast as your browser can render page with no extra network requests.
|
|
17
|
-
* **Simple Cross-Browser Support.** Because TestCafe only launches browsers, it can **automate browser** on desktop or mobile. Unlike WebDriver, you don't need special version of browser and driver to prepare to run tests. Setup simplified. All you need is just a browser installed, and you are ready to go.
|
|
18
|
-
* **Stable to Execution.** Because a test is executed inside a browser, the network latency effects are reduced. Unlike WebDriver you won't hit stale element exceptions, or element not interactable exceptions, as from within a web browser all DOM elements are accessible.
|
|
19
|
-
|
|
20
|
-
## Cons
|
|
21
|
-
|
|
22
|
-
* **Magic.** Browsers executed in TestCafe are not aware that they run in test mode. So at some edges automation control can be broken. It's also quite hard to debug possible issues, as you don't know how actually a web page is parsed to inject automation scripts.
|
|
23
|
-
* **No Browser Control.** Because TestCafe do not control browser, you can't actually automate all users actions. For instance, TestCafe can't open new tabs or open a new browser window in incognito mode. There can be also some issues running tests on 3rd party servers or inside iframes.
|
|
24
|
-
* **Simulated Events.** Events like `click` or `doubleClick` are simulated by JavaScript internally. Inside WebDriver or Puppeteer, where those events are dispatched by a browser, called native events. Native events are closer to real user experience. So in some cases simulated events wouldn't represent actual user experience, which can lead to false positive results. For instance, a button which can't be physically clicked by a user, would be clickable inside TestCafe.
|
|
25
|
-
|
|
26
|
-
Anyway, TestCafe is a good option to start if you need cross browser testing. And here is the **reason to use TestCafe with CodeceptJS: if you hit an edge case or issue, you can easily switch your tests to WebDriver**. As all helpers in CodeceptJS share the same syntax.
|
|
27
|
-
|
|
28
|
-
CodeceptJS is a rich testing frameworks which also provides features missing in original TestCafe:
|
|
29
|
-
|
|
30
|
-
* [Cucumber integration](/bdd)
|
|
31
|
-
* [Real Page Objects](/pageobjects)
|
|
32
|
-
* [Data Management via API](/data)
|
|
33
|
-
* and others
|
|
34
|
-
|
|
35
|
-
## Writing Tests
|
|
36
|
-
|
|
37
|
-
To start using TestCafe with CodeceptJS install both via NPM
|
|
38
|
-
|
|
39
|
-
> If you don't have `package.json` in your project, create it with `npm init -y`.
|
|
40
|
-
|
|
41
|
-
```
|
|
42
|
-
npm i codeceptjs testcafe --save-dev
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
Then you need to initialize a project, selecting TestCafe when asked:
|
|
46
|
-
|
|
47
|
-
```
|
|
48
|
-
npx codeceptjs init
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
A first test should be created with `codeceptjs gt` command
|
|
52
|
-
|
|
53
|
-
```
|
|
54
|
-
npx codeceptjs gt
|
|
55
|
-
```
|
|
56
|
-
|
|
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
|
-
|
|
59
|
-
```js
|
|
60
|
-
Feature('TodoMVC');
|
|
61
|
-
|
|
62
|
-
Scenario('create todo item', ({ I }) => {
|
|
63
|
-
I.amOnPage('http://todomvc.com/examples/angularjs/#/');
|
|
64
|
-
I.fillField('.new-todo', todo)
|
|
65
|
-
I.pressKey('Enter');
|
|
66
|
-
I.seeNumberOfVisibleElements('.todo-list li', 1);
|
|
67
|
-
I.see('1 item left', '.todo-count');
|
|
68
|
-
});
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
Same syntax is the same for all helpers in CodeceptJS so to learn more about available commands learn [CodeceptJS Basics](/basics).
|
|
72
|
-
|
|
73
|
-
> [▶ Complete list of TestCafe actions](/helpers/TestCafe)
|
|
74
|
-
|
|
75
|
-
## Page Objects
|
|
76
|
-
|
|
77
|
-
Multiple tests can be refactored to share some logic and locators. It is recommended to use PageObjects for this. For instance, in example above, we could create special actions for creating todos and checking them. If we move such methods in a corresponding object a test would look even clearer:
|
|
78
|
-
|
|
79
|
-
```js
|
|
80
|
-
Scenario('Create a new todo item', async ({ I, TodosPage }) => {
|
|
81
|
-
I.say('Given I have an empty todo list')
|
|
82
|
-
|
|
83
|
-
I.say('When I create a todo "foo"')
|
|
84
|
-
TodosPage.enterTodo('foo')
|
|
85
|
-
|
|
86
|
-
I.say('Then I see the new todo on my list')
|
|
87
|
-
TodosPage.seeNumberOfTodos(1)
|
|
88
|
-
|
|
89
|
-
I.saveScreenshot('create-todo-item.png')
|
|
90
|
-
})
|
|
91
|
-
|
|
92
|
-
Scenario('Create multiple todo items', async ({ I, TodosPage }) => {
|
|
93
|
-
I.say('Given I have an empty todo list')
|
|
94
|
-
|
|
95
|
-
I.say('When I create todos "foo", "bar" and "baz"')
|
|
96
|
-
TodosPage.enterTodo('foo')
|
|
97
|
-
TodosPage.enterTodo('bar')
|
|
98
|
-
TodosPage.enterTodo('baz')
|
|
99
|
-
|
|
100
|
-
I.say('Then I have these 3 todos on my list')
|
|
101
|
-
TodosPage.seeNumberOfTodos(3)
|
|
102
|
-
|
|
103
|
-
I.saveScreenshot('create-multiple-todo-items.png')
|
|
104
|
-
})
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
> ℹ [Source code of this example](https://github.com/hubidu/codeceptjs-testcafe-todomvc) is available on GitHub.
|
|
108
|
-
|
|
109
|
-
A PageObject can be injected into a test by its name. Here is how TodosPage looks like:
|
|
110
|
-
|
|
111
|
-
```js
|
|
112
|
-
// inside todos_page.js
|
|
113
|
-
const { I } = inject();
|
|
114
|
-
|
|
115
|
-
module.exports = {
|
|
116
|
-
goto() {
|
|
117
|
-
I.amOnPage('http://todomvc.com/examples/angularjs/#/')
|
|
118
|
-
},
|
|
119
|
-
|
|
120
|
-
enterTodo(todo) {
|
|
121
|
-
I.fillField('.new-todo', todo)
|
|
122
|
-
I.pressKey('Enter')
|
|
123
|
-
},
|
|
124
|
-
|
|
125
|
-
seeNumberOfTodos(numberOfTodos) {
|
|
126
|
-
I.seeNumberOfVisibleElements('.todo-list li', numberOfTodos)
|
|
127
|
-
},
|
|
128
|
-
}
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
> [▶ Read more about PageObjects in CodeceptJS](/pageobjects)
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
## Accessing TestCafe API
|
|
135
|
-
|
|
136
|
-
To get [testController](https://devexpress.github.io/testcafe/documentation/test-api/test-code-structure.html#test-controller))) inside a test use [`I.useTestCafeTo`](/helpers/TestCafe/#usetestcafeto) method with a callback.
|
|
137
|
-
To keep test readable provide a description of a callback inside the first parameter.
|
|
138
|
-
|
|
139
|
-
```js
|
|
140
|
-
I.useTestCafeTo('do some things using native webdriverio api', async ({ t }) => {
|
|
141
|
-
await t.click() // use testcafe api here
|
|
142
|
-
});
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
Because all TestCafe commands are asynchronous a callback function must be async.
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
## Extending
|
|
149
|
-
|
|
150
|
-
If you want to use TestCafe API inside your tests you can put them into actions of `I` object. To do so you can generate a new helper, access TestCafe helper, and get the test controller.
|
|
151
|
-
|
|
152
|
-
Create a helper using `codecepjs gh` command.
|
|
153
|
-
|
|
154
|
-
```
|
|
155
|
-
npx codeceptjs gh
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
All methods of newly created class will be added to `I` object.
|
|
159
|
-
|
|
160
|
-
```js
|
|
161
|
-
const Helper = codeceptjs.helper;
|
|
162
|
-
|
|
163
|
-
class MyTestCafe extends Helper {
|
|
164
|
-
|
|
165
|
-
slowlyFillField(field, text) {
|
|
166
|
-
// import test controller from TestCafe helper
|
|
167
|
-
const { t } = this.helpers.TestCafe;
|
|
168
|
-
// use TestCafe API here
|
|
169
|
-
return t.setTestSpeed(0.1)
|
|
170
|
-
.typeText(field, text);
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
}
|
|
174
|
-
```
|