codeceptjs 3.5.12-beta.5 → 3.5.12-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/lib/helper/MockServer.js +215 -0
- package/lib/helper/Playwright.js +43 -22
- package/lib/helper/Puppeteer.js +25 -6
- package/lib/helper/WebDriver.js +25 -4
- package/lib/helper/errors/ElementAssertion.js +38 -0
- package/package.json +6 -5
- package/typings/index.d.ts +16 -0
- package/typings/promiseBasedTypes.d.ts +182 -0
- package/typings/types.d.ts +182 -0
- package/docs/advanced.md +0 -351
- package/docs/ai.md +0 -248
- package/docs/api.md +0 -323
- package/docs/basics.md +0 -979
- package/docs/bdd.md +0 -539
- package/docs/best.md +0 -237
- package/docs/books.md +0 -37
- package/docs/bootstrap.md +0 -135
- package/docs/build/ApiDataFactory.js +0 -410
- package/docs/build/Appium.js +0 -2027
- package/docs/build/Expect.js +0 -422
- package/docs/build/FileSystem.js +0 -228
- package/docs/build/GraphQL.js +0 -229
- 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 -2152
- package/docs/build/OpenAI.js +0 -126
- package/docs/build/Playwright.js +0 -5110
- package/docs/build/Protractor.js +0 -2706
- package/docs/build/Puppeteer.js +0 -3905
- package/docs/build/REST.js +0 -344
- package/docs/build/TestCafe.js +0 -2125
- package/docs/build/WebDriver.js +0 -4240
- package/docs/changelog.md +0 -2572
- package/docs/commands.md +0 -266
- 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 -379
- package/docs/detox.md +0 -235
- package/docs/docker.md +0 -136
- 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 -1374
- package/docs/helpers/Detox.md +0 -586
- package/docs/helpers/Expect.md +0 -275
- package/docs/helpers/FileSystem.md +0 -152
- package/docs/helpers/GraphQL.md +0 -151
- 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 -1305
- package/docs/helpers/OpenAI.md +0 -70
- package/docs/helpers/Playwright.md +0 -2759
- package/docs/helpers/Polly.md +0 -44
- package/docs/helpers/Protractor.md +0 -1769
- package/docs/helpers/Puppeteer-firefox.md +0 -86
- package/docs/helpers/Puppeteer.md +0 -2317
- package/docs/helpers/REST.md +0 -218
- package/docs/helpers/TestCafe.md +0 -1321
- package/docs/helpers/WebDriver.md +0 -2547
- package/docs/hooks.md +0 -340
- package/docs/index.md +0 -111
- package/docs/installation.md +0 -75
- package/docs/internal-api.md +0 -266
- package/docs/locators.md +0 -339
- package/docs/mobile-react-native-locators.md +0 -67
- package/docs/mobile.md +0 -338
- package/docs/pageobjects.md +0 -291
- package/docs/parallel.md +0 -400
- package/docs/playwright.md +0 -632
- package/docs/plugins.md +0 -1259
- package/docs/puppeteer.md +0 -316
- package/docs/quickstart.md +0 -162
- package/docs/react.md +0 -70
- package/docs/reports.md +0 -392
- package/docs/secrets.md +0 -36
- 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 -143
- package/docs/webapi/amOnPage.mustache +0 -11
- package/docs/webapi/appendField.mustache +0 -11
- package/docs/webapi/attachFile.mustache +0 -12
- package/docs/webapi/blur.mustache +0 -18
- package/docs/webapi/checkOption.mustache +0 -13
- package/docs/webapi/clearCookie.mustache +0 -9
- 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/focus.mustache +0 -13
- 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/grabWebElement.mustache +0 -9
- package/docs/webapi/grabWebElements.mustache +0 -9
- 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 -21
- 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/waitForNumberOfTabs.mustache +0 -9
- 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 -701
- package/docs/wiki/Books-&-Posts.md +0 -27
- package/docs/wiki/Community-Helpers-&-Plugins.md +0 -53
- package/docs/wiki/Converting-Playwright-to-Istanbul-Coverage.md +0 -61
- package/docs/wiki/Examples.md +0 -145
- package/docs/wiki/Google-Summer-of-Code-(GSoC)-2020.md +0 -68
- package/docs/wiki/Home.md +0 -16
- package/docs/wiki/Migration-to-Appium-v2---CodeceptJS.md +0 -83
- 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/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 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
|
-
```
|
package/docs/translation.md
DELETED
|
@@ -1,247 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
permalink: /translation
|
|
3
|
-
title: Translation
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Translation
|
|
7
|
-
|
|
8
|
-
*Unique feature of CodeceptJS: write tests in your language!*
|
|
9
|
-
|
|
10
|
-
🇩🇪🇯🇵🇫🇷🇹🇼🇨🇳🇵🇱🇧🇷🇮🇹
|
|
11
|
-
|
|
12
|
-
Test output and the way tests are written can be localized. This way scenarios can be written in almost native language using UTF support of JavaScript.
|
|
13
|
-
|
|
14
|
-
If you have non-English team and you work on non-English project consider enabling translation
|
|
15
|
-
by setting translation to [one of available languages](https://github.com/codeceptjs/CodeceptJS/blob/3.x/translations) or writing vocabulary for your language.
|
|
16
|
-
|
|
17
|
-
## How it works
|
|
18
|
-
|
|
19
|
-
CodceptJS provides a high-level domain specific language (DSL) for writing end-to-end tests.
|
|
20
|
-
As CodeceptJS API is designed to provide a minimal set of methods to write test cases of any kind of complexity.
|
|
21
|
-
|
|
22
|
-
It is possible to add aliases for all CodeceptJS keywords and methods. So if all keywords and methods are translated to a specific language it is possible to write tests in that language. Sure, this is not perfect, as CSS/XPath locators as well as REST API speific words are used as is. However, writing tests in your native language may improve the team's understanding of the test behavior.
|
|
23
|
-
|
|
24
|
-
You can enable translation if your team is not from English-speaking country developing non-English product.
|
|
25
|
-
|
|
26
|
-
> ⚠️ It's important to note that default translations are far from being complete. So there are still lots of methods and keywords not translated to your language yet. We recommend to [extend a vocabulary](#extending-vocabulary) to add aliases for non-translated methods and submit a pull request with improvements to a [corresponding language file](https://github.com/codeceptjs/CodeceptJS/blob/3.x/translations).
|
|
27
|
-
|
|
28
|
-
To enable translition create a new project with
|
|
29
|
-
|
|
30
|
-
```
|
|
31
|
-
npx codeceptjs init
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
And select a language of your choice from a list:
|
|
35
|
-
|
|
36
|
-
```
|
|
37
|
-
? Do you want localization for tests? (See https://codecept.io/translation/)
|
|
38
|
-
❯ English (no localization)
|
|
39
|
-
de-DE
|
|
40
|
-
it-IT
|
|
41
|
-
fr-FR
|
|
42
|
-
ja-JP
|
|
43
|
-
pl-PL
|
|
44
|
-
pt-BR
|
|
45
|
-
(Move up and down to reveal more choices)
|
|
46
|
-
```
|
|
47
|
-
> 💡 If you don't see your language in the list but still want to use localized tests, select 'English (no localization)' and create [custom translation](#custom-translation).
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
## Languages
|
|
51
|
-
|
|
52
|
-
### Portuguese 🇧🇷
|
|
53
|
-
|
|
54
|
-
To write your tests in portuguese you can enable the portuguese translation in config file like:
|
|
55
|
-
|
|
56
|
-
```js
|
|
57
|
-
translation: "pt-BR"
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
Now you can write test like this:
|
|
61
|
-
|
|
62
|
-
```js
|
|
63
|
-
Cenário('Efetuar login', ({ Eu }) => {
|
|
64
|
-
Eu.estouNaPagina('http://minhaAplicacao.com.br');
|
|
65
|
-
Eu.preenchoOCampo("login", "usuario@minhaAplicacao.com.br");
|
|
66
|
-
Eu.preenchoOCampo("senha", "123456");
|
|
67
|
-
Eu.clico("Entrar");
|
|
68
|
-
Eu.vejo("Seja bem vindo usuário!");
|
|
69
|
-
});
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
### French 🇫🇷
|
|
73
|
-
|
|
74
|
-
To write your tests in French you can enable the French translation by adding to config:
|
|
75
|
-
|
|
76
|
-
```js
|
|
77
|
-
translation: "fr-FR"
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
Now you can write tests like this:
|
|
81
|
-
|
|
82
|
-
```js
|
|
83
|
-
Scenario('Se connecter sur GitHub', (Je) => {
|
|
84
|
-
Je.suisSurLaPage('https://github.com/login');
|
|
85
|
-
Je.remplisLeChamp("Username or email address", "jean-dupond");
|
|
86
|
-
Je.remplisLeChamp("Password", "*********");
|
|
87
|
-
Je.cliqueSur("Sign in");
|
|
88
|
-
Je.vois("Learn Git and GitHub without any code!");
|
|
89
|
-
});
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
### Italian 🇮🇹
|
|
93
|
-
|
|
94
|
-
Add to `codeceptjs.conf.js` or `codeceptjs.conf.ts` config file:
|
|
95
|
-
|
|
96
|
-
```js
|
|
97
|
-
translation: "it-IT"
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
Now you can write test like this:
|
|
101
|
-
|
|
102
|
-
```js
|
|
103
|
-
Caratteristica('Effettuare il Login su GitHub', (io) => {
|
|
104
|
-
io.sono_sulla_pagina('https://github.com/login');
|
|
105
|
-
io.compilo_il_campo("Username or email address", "giuseppe-santoro");
|
|
106
|
-
io.compilo_il_campo("Password", "*********");
|
|
107
|
-
io.faccio_click_su("Sign in");
|
|
108
|
-
io.vedo("Learn Git and GitHub without any code!");
|
|
109
|
-
});
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
### Polish 🇵🇱
|
|
113
|
-
|
|
114
|
-
Add to `codeceptjs.conf.js` or `codeceptjs.conf.ts` config file:
|
|
115
|
-
|
|
116
|
-
```js
|
|
117
|
-
translation: "pl-PL"
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
Now you can write test like this:
|
|
121
|
-
|
|
122
|
-
```js
|
|
123
|
-
Scenario('Zakładanie konta free trial na stronie głównej GetResponse', ({ Ja }) => {
|
|
124
|
-
Ja.jestem_na_stronie('https://getresponse.com');
|
|
125
|
-
Ja.wypełniam_pole("Email address", "sjakubowski@getresponse.com");
|
|
126
|
-
Ja.wypełniam_pole("Password", "digital-marketing-systems");
|
|
127
|
-
Ja.klikam('Sign up');
|
|
128
|
-
Ja.czekam(1);
|
|
129
|
-
Ja.widzę_w_adresie_url('/account_free_created.html');
|
|
130
|
-
});
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
### Chinese 🇹🇼🇨🇳
|
|
134
|
-
|
|
135
|
-
Add to `codeceptjs.conf.js` or `codeceptjs.conf.ts` config: file:
|
|
136
|
-
|
|
137
|
-
```JS
|
|
138
|
-
translation: "zh-CN"
|
|
139
|
-
```
|
|
140
|
-
or
|
|
141
|
-
```JS
|
|
142
|
-
translation: "zh-TW"
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
This way tests can be written in Chinese language while it is still JavaScript:
|
|
146
|
-
|
|
147
|
-
```JavaScript
|
|
148
|
-
Feature('CodeceptJS 演示');
|
|
149
|
-
|
|
150
|
-
Scenario('成功提交表单', ({ 我 }) => {
|
|
151
|
-
我.在页面('/documentation')
|
|
152
|
-
我.填写字段('电邮', 'hello@world.com')
|
|
153
|
-
我.填写字段('密码', '123456')
|
|
154
|
-
我.勾选选项('激活')
|
|
155
|
-
我.勾选选项('男');
|
|
156
|
-
我.单击('创建用户')
|
|
157
|
-
我.看到('用户名可用')
|
|
158
|
-
我.在当前网址中看不到('/documentation')
|
|
159
|
-
});
|
|
160
|
-
```
|
|
161
|
-
or
|
|
162
|
-
|
|
163
|
-
```JavaScript
|
|
164
|
-
Feature('CodeceptJS 演示');
|
|
165
|
-
|
|
166
|
-
Scenario('成功提交表單', ({ 我 }) => {
|
|
167
|
-
我.在頁面('/documentation')
|
|
168
|
-
我.填寫欄位('電郵', 'hello@world.com')
|
|
169
|
-
我.填寫欄位('密碼', '123456')
|
|
170
|
-
我.勾選選項('活化')
|
|
171
|
-
我.勾選選項('男');
|
|
172
|
-
我.單擊('建立用戶')
|
|
173
|
-
我.看到('用戶名可用')
|
|
174
|
-
我.在當前網址中看不到('/documentation')
|
|
175
|
-
});
|
|
176
|
-
```
|
|
177
|
-
|
|
178
|
-
### Japanese 🇯🇵
|
|
179
|
-
|
|
180
|
-
Add to `codeceptjs.conf.js` or `codeceptjs.conf.ts` config file:
|
|
181
|
-
|
|
182
|
-
```js
|
|
183
|
-
translation: "ja-JP"
|
|
184
|
-
```
|
|
185
|
-
|
|
186
|
-
Now you can write test like this:
|
|
187
|
-
|
|
188
|
-
```js
|
|
189
|
-
Scenario('ログインできる', ({ 私は }) => {
|
|
190
|
-
私は.ページを移動する('/login');
|
|
191
|
-
私は.フィールドに入力する("Eメール", "foo@example.com");
|
|
192
|
-
私は.フィールドに入力する("パスワード", "p@ssword");
|
|
193
|
-
私は.クリックする('ログイン');
|
|
194
|
-
私は.待つ(1);
|
|
195
|
-
私は.URLに含まれるか確認する('/home');
|
|
196
|
-
});
|
|
197
|
-
```
|
|
198
|
-
|
|
199
|
-
## Extending Vocabulary
|
|
200
|
-
|
|
201
|
-
To add localized aliases to more actions create a new JSON or JavaScript file returning an object with following fields:
|
|
202
|
-
|
|
203
|
-
```js
|
|
204
|
-
module.exports = {
|
|
205
|
-
actions: {
|
|
206
|
-
// add action aliases, translating method name to your language
|
|
207
|
-
rightClick: 'Rechtsklick'
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
```
|
|
211
|
-
|
|
212
|
-
Then enable this vocabulary file in codecept conf:
|
|
213
|
-
|
|
214
|
-
```js
|
|
215
|
-
// inside codecept.conf.js or codecept.conf.ts
|
|
216
|
-
// ...
|
|
217
|
-
translation: 'de_DE',
|
|
218
|
-
vocabularies: ['my_translation_file.js'],
|
|
219
|
-
```
|
|
220
|
-
|
|
221
|
-
### Custom Translation
|
|
222
|
-
|
|
223
|
-
Create translation file like this:
|
|
224
|
-
|
|
225
|
-
```js
|
|
226
|
-
module.exports = {
|
|
227
|
-
I: 'Ya',
|
|
228
|
-
contexts: {
|
|
229
|
-
Feature: 'Feature',
|
|
230
|
-
Scenario: 'Szenario',
|
|
231
|
-
Before: 'Vor',
|
|
232
|
-
After: 'Nach',
|
|
233
|
-
BeforeSuite: 'vor_der_suite',
|
|
234
|
-
AfterSuite: 'nach_der_suite',
|
|
235
|
-
},
|
|
236
|
-
actions: {
|
|
237
|
-
click: 'Klicken',
|
|
238
|
-
wait: 'Wartenn',
|
|
239
|
-
}
|
|
240
|
-
```
|
|
241
|
-
|
|
242
|
-
And add the file path to your config
|
|
243
|
-
|
|
244
|
-
```js
|
|
245
|
-
translation: "MyLang",
|
|
246
|
-
vocabularies: ["./relative/path/to/your/translation.js"]
|
|
247
|
-
```
|
package/docs/tutorial.md
DELETED
|
@@ -1,271 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
permalink: /tutorial
|
|
3
|
-
title: CodeceptJS Complete Tutorial
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Tutorial: Writing Tests for Checkout Page
|
|
7
|
-
|
|
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
|
-
|
|
10
|
-
## Let's get CodeceptJS installed!
|
|
11
|
-
|
|
12
|
-
To install CodeceptJS, you will need to have Node.js and npm (the Node.js package manager) installed on your system. You can check if you already have these tools installed by running the following commands in a terminal:
|
|
13
|
-
|
|
14
|
-
```bash
|
|
15
|
-
node --version
|
|
16
|
-
npm --version
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
If either of these commands return an error, you will need to install Node.js and npm before you can install CodeceptJS. You can download and install the latest version of Node.js from the official website, which includes npm.
|
|
20
|
-
|
|
21
|
-
To install CodeceptJS create a new folder and run command form terminal:
|
|
22
|
-
|
|
23
|
-
```
|
|
24
|
-
npx create-codeceptjs .
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
If you run the npx create-codeceptjs . command, it will install CodeceptJS with Playwright in the current directory.
|
|
28
|
-
|
|
29
|
-
> The `npx` command is a tool that comes with npm (the Node.js package manager) and it allows you to run npm packages without having to install them globally on your system.
|
|
30
|
-
|
|
31
|
-
It may take some time as it downloads browsers: Chrome, Firefox and Safari and creates a demo project.
|
|
32
|
-
|
|
33
|
-
But we are here to write a checkout test, right?
|
|
34
|
-
|
|
35
|
-
Let's initialize a new project for that!
|
|
36
|
-
|
|
37
|
-
Run
|
|
38
|
-
|
|
39
|
-
```
|
|
40
|
-
npx codeceptjs init
|
|
41
|
-
```
|
|
42
|
-
Agree on defaults (press Enter for every question asked). When asked for base site URL, provide a URL of a ecommerce website you are testing. For instance, it could be: `https://myshop.com` if you test already published website or `http://localhost` if you run the website locally.
|
|
43
|
-
|
|
44
|
-
When asked for a test name and suite name write "Checkout". It will create the following dirctory structure:
|
|
45
|
-
|
|
46
|
-
```
|
|
47
|
-
.
|
|
48
|
-
├── codecept.conf.js
|
|
49
|
-
├── package.json
|
|
50
|
-
└── Checkout_test.js
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
The `codecept.conf.js` file in the root of the project directory contains the global configuration settings for CodeceptJS.
|
|
54
|
-
|
|
55
|
-
Now open a test:
|
|
56
|
-
|
|
57
|
-
```js
|
|
58
|
-
Feature('Checkout');
|
|
59
|
-
|
|
60
|
-
Scenario('test something', ({ I }) => {
|
|
61
|
-
});
|
|
62
|
-
```
|
|
63
|
-
Inside the Scenario block you write a test.
|
|
64
|
-
|
|
65
|
-
Add `I.amOnPage('/')` into it. It will open the browser on a URL you specified as a base.
|
|
66
|
-
|
|
67
|
-
```js
|
|
68
|
-
Feature('Checkout');
|
|
69
|
-
|
|
70
|
-
Scenario('test something', ({ I }) => {
|
|
71
|
-
I.amOnPage('/')
|
|
72
|
-
});
|
|
73
|
-
```
|
|
74
|
-
But you may want to ask...
|
|
75
|
-
|
|
76
|
-
## What is I?
|
|
77
|
-
|
|
78
|
-
Glad you asked!
|
|
79
|
-
|
|
80
|
-
In CodeceptJS, the `I` object is used to represent the user performing actions in a test scenario. It provides a number of methods (also known as actions) that can be used to simulate user interactions with the application under test.
|
|
81
|
-
|
|
82
|
-
Some of the most popular actions of the I object are:
|
|
83
|
-
|
|
84
|
-
* `I.amOnPage(url)`: This action navigates the user to the specified URL.
|
|
85
|
-
* `I.click(locator)`: This action simulates a click on the element identified by the given locator.
|
|
86
|
-
* `I.fillField(field, value)`: This action fills the specified field with the given value.
|
|
87
|
-
* `I.see(text, context)`: This action checks that the given text is visible on the page (or in the specified context).
|
|
88
|
-
* `I.selectOption(select, option)`: This action selects the specified option from the given select dropdown.
|
|
89
|
-
* `I.waitForElement(locator, timeout)`: This action waits for the specified element to appear on the page, up to the given timeout.
|
|
90
|
-
* `I.waitForText(text, timeout, context)`: This action waits for the given text to appear on the page (or in the specified context), up to the given timeout.
|
|
91
|
-
|
|
92
|
-
We will need to use them to navigate into Checkout process. How do we navigate web? Sure by clicking on links!
|
|
93
|
-
|
|
94
|
-
Let's use `I.click()` for that.
|
|
95
|
-
|
|
96
|
-
But how we can access elements on a webpage?
|
|
97
|
-
|
|
98
|
-
CodeceptJS is smart enough to locate clickable elements by their visible text. For instance, if on your ecommerce website you have a product 'Coffee Cup' with that exact name you can use
|
|
99
|
-
|
|
100
|
-
```js
|
|
101
|
-
I.click('Coffee Cup');
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
But sometimes elements are not as easy to locate, so you can use CSS or XPath locators to locate them.
|
|
105
|
-
|
|
106
|
-
For instance, locating Coffee Cup via CSS can take into accont HTML structure of a page and element attributes. For instance, it can be like this:
|
|
107
|
-
|
|
108
|
-
```js
|
|
109
|
-
I.click('div.products a.product-name[title="Coffee Cup"]');
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
In this example, the `div.products` part of the selector specifies a div element with the `products` class, and the `a.product-name[title="Coffee Cup"]` part specifies an a element with `the product-name` class and the `title` attribute set to Coffee Cup.
|
|
113
|
-
|
|
114
|
-
You can read more about HTML and CSS locators, and basically that's all what you need to know to start writing a checkout test!
|
|
115
|
-
|
|
116
|
-
## Get back to Checkout
|
|
117
|
-
|
|
118
|
-
Let's see how a regular checkout script may look in CodeceptJS:
|
|
119
|
-
|
|
120
|
-
```js
|
|
121
|
-
Scenario('test the checkout form', async ({ I }) => {
|
|
122
|
-
// we select one product and switched to checkout project
|
|
123
|
-
I.amOnPage('/');
|
|
124
|
-
I.click('Coffee Cup');
|
|
125
|
-
I.click('Purchase');
|
|
126
|
-
I.click('Checkout');
|
|
127
|
-
|
|
128
|
-
// fill in the shipping address
|
|
129
|
-
I.fillField('First Name', 'John');
|
|
130
|
-
I.fillField('Last Name', 'Doe');
|
|
131
|
-
I.fillField('Address', '123 Main St.');
|
|
132
|
-
I.fillField('City', 'New York');
|
|
133
|
-
I.selectOption('State', 'New York');
|
|
134
|
-
I.fillField('Zip Code', '10001');
|
|
135
|
-
|
|
136
|
-
// select a payment method
|
|
137
|
-
I.click('#credit-card-option');
|
|
138
|
-
I.fillField('Card Number', '1234-5678-9012-3456');
|
|
139
|
-
I.fillField('Expiration Date', '12/22');
|
|
140
|
-
I.fillField('Security Code', '123');
|
|
141
|
-
|
|
142
|
-
// click the checkout button
|
|
143
|
-
I.click('Checkout');
|
|
144
|
-
|
|
145
|
-
// verify that the checkout was successful
|
|
146
|
-
I.see('Your order has been placed successfully!');
|
|
147
|
-
});
|
|
148
|
-
```
|
|
149
|
-
Sure, in relaity your script might be more complicated. As you have noticed, we used CSS locator `'#credit-card-option'` to get select a payment option. However, the test is simple and you can follow user steps through it.
|
|
150
|
-
|
|
151
|
-
Please note, that you shouldn't use a real credit card number here. Good news, you don't need to. Payment providers like Strip provide dummy card numbers for testing purposes.
|
|
152
|
-
|
|
153
|
-
Run the test with next command:
|
|
154
|
-
|
|
155
|
-
```
|
|
156
|
-
npx codeceptjs run --debug -p pauseOnFail
|
|
157
|
-
```
|
|
158
|
-
|
|
159
|
-
What are special options here?
|
|
160
|
-
|
|
161
|
-
* `--debug` flag is used to output additional information to the console, such as the details of each step in the test, the values of variables, and the results of test assertions. This can help you to identify and fix any issues in your tests.
|
|
162
|
-
* `-p pauseOnFail` option is also used to keep the browser opened even if a test fails. It will help us to identify to which point test was executed and what can be improved.
|
|
163
|
-
|
|
164
|
-
Add more test steps if needed, update locators, and notify business owners that all that purchases are made by you so your collegues won't call you in the night asking when you want to get a coffee cup 😀 Also the good idea is to run tests on staging website, to not interfere with business process.
|
|
165
|
-
|
|
166
|
-
What a test is complete you can run it with:
|
|
167
|
-
|
|
168
|
-
```
|
|
169
|
-
npx codeceptjs run
|
|
170
|
-
```
|
|
171
|
-
|
|
172
|
-
If you are annoyed to see a browser window you can use `HEADLESS` environment variable:
|
|
173
|
-
|
|
174
|
-
```
|
|
175
|
-
HEADLESS=true codeceptjs run
|
|
176
|
-
```
|
|
177
|
-
for Windows users HEADLESS should be set in a different manner:
|
|
178
|
-
|
|
179
|
-
```
|
|
180
|
-
set HEADLESS=true&& codeceptjs run
|
|
181
|
-
```
|
|
182
|
-
The tests will pass but no browser is shown, so you can watch YouTube videos while it goes!
|
|
183
|
-
|
|
184
|
-
## Refactoring
|
|
185
|
-
|
|
186
|
-
What if you need to check more purchases? Should you copy paste your code for that?
|
|
187
|
-
|
|
188
|
-
No! You can use Page Object pattern to put repeating interactions into the reusable functions.
|
|
189
|
-
|
|
190
|
-
You can create a page object via next command:
|
|
191
|
-
|
|
192
|
-
```
|
|
193
|
-
npx codeceptjs gpo
|
|
194
|
-
```
|
|
195
|
-
|
|
196
|
-
Sure, we will call it `Checkout`. It will be created in `./pages/Checkout.js` file. You should enable it in `codecept.conf.js` inside `include` section:
|
|
197
|
-
|
|
198
|
-
```js
|
|
199
|
-
include: {
|
|
200
|
-
...
|
|
201
|
-
checkoutPage: './pages/Checkout.js',
|
|
202
|
-
},
|
|
203
|
-
|
|
204
|
-
```
|
|
205
|
-
Now open this file:
|
|
206
|
-
|
|
207
|
-
```js
|
|
208
|
-
const { I } = inject();
|
|
209
|
-
|
|
210
|
-
module.exports = {
|
|
211
|
-
|
|
212
|
-
// insert your locators and methods here
|
|
213
|
-
}
|
|
214
|
-
```
|
|
215
|
-
|
|
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
|
-
|
|
218
|
-
```js
|
|
219
|
-
const { I } = inject();
|
|
220
|
-
|
|
221
|
-
module.exports = {
|
|
222
|
-
|
|
223
|
-
fillShippingAddress(name, address, city, state, zip) {
|
|
224
|
-
I.fillField('Name', name);
|
|
225
|
-
I.fillField('Address', address);
|
|
226
|
-
I.fillField('City', city);
|
|
227
|
-
I.fillField('State', state);
|
|
228
|
-
I.fillField('Zip', zip);
|
|
229
|
-
},
|
|
230
|
-
|
|
231
|
-
fillValidCreditCard() {
|
|
232
|
-
I.click('#credit-card-option');
|
|
233
|
-
I.fillField('Card Number', '1234-5678-9012-3456');
|
|
234
|
-
I.fillField('Expiration Date', '12/22');
|
|
235
|
-
I.fillField('Security Code', '123');
|
|
236
|
-
},
|
|
237
|
-
|
|
238
|
-
checkout() {
|
|
239
|
-
I.click('Checkout');
|
|
240
|
-
},
|
|
241
|
-
}
|
|
242
|
-
```
|
|
243
|
-
|
|
244
|
-
After that we can update our test to use the created page object. Note, that we import Checkout PageObject by its name `checkoutPage` we previously defined in a config.
|
|
245
|
-
|
|
246
|
-
```js
|
|
247
|
-
Scenario('test the checkout form', async ({I, checkoutPage}) => {
|
|
248
|
-
I.amOnPage('/');
|
|
249
|
-
I.click('Coffee Cup');
|
|
250
|
-
I.click('Purchase');
|
|
251
|
-
I.click('Checkout');
|
|
252
|
-
|
|
253
|
-
// fill in the shipping address using the page object
|
|
254
|
-
checkoutPage.fillShippingAddress('John', 'Doe', '123 Main St.', 'New York', 'New York', '10001');
|
|
255
|
-
checkoutPage.fillValidCreditCard();
|
|
256
|
-
checkoutPage.checkout();
|
|
257
|
-
|
|
258
|
-
// verify that the checkout was successful
|
|
259
|
-
I.see('Your order has been placed successfully!');
|
|
260
|
-
});
|
|
261
|
-
```
|
|
262
|
-
|
|
263
|
-
As you see the code of a test was reduced. And we can write the similar tests on the same manner.
|
|
264
|
-
|
|
265
|
-
By applying more and more cases you can test a website to all behaviors.
|
|
266
|
-
|
|
267
|
-
## Summary
|
|
268
|
-
|
|
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
|
-
|
|
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.
|