codeceptjs 3.5.12-beta.3 → 3.5.12-beta.5

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.
Files changed (209) hide show
  1. package/docs/advanced.md +351 -0
  2. package/docs/ai.md +248 -0
  3. package/docs/api.md +323 -0
  4. package/docs/basics.md +979 -0
  5. package/docs/bdd.md +539 -0
  6. package/docs/best.md +237 -0
  7. package/docs/books.md +37 -0
  8. package/docs/bootstrap.md +135 -0
  9. package/docs/build/ApiDataFactory.js +410 -0
  10. package/docs/build/Appium.js +2027 -0
  11. package/docs/build/Expect.js +422 -0
  12. package/docs/build/FileSystem.js +228 -0
  13. package/docs/build/GraphQL.js +229 -0
  14. package/docs/build/GraphQLDataFactory.js +309 -0
  15. package/docs/build/JSONResponse.js +338 -0
  16. package/docs/build/Mochawesome.js +71 -0
  17. package/docs/build/Nightmare.js +2152 -0
  18. package/docs/build/OpenAI.js +126 -0
  19. package/docs/build/Playwright.js +5110 -0
  20. package/docs/build/Protractor.js +2706 -0
  21. package/docs/build/Puppeteer.js +3905 -0
  22. package/docs/build/REST.js +344 -0
  23. package/docs/build/TestCafe.js +2125 -0
  24. package/docs/build/WebDriver.js +4240 -0
  25. package/docs/changelog.md +2572 -0
  26. package/docs/commands.md +266 -0
  27. package/docs/community-helpers.md +58 -0
  28. package/docs/configuration.md +157 -0
  29. package/docs/continuous-integration.md +22 -0
  30. package/docs/custom-helpers.md +306 -0
  31. package/docs/data.md +379 -0
  32. package/docs/detox.md +235 -0
  33. package/docs/docker.md +136 -0
  34. package/docs/email.md +183 -0
  35. package/docs/examples.md +149 -0
  36. package/docs/helpers/ApiDataFactory.md +266 -0
  37. package/docs/helpers/Appium.md +1374 -0
  38. package/docs/helpers/Detox.md +586 -0
  39. package/docs/helpers/Expect.md +275 -0
  40. package/docs/helpers/FileSystem.md +152 -0
  41. package/docs/helpers/GraphQL.md +151 -0
  42. package/docs/helpers/GraphQLDataFactory.md +226 -0
  43. package/docs/helpers/JSONResponse.md +254 -0
  44. package/docs/helpers/Mochawesome.md +8 -0
  45. package/docs/helpers/MockRequest.md +377 -0
  46. package/docs/helpers/Nightmare.md +1305 -0
  47. package/docs/helpers/OpenAI.md +70 -0
  48. package/docs/helpers/Playwright.md +2759 -0
  49. package/docs/helpers/Polly.md +44 -0
  50. package/docs/helpers/Protractor.md +1769 -0
  51. package/docs/helpers/Puppeteer-firefox.md +86 -0
  52. package/docs/helpers/Puppeteer.md +2317 -0
  53. package/docs/helpers/REST.md +218 -0
  54. package/docs/helpers/TestCafe.md +1321 -0
  55. package/docs/helpers/WebDriver.md +2547 -0
  56. package/docs/hooks.md +340 -0
  57. package/docs/index.md +111 -0
  58. package/docs/installation.md +75 -0
  59. package/docs/internal-api.md +266 -0
  60. package/docs/locators.md +339 -0
  61. package/docs/mobile-react-native-locators.md +67 -0
  62. package/docs/mobile.md +338 -0
  63. package/docs/pageobjects.md +291 -0
  64. package/docs/parallel.md +400 -0
  65. package/docs/playwright.md +632 -0
  66. package/docs/plugins.md +1259 -0
  67. package/docs/puppeteer.md +316 -0
  68. package/docs/quickstart.md +162 -0
  69. package/docs/react.md +70 -0
  70. package/docs/reports.md +392 -0
  71. package/docs/secrets.md +36 -0
  72. package/docs/shadow.md +68 -0
  73. package/docs/shared/keys.mustache +31 -0
  74. package/docs/shared/react.mustache +1 -0
  75. package/docs/testcafe.md +174 -0
  76. package/docs/translation.md +247 -0
  77. package/docs/tutorial.md +271 -0
  78. package/docs/typescript.md +180 -0
  79. package/docs/ui.md +59 -0
  80. package/docs/videos.md +28 -0
  81. package/docs/visual.md +202 -0
  82. package/docs/vue.md +143 -0
  83. package/docs/webapi/amOnPage.mustache +11 -0
  84. package/docs/webapi/appendField.mustache +11 -0
  85. package/docs/webapi/attachFile.mustache +12 -0
  86. package/docs/webapi/blur.mustache +18 -0
  87. package/docs/webapi/checkOption.mustache +13 -0
  88. package/docs/webapi/clearCookie.mustache +9 -0
  89. package/docs/webapi/clearField.mustache +9 -0
  90. package/docs/webapi/click.mustache +25 -0
  91. package/docs/webapi/clickLink.mustache +8 -0
  92. package/docs/webapi/closeCurrentTab.mustache +7 -0
  93. package/docs/webapi/closeOtherTabs.mustache +8 -0
  94. package/docs/webapi/dontSee.mustache +11 -0
  95. package/docs/webapi/dontSeeCheckboxIsChecked.mustache +10 -0
  96. package/docs/webapi/dontSeeCookie.mustache +8 -0
  97. package/docs/webapi/dontSeeCurrentUrlEquals.mustache +10 -0
  98. package/docs/webapi/dontSeeElement.mustache +8 -0
  99. package/docs/webapi/dontSeeElementInDOM.mustache +8 -0
  100. package/docs/webapi/dontSeeInCurrentUrl.mustache +4 -0
  101. package/docs/webapi/dontSeeInField.mustache +11 -0
  102. package/docs/webapi/dontSeeInSource.mustache +8 -0
  103. package/docs/webapi/dontSeeInTitle.mustache +8 -0
  104. package/docs/webapi/doubleClick.mustache +13 -0
  105. package/docs/webapi/downloadFile.mustache +12 -0
  106. package/docs/webapi/dragAndDrop.mustache +9 -0
  107. package/docs/webapi/dragSlider.mustache +11 -0
  108. package/docs/webapi/executeAsyncScript.mustache +24 -0
  109. package/docs/webapi/executeScript.mustache +26 -0
  110. package/docs/webapi/fillField.mustache +16 -0
  111. package/docs/webapi/focus.mustache +13 -0
  112. package/docs/webapi/forceClick.mustache +28 -0
  113. package/docs/webapi/forceRightClick.mustache +18 -0
  114. package/docs/webapi/grabAllWindowHandles.mustache +7 -0
  115. package/docs/webapi/grabAttributeFrom.mustache +10 -0
  116. package/docs/webapi/grabAttributeFromAll.mustache +9 -0
  117. package/docs/webapi/grabBrowserLogs.mustache +9 -0
  118. package/docs/webapi/grabCookie.mustache +11 -0
  119. package/docs/webapi/grabCssPropertyFrom.mustache +11 -0
  120. package/docs/webapi/grabCssPropertyFromAll.mustache +10 -0
  121. package/docs/webapi/grabCurrentUrl.mustache +9 -0
  122. package/docs/webapi/grabCurrentWindowHandle.mustache +6 -0
  123. package/docs/webapi/grabDataFromPerformanceTiming.mustache +20 -0
  124. package/docs/webapi/grabElementBoundingRect.mustache +20 -0
  125. package/docs/webapi/grabGeoLocation.mustache +8 -0
  126. package/docs/webapi/grabHTMLFrom.mustache +10 -0
  127. package/docs/webapi/grabHTMLFromAll.mustache +9 -0
  128. package/docs/webapi/grabNumberOfOpenTabs.mustache +8 -0
  129. package/docs/webapi/grabNumberOfVisibleElements.mustache +9 -0
  130. package/docs/webapi/grabPageScrollPosition.mustache +8 -0
  131. package/docs/webapi/grabPopupText.mustache +5 -0
  132. package/docs/webapi/grabSource.mustache +8 -0
  133. package/docs/webapi/grabTextFrom.mustache +10 -0
  134. package/docs/webapi/grabTextFromAll.mustache +9 -0
  135. package/docs/webapi/grabTitle.mustache +8 -0
  136. package/docs/webapi/grabValueFrom.mustache +9 -0
  137. package/docs/webapi/grabValueFromAll.mustache +8 -0
  138. package/docs/webapi/grabWebElement.mustache +9 -0
  139. package/docs/webapi/grabWebElements.mustache +9 -0
  140. package/docs/webapi/moveCursorTo.mustache +12 -0
  141. package/docs/webapi/openNewTab.mustache +7 -0
  142. package/docs/webapi/pressKey.mustache +12 -0
  143. package/docs/webapi/pressKeyDown.mustache +12 -0
  144. package/docs/webapi/pressKeyUp.mustache +12 -0
  145. package/docs/webapi/pressKeyWithKeyNormalization.mustache +60 -0
  146. package/docs/webapi/refreshPage.mustache +6 -0
  147. package/docs/webapi/resizeWindow.mustache +6 -0
  148. package/docs/webapi/rightClick.mustache +14 -0
  149. package/docs/webapi/saveElementScreenshot.mustache +10 -0
  150. package/docs/webapi/saveScreenshot.mustache +12 -0
  151. package/docs/webapi/say.mustache +10 -0
  152. package/docs/webapi/scrollIntoView.mustache +11 -0
  153. package/docs/webapi/scrollPageToBottom.mustache +6 -0
  154. package/docs/webapi/scrollPageToTop.mustache +6 -0
  155. package/docs/webapi/scrollTo.mustache +12 -0
  156. package/docs/webapi/see.mustache +11 -0
  157. package/docs/webapi/seeAttributesOnElements.mustache +9 -0
  158. package/docs/webapi/seeCheckboxIsChecked.mustache +10 -0
  159. package/docs/webapi/seeCookie.mustache +8 -0
  160. package/docs/webapi/seeCssPropertiesOnElements.mustache +9 -0
  161. package/docs/webapi/seeCurrentUrlEquals.mustache +11 -0
  162. package/docs/webapi/seeElement.mustache +8 -0
  163. package/docs/webapi/seeElementInDOM.mustache +8 -0
  164. package/docs/webapi/seeInCurrentUrl.mustache +8 -0
  165. package/docs/webapi/seeInField.mustache +12 -0
  166. package/docs/webapi/seeInPopup.mustache +8 -0
  167. package/docs/webapi/seeInSource.mustache +7 -0
  168. package/docs/webapi/seeInTitle.mustache +8 -0
  169. package/docs/webapi/seeNumberOfElements.mustache +11 -0
  170. package/docs/webapi/seeNumberOfVisibleElements.mustache +10 -0
  171. package/docs/webapi/seeTextEquals.mustache +9 -0
  172. package/docs/webapi/seeTitleEquals.mustache +8 -0
  173. package/docs/webapi/selectOption.mustache +21 -0
  174. package/docs/webapi/setCookie.mustache +16 -0
  175. package/docs/webapi/setGeoLocation.mustache +12 -0
  176. package/docs/webapi/switchTo.mustache +9 -0
  177. package/docs/webapi/switchToNextTab.mustache +10 -0
  178. package/docs/webapi/switchToPreviousTab.mustache +10 -0
  179. package/docs/webapi/type.mustache +21 -0
  180. package/docs/webapi/uncheckOption.mustache +13 -0
  181. package/docs/webapi/wait.mustache +8 -0
  182. package/docs/webapi/waitForClickable.mustache +11 -0
  183. package/docs/webapi/waitForDetached.mustache +10 -0
  184. package/docs/webapi/waitForElement.mustache +11 -0
  185. package/docs/webapi/waitForEnabled.mustache +6 -0
  186. package/docs/webapi/waitForFunction.mustache +17 -0
  187. package/docs/webapi/waitForInvisible.mustache +10 -0
  188. package/docs/webapi/waitForNumberOfTabs.mustache +9 -0
  189. package/docs/webapi/waitForText.mustache +13 -0
  190. package/docs/webapi/waitForValue.mustache +10 -0
  191. package/docs/webapi/waitForVisible.mustache +10 -0
  192. package/docs/webapi/waitInUrl.mustache +9 -0
  193. package/docs/webapi/waitNumberOfVisibleElements.mustache +10 -0
  194. package/docs/webapi/waitToHide.mustache +10 -0
  195. package/docs/webapi/waitUrlEquals.mustache +10 -0
  196. package/docs/webdriver.md +701 -0
  197. package/docs/wiki/Books-&-Posts.md +27 -0
  198. package/docs/wiki/Community-Helpers-&-Plugins.md +53 -0
  199. package/docs/wiki/Converting-Playwright-to-Istanbul-Coverage.md +61 -0
  200. package/docs/wiki/Examples.md +145 -0
  201. package/docs/wiki/Google-Summer-of-Code-(GSoC)-2020.md +68 -0
  202. package/docs/wiki/Home.md +16 -0
  203. package/docs/wiki/Migration-to-Appium-v2---CodeceptJS.md +83 -0
  204. package/docs/wiki/Release-Process.md +24 -0
  205. package/docs/wiki/Roadmap.md +23 -0
  206. package/docs/wiki/Tests.md +1393 -0
  207. package/docs/wiki/Upgrading-to-CodeceptJS-3.md +153 -0
  208. package/docs/wiki/Videos.md +19 -0
  209. package/package.json +2 -1
@@ -0,0 +1,180 @@
1
+ ---
2
+ permalink: /typescript
3
+ title: TypeScript
4
+ ---
5
+
6
+ # TypeScript
7
+
8
+ CodeceptJS supports [type declaration](https://github.com/codeceptjs/CodeceptJS/tree/master/typings) for [TypeScript](https://www.typescriptlang.org/). It means that you can write your tests in TS. Also, all of your custom steps can be written in TS
9
+
10
+ # Why TypeScript?
11
+
12
+ With the TypeScript writing CodeceptJS tests becomes much easier. If you configure TS properly in your project as well as your IDE, you will get the following features:
13
+ - [Autocomplete (with IntelliSense)](https://code.visualstudio.com/docs/editor/intellisense) - a tool that streamlines your work by suggesting when you typing what function or property which exists in a class, what arguments can be passed to that method, what it returns, etc.
14
+ Example:
15
+
16
+ ![Auto Complete](/img/Auto_comlete.gif)
17
+
18
+ - To show additional information for a step in a test. Example:
19
+
20
+ ![Quick Info](/img/Quick_info.gif)
21
+
22
+ - Checks types - thanks to TypeScript support in CodeceptJS now allow to tests your tests. TypeScript can prevent some errors:
23
+ - invalid type of variables passed to function;
24
+ - calls no-exist method from PageObject or `I` object;
25
+ - incorrectly used CodeceptJS features;
26
+
27
+
28
+ ## Getting Started <Badge text="Since 3.3.5" type="warning"/>
29
+
30
+ CodeceptJS can initialize tests as a TypeScript project.
31
+ When starting a new project with a standard installation via
32
+
33
+ ```
34
+ npx codeceptjs init
35
+ ```
36
+ Then select TypeScript as the first question:
37
+
38
+ ```
39
+ ? Do you plan to write tests in TypeScript? Yes
40
+ ```
41
+
42
+ Then a config file and new tests will be created in TypeScript format.
43
+
44
+ If a config file is set in TypeScript format (`codecept.conf.ts`) package `ts-node` will be used to run tests.
45
+
46
+ ## Promise-Based Typings
47
+
48
+ By default, CodeceptJS tests are written in synchronous mode. This is a regular CodeceptJS test:
49
+
50
+ ```js
51
+ I.amOnPage('/')
52
+ I.click('Login')
53
+ I.see('Hello!')
54
+ ```
55
+
56
+ Even thought we don't see any `await`, those commands are executed synchronously, one by one.
57
+ All methods of `I` object actually return promise and TypeScript linter requires to use `await` operator for those promises.
58
+ To trick TypeScript and allow writing tests in CodeceptJS manner we create typings where `void` is returned instead of promises. This way linter won't complain on async code without await, as no promise is returned.
59
+
60
+ Our philosophy here is: use `await` only when it is actually needed, don't add visual mess to your code prefixing each line with `await`. However, you might want to get a better control of your tests and follow TypeScript conventions.
61
+ This is why you might want to **enable promise-based typings**.
62
+
63
+ A previous test should be rewritten with `await`s:
64
+
65
+ ```js
66
+ await I.amOnPage('/')
67
+ await I.click('Login')
68
+ await I.see('Hello!')
69
+ ```
70
+
71
+ Using `await` explicitly provides a beter control of execution flow. Some CodeceptJS users report that they increased stability of tests by adopting `await` for all CodeceptJS commands in their codebase.
72
+
73
+ If you select to use promise-based typings, type definitions will be generated so all actions to return a promise.
74
+ Otherwise they will still return promises but it won't be relfected in type definitions.
75
+
76
+ To introduce promise-based typings into a current project edit `codecept.conf.ts`:
77
+
78
+ ```ts
79
+ fullPromiseBased: true;
80
+ ```
81
+
82
+ and rebuild type definitions with
83
+
84
+ ```
85
+ npx codeceptjs def
86
+ ```
87
+
88
+ ## Types for custom helper or page object
89
+
90
+ 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`.
91
+
92
+ For example, if you add the new step `printMessage` for your custom helper like this:
93
+ ```js
94
+ // customHelper.ts
95
+ export class CustomHelper extends Helper {
96
+ printMessage(msg: string) {
97
+ console.log(msg)
98
+ }
99
+ }
100
+
101
+ ```
102
+
103
+ Then you need to add this helper to your `codecept.conf.js` like in this [docs](https://codecept.io/helpers/#configuration).
104
+ And then run the command `npx codeceptjs def`.
105
+
106
+ As result our `steps.d.ts` file will be updated like this:
107
+ ```ts
108
+ /// <reference types='codeceptjs' />
109
+ type CustomHelper = import('./CustomHelper');
110
+
111
+ declare namespace CodeceptJS {
112
+ interface SupportObject { I: I }
113
+ interface Methods extends Puppeteer, CustomHelper {}
114
+ interface I extends WithTranslation<Methods> {}
115
+ namespace Translation {
116
+ interface Actions {}
117
+ }
118
+ }
119
+ ```
120
+
121
+ And now you can use autocomplete on your test.
122
+
123
+ Generation types for PageObject looks like for a custom helper, but `steps.d.ts` will look like:
124
+ ```ts
125
+ /// <reference types='codeceptjs' />
126
+ type loginPage = typeof import('./loginPage');
127
+ type homePage = typeof import('./homePage');
128
+ type CustomHelper = import('./CustomHelper');
129
+
130
+ declare namespace CodeceptJS {
131
+ interface SupportObject { I: I, loginPage: loginPage, homePage: homePage }
132
+ interface Methods extends Puppeteer, CustomHelper {}
133
+ interface I extends WithTranslation<Methods> {}
134
+ namespace Translation {
135
+ interface Actions {}
136
+ }
137
+ }
138
+ ```
139
+
140
+ ## Types for custom strict locators
141
+
142
+ 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`).
143
+
144
+ Example: A custom strict locator with a `data` property, which can be used like this:
145
+
146
+ ```ts
147
+ I.click({ data: 'user-login' });
148
+ ```
149
+
150
+ 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:
151
+
152
+ ```ts
153
+ /// <reference types='codeceptjs' />
154
+ ...
155
+
156
+ declare namespace CodeceptJS {
157
+ ...
158
+
159
+ interface CustomLocators {
160
+ data: { data: string };
161
+ }
162
+ }
163
+ ```
164
+
165
+ 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.
166
+
167
+ You can also define more complicated custom locators with multiple (also optional) properties:
168
+
169
+ ```ts
170
+ /// <reference types='codeceptjs' />
171
+ ...
172
+
173
+ declare namespace CodeceptJS {
174
+ ...
175
+
176
+ interface CustomLocators {
177
+ data: { data: string, value?: number, flag?: boolean };
178
+ }
179
+ }
180
+ ```
package/docs/ui.md ADDED
@@ -0,0 +1,59 @@
1
+ ---
2
+ title: CodeceptUI
3
+ permalink: /ui
4
+ ---
5
+
6
+
7
+ <img src="/img/codeceptui.png" alt="CodeceptUI" style="width: 100%; border-radius: 5px; box-shadow: 0px 5px 10px rgba(0,0,0,0.1)" />
8
+
9
+
10
+ ## CodeceptUI
11
+
12
+ CodeceptJS has an interactive, graphical test runner. We call it CodeceptUI. It works in your browser and helps you to manage your tests.
13
+
14
+ CodeceptUI can be used for
15
+
16
+ * running tests by groups or single
17
+ * get test reports
18
+ * review tests
19
+ * edit tests and page objects
20
+ * write new tests
21
+ * reuse one browser session accross multiple test runs
22
+ * easily switch to headless/headful mode
23
+
24
+
25
+ ![](https://user-images.githubusercontent.com/220264/93860826-4d5fbc80-fcc8-11ea-99dc-af816f3db466.png)
26
+
27
+ ## Installation
28
+
29
+ CodeceptUI is already installed with `create-codeceptjs` command but you can install it manually via:
30
+
31
+ ```
32
+ npm i @codeceptjs/ui --save
33
+ ```
34
+
35
+ ## Usage
36
+
37
+ To start using CodeceptUI you need to have CodeceptJS project with a few tests written.
38
+ If CodeceptUI was installed by `create-codecept` command it can be started with:
39
+
40
+ ```
41
+ npm run codeceptjs:ui
42
+ ```
43
+
44
+ CodeceptUI can be started in two modes:
45
+
46
+ * **Application** mode - starts Electron application in a window. Designed for desktop systems.
47
+ * **Server** mode - starts a webserver. Deigned for CI systems.
48
+
49
+ To start CodeceptUI in application mode:
50
+
51
+ ```
52
+ npx codecept-ui --app
53
+ ```
54
+
55
+ To start CodeceptUI in server mode:
56
+
57
+ ```
58
+ npx codecept-ui
59
+ ```
package/docs/videos.md ADDED
@@ -0,0 +1,28 @@
1
+ ---
2
+ permalink: /videos
3
+ layout: Section
4
+ sidebar: false
5
+ title: Videos
6
+ editLink: false
7
+ ---
8
+
9
+ > Add your own videos to our [Wiki Page](https://github.com/codeceptjs/CodeceptJS/wiki/Videos)
10
+ [![](http://i3.ytimg.com/vi/BRMWstiOTks/maxresdefault.jpg)](https://www.youtube.com/watch?v=BRMWstiOTks)
11
+
12
+ ## [An Introduction, Getting started and working with CodeceptJS & Puppeteer (EAWeekend)](https://www.youtube.com/watch?v=BRMWstiOTks)
13
+
14
+ ## [CodeceptJS Official YouTube Channel](https://www.youtube.com/channel/UCEs4030bmtonyDhTHEXa_2g)
15
+
16
+ ## [Introductory Videos](https://www.youtube.com/watch?v=FPFG1rBNJ64&list=PLcFXthgti9Lt4SjSvL1ALDg6dOeTC0TvT)
17
+
18
+ Free educational videos provided by our community member **[@ontytoom](http://github.com/ontytoom)**.
19
+
20
+ 1. [Installation](https://www.youtube.com/watch?v=FPFG1rBNJ64)
21
+ 1. [Creating a Test](https://www.youtube.com/watch?v=mdQZjL3h9d0)
22
+ 1. [Using Page Objects](https://www.youtube.com/watch?v=s677_6VctjQ)
23
+
24
+ ## [Practical E2E Testing with CodeceptJS](https://www.udemy.com/practical-e2e-testing-with-codeceptjs/)
25
+
26
+ Udemy course by Luke Beilharz
27
+
28
+
package/docs/visual.md ADDED
@@ -0,0 +1,202 @@
1
+ ---
2
+ permalink: /visual
3
+ title: Visual Testing
4
+ ---
5
+
6
+ # Visual Testing
7
+
8
+ How does one test if the UI being rendered appears correctly to the users or how to test if each UI element appears in the right position and size? The traditional way to test the UI of the application has always been manually, which is time consuming.
9
+
10
+ Visual testing with help of CodeceptJS will help in improving such use cases for the QA folks.
11
+
12
+ By default CodeceptJS uses [WebDriver](/helpers/WebDriver/) helper and **Selenium** to automate browser. It is also capable of taking screenshots of the application and this could be used for visual testing.
13
+
14
+ Currently there are two helpers available for Visual testing with CodeceptJS
15
+
16
+ ## Using Resemble helper
17
+
18
+ [Resemble.js](https://github.com/rsmbl/Resemble.js) is a great tool for image comparison and analysis, which can be used with CodeceptJS
19
+
20
+ ### Setup
21
+
22
+ To install the package, just run
23
+
24
+ ```
25
+ npm install codeceptjs-resemblehelper --save
26
+ ```
27
+
28
+ ### Configuring
29
+
30
+ This helper should be added to `codecept.conf.js` config file.
31
+
32
+ Example:
33
+
34
+ ```json
35
+ {
36
+ "helpers": {
37
+ "ResembleHelper" : {
38
+ "require": "codeceptjs-resemblehelper",
39
+ "screenshotFolder" : "./tests/output/",
40
+ "baseFolder": "./tests/screenshots/base/",
41
+ "diffFolder": "./tests/screenshots/diff/"
42
+ }
43
+ }
44
+ }
45
+ ```
46
+
47
+ To use the Helper, users must provide the three parameters:
48
+
49
+ * `screenshotFolder` : This will always have the same value as `output` in Codecept configuration, this is the folder where WebDriver saves a screenshot when using `I.saveScreenshot` method
50
+ * `baseFolder`: This is the folder for base images, which will be used with screenshot for comparison
51
+ * `diffFolder`: This will the folder where resemble would try to store the difference image, which can be viewed later.
52
+
53
+ ### Usage
54
+
55
+ Details about the helper can be found on the [Github Repo](https://github.com/puneet0191/codeceptjs-resemblehelper)
56
+
57
+ Base Image is compared with the screenshot image and test results are derived based on the `mismatch tolerance` level provided by the user for the comparison
58
+
59
+ ### Example
60
+
61
+ Lets consider visual testing for [CodeceptJS Home](https://codecept.io)
62
+
63
+ ```js
64
+ Feature('To test screen comparison with resemble Js Example test');
65
+
66
+ Scenario('Compare CodeceptIO Home Page @visual-test', async ({ I }) => {
67
+ I.amOnPage("/");
68
+ I.saveScreenshot("Codecept_IO_Screenshot_Image.png");
69
+ I.seeVisualDiff("Codecept_IO_Screenshot_Image.png", {tolerance: 2, prepareBaseImage: false});
70
+ });
71
+ ```
72
+
73
+ In this example, we are setting the expected mismatch tolerance level as `2`
74
+
75
+ `Base Image` (Generated by User)
76
+ ![Base Image](/img/Codecept_IO_Base_Image.png)
77
+
78
+ `Screenshot Image` (Generated by Test)
79
+ ![Screenshot Image](/img/Codecept_IO_Screenshot_Image.png)
80
+
81
+ Clearly the difference in both the images visible to human eye is the section about `Scenario Driven`
82
+
83
+ ![Difference Image](/img/difference_Image_Codecept_Home.png)
84
+
85
+ `Diff Image` generated by the helper clearly highlights the section which don't match
86
+
87
+ ![Highlight](/img/Difference%20Image%20Focus.png)
88
+
89
+ `Failed Test output`
90
+ ```
91
+ To test screen comparison with resemble Js Example test --
92
+ Compare CodeceptIO Home Page @visual-test
93
+ I see Visual Diff "Codecept_IO_Screenshot_Image.png", {tolerance: 2, prepareBaseImage: false}
94
+ MisMatch Percentage Calculated is 2.85
95
+ ✖ FAILED in 418ms
96
+
97
+
98
+ -- FAILURES:
99
+
100
+ 1) To test screen comparison with resemble Js Example test
101
+ Compare CodeceptIO Home Page @visual-test:
102
+
103
+ MissMatch Percentage 2.85
104
+ + expected - actual
105
+
106
+ -false
107
+ +true
108
+ ```
109
+
110
+ `Codeceptjs-resemblehelper` basically comes with two major functions
111
+
112
+ 1) `seeVisualDiff` which can be used to compare two images and calculate the misMatch percentage.
113
+ 2) `seeVisualDiffForElement` which can be used to compare elements on the two images and calculate misMatch percentage.
114
+
115
+ ## Using Applitools
116
+
117
+ Applitools helps Test Automation engineers, DevOps, and FrontEnd Developers continuously test and validate visually perfect mobile, web, and native apps. Now it can be used with CodeceptJS.
118
+
119
+ ### Setup
120
+
121
+ Create an account at [Applitools](https://applitools.com/users/register) and install the npm packages
122
+
123
+ ```
124
+ npm i codeceptjs-applitoolshelper --save
125
+ npm i webdriverio@5 --save
126
+ ```
127
+
128
+ ### Configuring
129
+
130
+ ```js
131
+ ...
132
+ helpers: {
133
+ WebDriver: {
134
+ url: 'https://applitools.com/helloworld',
135
+ browser: 'chrome',
136
+ desiredCapabilities: {
137
+ chromeOptions: {
138
+ args: [ '--headless', '--disable-extensions', '--disable-gpu', '--no-sandbox', '--disable-dev-shm-usage']
139
+ }
140
+ },
141
+ windowSize: '1920x600',
142
+ smartWait: 5000,
143
+ timeouts: {
144
+ 'script': 60000,
145
+ 'page load': 10000
146
+ },
147
+ },
148
+ ApplitoolsHelper: {
149
+ require: 'codeceptjs-applitoolshelper',
150
+ applitoolsKey: 'YOUR_API_KEY'
151
+ }
152
+ },
153
+ ...
154
+ ```
155
+
156
+ #### To use this helper you need to provide the following info:
157
+
158
+ - applitoolsKey (Required): You can find your API key under the user menu located at the right hand side of the test manager toolbar
159
+ - windowSize (Optional): the windows size as for instance 1440x700, if not provided, the default 1920x600 will be used. The windowSize will follow this precedence: ApplitoolsHelper, Webdriver.
160
+ - appName (Optional): you can either provide your desired application name, if not provided, the default 'Application Under Test' will be used.
161
+
162
+ ### Usage
163
+
164
+ ```javascript
165
+ /**
166
+ * @param pageToCheck {string} Name of page you want to check
167
+ */
168
+ I.eyeCheck(pageToCheck);
169
+
170
+ ```
171
+
172
+ The first time you run this test a new baseline will be created, and subsequent test runs will be compared to this baseline. If any screenshot mismatch its baseline image in a perceptible way, there will be a `DiffsFoundException` which includes a URL that points to a detailed report where you can see the detected differences and take appropriate actions such as reporting bugs, updating the baseline and more.
173
+
174
+ ```js
175
+ -- FAILURES:
176
+
177
+ 1) Applitools functionality
178
+ Check home page @test:
179
+ Test 'Applitools functionality' of 'Application Under Test' detected differences!. See details at: https://eyes.applitools.com/app/batches/00000251831777088983/00000251831777088717?accountId=KO-Oh9tXI0e8VF8Ha_GLVA~~
180
+ ```
181
+
182
+ > You can find the latest documentation here [Applitools Docs](https://applitools.com/tutorials/webdriverio5.html#run-your-first-test)
183
+
184
+ ### Example
185
+
186
+ Lets consider visual testing for [CodeceptJS Home](https://codecept.io).
187
+ You can also find example repo here: https://github.com/PeterNgTr/codeceptjs-applitoolshelper
188
+
189
+ ```js
190
+ const { I } = inject();
191
+
192
+ Feature('Applitools functionality');
193
+
194
+ Before(() => {
195
+ I.amOnPage('https://applitools.com/helloworld');
196
+ });
197
+
198
+ Scenario('Check home page @test', async ({ }) => {
199
+ await I.eyeCheck('Homepage');
200
+ });
201
+ ```
202
+
package/docs/vue.md ADDED
@@ -0,0 +1,143 @@
1
+ ---
2
+ permalink: /vue
3
+ layout: Section
4
+ sidebar: false
5
+ title: Testing Vue Apps
6
+ ---
7
+
8
+
9
+ # vue-cli-plugin-e2e-codeceptjs
10
+
11
+ *Hey, how about some end 2 end testing for your Vue apps?* 🤔
12
+
13
+ *Let's do it together! Vue, me, [CodeceptJS](https://codecept.io) & [Puppeteer](https://pptr.dev).* 🤗
14
+
15
+ *Browser testing was never that simple. Just see it!* 😍
16
+
17
+ ```js
18
+ I.amOnPage('/');
19
+ I.click('My Component Button');
20
+ I.see('My Component');
21
+ I.say('I am happy!');
22
+ // that's right, this is a valid test!
23
+ ```
24
+
25
+ ## How to try it?
26
+
27
+ **Requirements:**
28
+
29
+ * NodeJS >= 8.9
30
+ * NPM / Yarn
31
+ * Vue CLI installed globally
32
+
33
+ ```
34
+ npm i vue-cli-plugin-codeceptjs-puppeteer --save-dev
35
+ ```
36
+
37
+ This will install CodeceptJS, CodeceptUI & Puppeteer with Chrome browser.
38
+
39
+ To add CodeceptJS to your project invoke installer:
40
+
41
+ ```
42
+ vue invoke vue-cli-plugin-codeceptjs-puppeteer
43
+ ```
44
+
45
+ > You will be asked about installing a demo component. If you start a fresh project **it is recommended to agree and install a demo component**, so you could see tests passing.
46
+
47
+
48
+ ## Running Tests
49
+
50
+ We added npm scripts:
51
+
52
+ * `test:e2e` - will execute tests with browser opened. If you installed test component, and started a test server, running this command will show you a brower window passed test.
53
+ * Use `--headless` option to run browser headlessly
54
+ * Use `--serve` option to start a dev server before tests
55
+
56
+
57
+ Examples:
58
+
59
+ ```
60
+ npm run test:e2e
61
+ npm run test:e2e -- --headless
62
+ npm run test:e2e -- --serve
63
+ ```
64
+
65
+ > This command is a wrapper for `codecept run --steps`. You can use the [Run arguments and options](/commands#run) here.
66
+
67
+ * `test:e2e:parallel` - will execute tests headlessly in parallel processes (workers). By default runs tests in 2 workers.
68
+ * Use an argument to set number of workers
69
+ * Use `--serve` option to start dev server before running
70
+
71
+ Examples:
72
+
73
+ ```
74
+ npm run test:e2e:parallel
75
+ npm run test:e2e:parallel -- 3
76
+ npm run test:e2e:parallel -- 3 --serve
77
+ ```
78
+
79
+ > This command is a wrapper for `codecept run-workers 2`. You can use the [Run arguments and options](/commands#run-workers) here.
80
+
81
+ * `test:e2e:open` - this opens interactive web test runner. So you could see, review & run your tests from a browser.
82
+
83
+ ![](https://user-images.githubusercontent.com/220264/70399222-b7a1bc00-1a2a-11ea-8f0b-2878b0328161.gif)
84
+
85
+ ```
86
+ npm run test:e2e:open
87
+ ```
88
+
89
+ ## Directory Structure
90
+
91
+ Generator has created these files:
92
+
93
+ ```js
94
+ codecept.conf.js 👈 codeceptjs config
95
+ jsconfig.json 👈 enabling type definitons
96
+ tests
97
+ ├── e2e
98
+ │   ├── app_test.js 👈 demo test, edit it!
99
+ │   ├── output 👈 temp directory for screenshots, reports, etc
100
+ │   └── support
101
+ │   └── steps_file.js 👈 common steps
102
+ └── steps.d.ts 👈 type definitions
103
+ ```
104
+
105
+ If you agreed to create a demo component, you will also see `TestMe` component in `src/components` folder.
106
+
107
+ ## Locators
108
+
109
+ For Vue apps a special `vue` locator is available. It allows to select an element by its component name, and props.
110
+
111
+ ```js
112
+ { vue: 'MyComponent' }
113
+ { vue: 'Button', props: { title: 'Click Me' }}
114
+ ```
115
+
116
+ With Playwright, you can use Vue locators in any method where locator is required:
117
+
118
+ ```js
119
+ I.click({ vue: 'Tab', props: { title: 'Click Me!' }});
120
+ I.seeElement({ vue: 't', props: { title: 'Clicked' }});
121
+ ```
122
+
123
+ To find Vue element names and props in a tree use [Vue DevTools](https://chromewebstore.google.com/detail/vuejs-devtools/nhdogjmejiglipccpnnnanhbledajbpd) extension.
124
+
125
+ > Turn off minification for application builds otherwise component names will be uglified as well
126
+
127
+ Vue locators work via [Playwright Vue Locator](https://playwright.dev/docs/other-locators#vue-locator).
128
+
129
+ ## How to write tests?
130
+
131
+ * Open `tests/e2e/app_js` and see the demo test
132
+ * Execute a test & use interactive pause to see how CodeceptJS works
133
+ * [Learn CodeceptJS basics](/basics)
134
+ * [Learn how to write CodeceptJS tests with Puppeteer](/puppeteer)
135
+ * [See full reference for CodeceptJS Puppeteer Helper](/helpers/Puppeteer)
136
+ * Ask your questions in [Slack](https://bit.ly/chat-codeceptjs) & [Forum](https://codecept.discourse.group/)
137
+
138
+ ## Enjoy testing!
139
+
140
+ Testing is simple & fun, enjoy it!
141
+
142
+ With ❤ [CodeceptJS Team](https://codecept.io)
143
+
@@ -0,0 +1,11 @@
1
+ Opens a web page in a browser. Requires relative or absolute url.
2
+ If url starts with `/`, opens a web page of a site defined in `url` config parameter.
3
+
4
+ ```js
5
+ I.amOnPage('/'); // opens main page of website
6
+ I.amOnPage('https://github.com'); // opens github
7
+ I.amOnPage('/login'); // opens a login page
8
+ ```
9
+
10
+ @param {string} url url path or global url.
11
+ @returns {void} automatically synchronized promise through #recorder
@@ -0,0 +1,11 @@
1
+ Appends text to a input field or textarea.
2
+ Field is located by name, label, CSS or XPath
3
+
4
+ ```js
5
+ I.appendField('#myTextField', 'appended');
6
+ // typing secret
7
+ I.appendField('password', secret('123456'));
8
+ ```
9
+ @param {CodeceptJS.LocatorOrString} field located by label|name|CSS|XPath|strict locator
10
+ @param {string} value text value to append.
11
+ @returns {void} automatically synchronized promise through #recorder
@@ -0,0 +1,12 @@
1
+ Attaches a file to element located by label, name, CSS or XPath
2
+ Path to file is relative current codecept directory (where codecept.conf.ts or codecept.conf.js is located).
3
+ File will be uploaded to remote system (if tests are running remotely).
4
+
5
+ ```js
6
+ I.attachFile('Avatar', 'data/avatar.jpg');
7
+ I.attachFile('form input[name=avatar]', 'data/avatar.jpg');
8
+ ```
9
+
10
+ @param {CodeceptJS.LocatorOrString} locator field located by label|name|CSS|XPath|strict locator.
11
+ @param {string} pathToFile local file path relative to codecept.conf.ts or codecept.conf.js config file.
12
+ @returns {void} automatically synchronized promise through #recorder
@@ -0,0 +1,18 @@
1
+ Remove focus from a text input, button, etc.
2
+ Calls [blur](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus) on the element.
3
+
4
+ Examples:
5
+
6
+ ```js
7
+ I.blur('.text-area')
8
+ ```
9
+ ```js
10
+ //element `#product-tile` is focused
11
+ I.see('#add-to-cart-btn');
12
+ I.blur('#product-tile')
13
+ I.dontSee('#add-to-cart-btn');
14
+ ```
15
+
16
+ @param {CodeceptJS.LocatorOrString} locator field located by label|name|CSS|XPath|strict locator.
17
+ @param {any} [options] Playwright only: [Additional options](https://playwright.dev/docs/api/class-locator#locator-blur) for available options object as 2nd argument.
18
+ @returns {void} automatically synchronized promise through #recorder
@@ -0,0 +1,13 @@
1
+ Selects a checkbox or radio button.
2
+ Element is located by label or name or CSS or XPath.
3
+
4
+ The second parameter is a context (CSS or XPath locator) to narrow the search.
5
+
6
+ ```js
7
+ I.checkOption('#agree');
8
+ I.checkOption('I Agree to Terms and Conditions');
9
+ I.checkOption('agree', '//form');
10
+ ```
11
+ @param {CodeceptJS.LocatorOrString} field checkbox located by label | name | CSS | XPath | strict locator.
12
+ @param {?CodeceptJS.LocatorOrString} [context=null] (optional, `null` by default) element located by CSS | XPath | strict locator.
13
+ @returns {void} automatically synchronized promise through #recorder
@@ -0,0 +1,9 @@
1
+ Clears a cookie by name,
2
+ if none provided clears all cookies.
3
+
4
+ ```js
5
+ I.clearCookie();
6
+ I.clearCookie('test'); // Playwright currently doesn't support clear a particular cookie name
7
+ ```
8
+
9
+ @param {?string} [cookie=null] (optional, `null` by default) cookie name