codeceptjs 2.1.3 → 2.2.1

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 (173) hide show
  1. package/CHANGELOG.md +125 -37
  2. package/README.md +15 -22
  3. package/bin/codecept.js +4 -1
  4. package/docs/acceptance.md +44 -1
  5. package/docs/advanced.md +1 -1
  6. package/docs/angular.md +6 -9
  7. package/docs/basics.md +388 -75
  8. package/docs/bdd.md +4 -3
  9. package/docs/best.md +1 -1
  10. package/docs/books.md +31 -0
  11. package/docs/build/Appium.js +215 -176
  12. package/docs/build/Nightmare.js +618 -489
  13. package/docs/build/Polly.js +189 -0
  14. package/docs/build/Protractor.js +747 -608
  15. package/docs/build/Puppeteer.js +914 -633
  16. package/docs/build/REST.js +1 -1
  17. package/docs/build/TestCafe.js +1835 -0
  18. package/docs/build/WebDriver.js +861 -805
  19. package/docs/build/WebDriverIO.js +616 -617
  20. package/docs/changelog.md +410 -316
  21. package/docs/commands.md +6 -6
  22. package/docs/community-helpers.md +2 -0
  23. package/docs/detox.md +235 -0
  24. package/docs/examples.md +23 -0
  25. package/docs/helpers/ApiDataFactory.md +11 -10
  26. package/docs/helpers/Appium.md +130 -61
  27. package/docs/helpers/Detox.md +579 -0
  28. package/docs/helpers/FileSystem.md +2 -1
  29. package/docs/helpers/Mochawesome.md +1 -0
  30. package/docs/helpers/Nightmare.md +348 -128
  31. package/docs/helpers/Polly.md +85 -0
  32. package/docs/helpers/Protractor.md +451 -184
  33. package/docs/helpers/Puppeteer-firefox.md +55 -0
  34. package/docs/helpers/Puppeteer.md +619 -183
  35. package/docs/helpers/REST.md +17 -16
  36. package/docs/helpers/SeleniumWebdriver.md +9 -8
  37. package/docs/helpers/TestCafe.md +1168 -0
  38. package/docs/helpers/WebDriver.md +600 -291
  39. package/docs/helpers/WebDriverIO.md +393 -278
  40. package/docs/helpers.md +37 -18
  41. package/docs/locators.md +2 -0
  42. package/docs/mobile-react-native-locators.md +64 -0
  43. package/docs/mobile.md +5 -0
  44. package/docs/plugins.md +54 -13
  45. package/docs/puppeteer.md +74 -26
  46. package/docs/quickstart.md +47 -12
  47. package/docs/react.md +67 -0
  48. package/docs/reports.md +1 -1
  49. package/docs/{webapi/_keys.mustache → shared/keys.mustache} +0 -0
  50. package/docs/shared/react.mustache +1 -0
  51. package/docs/testcafe.md +157 -0
  52. package/docs/videos.md +19 -0
  53. package/docs/webapi/amOnPage.mustache +1 -1
  54. package/docs/webapi/appendField.mustache +2 -2
  55. package/docs/webapi/attachFile.mustache +2 -2
  56. package/docs/webapi/checkOption.mustache +2 -2
  57. package/docs/webapi/clearCookie.mustache +1 -1
  58. package/docs/webapi/clearField.mustache +1 -1
  59. package/docs/webapi/click.mustache +2 -2
  60. package/docs/webapi/clickLink.mustache +3 -3
  61. package/docs/webapi/dontSee.mustache +6 -3
  62. package/docs/webapi/dontSeeCheckboxIsChecked.mustache +7 -1
  63. package/docs/webapi/dontSeeCookie.mustache +5 -1
  64. package/docs/webapi/dontSeeCurrentUrlEquals.mustache +6 -1
  65. package/docs/webapi/dontSeeElement.mustache +5 -1
  66. package/docs/webapi/dontSeeElementInDOM.mustache +5 -1
  67. package/docs/webapi/dontSeeInCurrentUrl.mustache +1 -1
  68. package/docs/webapi/dontSeeInField.mustache +7 -2
  69. package/docs/webapi/dontSeeInSource.mustache +5 -1
  70. package/docs/webapi/dontSeeInTitle.mustache +5 -1
  71. package/docs/webapi/doubleClick.mustache +2 -2
  72. package/docs/webapi/downloadFile.mustache +2 -2
  73. package/docs/webapi/dragAndDrop.mustache +2 -2
  74. package/docs/webapi/dragSlider.mustache +2 -2
  75. package/docs/webapi/executeAsyncScript.mustache +1 -1
  76. package/docs/webapi/executeScript.mustache +1 -1
  77. package/docs/webapi/fillField.mustache +2 -2
  78. package/docs/webapi/grabAttributeFrom.mustache +3 -2
  79. package/docs/webapi/grabBrowserLogs.mustache +3 -1
  80. package/docs/webapi/grabCookie.mustache +2 -1
  81. package/docs/webapi/grabCssPropertyFrom.mustache +3 -2
  82. package/docs/webapi/grabCurrentUrl.mustache +3 -1
  83. package/docs/webapi/grabDataFromPerformanceTiming.mustache +19 -0
  84. package/docs/webapi/grabHTMLFrom.mustache +2 -1
  85. package/docs/webapi/grabNumberOfOpenTabs.mustache +4 -2
  86. package/docs/webapi/grabNumberOfVisibleElements.mustache +3 -2
  87. package/docs/webapi/grabPageScrollPosition.mustache +3 -1
  88. package/docs/webapi/grabSource.mustache +3 -1
  89. package/docs/webapi/grabTextFrom.mustache +2 -1
  90. package/docs/webapi/grabTitle.mustache +3 -1
  91. package/docs/webapi/grabValueFrom.mustache +2 -1
  92. package/docs/webapi/moveCursorTo.mustache +3 -3
  93. package/docs/webapi/pressKey.mustache +1 -1
  94. package/docs/webapi/resizeWindow.mustache +2 -2
  95. package/docs/webapi/rightClick.mustache +2 -2
  96. package/docs/webapi/saveScreenshot.mustache +3 -3
  97. package/docs/webapi/say.mustache +2 -2
  98. package/docs/webapi/scrollPageToBottom.mustache +1 -1
  99. package/docs/webapi/scrollPageToTop.mustache +1 -1
  100. package/docs/webapi/scrollTo.mustache +3 -3
  101. package/docs/webapi/see.mustache +2 -2
  102. package/docs/webapi/seeAttributesOnElements.mustache +3 -3
  103. package/docs/webapi/seeCheckboxIsChecked.mustache +2 -1
  104. package/docs/webapi/seeCookie.mustache +1 -1
  105. package/docs/webapi/seeCssPropertiesOnElements.mustache +2 -2
  106. package/docs/webapi/seeCurrentUrlEquals.mustache +1 -1
  107. package/docs/webapi/seeElement.mustache +1 -1
  108. package/docs/webapi/seeElementInDOM.mustache +1 -1
  109. package/docs/webapi/seeInCurrentUrl.mustache +1 -1
  110. package/docs/webapi/seeInField.mustache +2 -2
  111. package/docs/webapi/seeInSource.mustache +1 -1
  112. package/docs/webapi/seeInTitle.mustache +5 -1
  113. package/docs/webapi/seeNumberOfElements.mustache +10 -0
  114. package/docs/webapi/seeNumberOfVisibleElements.mustache +2 -2
  115. package/docs/webapi/selectOption.mustache +2 -2
  116. package/docs/webapi/setCookie.mustache +1 -1
  117. package/docs/webapi/switchTo.mustache +6 -1
  118. package/docs/webapi/uncheckOption.mustache +2 -2
  119. package/docs/webapi/wait.mustache +1 -2
  120. package/docs/webapi/waitForDetached.mustache +3 -3
  121. package/docs/webapi/waitForElement.mustache +2 -2
  122. package/docs/webapi/waitForEnabled.mustache +1 -1
  123. package/docs/webapi/waitForFunction.mustache +3 -3
  124. package/docs/webapi/waitForInvisible.mustache +3 -3
  125. package/docs/webapi/waitForText.mustache +3 -3
  126. package/docs/webapi/waitForValue.mustache +3 -3
  127. package/docs/webapi/waitForVisible.mustache +3 -3
  128. package/docs/webapi/waitInUrl.mustache +2 -2
  129. package/docs/webapi/waitNumberOfVisibleElements.mustache +3 -3
  130. package/docs/webapi/waitToHide.mustache +3 -3
  131. package/docs/webapi/waitUntil.mustache +3 -3
  132. package/docs/webapi/waitUrlEquals.mustache +2 -2
  133. package/docs/webdriver.md +453 -0
  134. package/lib/codecept.js +11 -9
  135. package/lib/command/definitions.js +183 -30
  136. package/lib/command/gherkin/snippets.js +29 -9
  137. package/lib/command/init.js +31 -9
  138. package/lib/command/run-multiple.js +46 -59
  139. package/lib/command/utils.js +1 -1
  140. package/lib/container.js +30 -4
  141. package/lib/data/dataScenarioConfig.js +18 -0
  142. package/lib/helper/Appium.js +24 -24
  143. package/lib/helper/Nightmare.js +81 -84
  144. package/lib/helper/Polly.js +189 -0
  145. package/lib/helper/Protractor.js +96 -86
  146. package/lib/helper/Puppeteer.js +238 -113
  147. package/lib/helper/REST.js +1 -1
  148. package/lib/helper/TestCafe.js +1257 -0
  149. package/lib/helper/WebDriver.js +217 -277
  150. package/lib/helper/WebDriverIO.js +75 -75
  151. package/lib/helper/clientscripts/nightmare.js +8 -0
  152. package/lib/helper/extras/React.js +55 -0
  153. package/lib/helper/testcafe/testControllerHolder.js +42 -0
  154. package/lib/helper/testcafe/testcafe-utils.js +63 -0
  155. package/lib/history.js +39 -0
  156. package/lib/hooks.js +25 -1
  157. package/lib/interfaces/gherkin.js +17 -1
  158. package/lib/interfaces/scenarioConfig.js +2 -2
  159. package/lib/listener/config.js +3 -3
  160. package/lib/locator.js +6 -0
  161. package/lib/pause.js +22 -1
  162. package/lib/plugin/allure.js +63 -0
  163. package/lib/plugin/autoLogin.js +65 -16
  164. package/lib/plugin/puppeteerCoverage.js +6 -1
  165. package/lib/plugin/stepByStepReport.js +4 -3
  166. package/lib/scenario.js +23 -17
  167. package/lib/step.js +5 -2
  168. package/lib/ui.js +1 -1
  169. package/lib/utils.js +70 -20
  170. package/package.json +20 -19
  171. package/translations/de-DE.js +69 -0
  172. package/translations/index.js +1 -0
  173. package/docs/video.md +0 -26
@@ -0,0 +1,1168 @@
1
+ ---
2
+ id: TestCafe
3
+ title: TestCafe
4
+ ---
5
+
6
+ <!-- Generated by documentation.js. Update this documentation by updating the source code. -->
7
+
8
+ ## TestCafe
9
+
10
+ Extends Helper
11
+
12
+ Uses [TestCafe][1] library to run cross-browser tests.
13
+ The browser version you want to use in tests must be installed on your system.
14
+
15
+ Requires `testcafe` package to be installed.
16
+
17
+ npm i testcafe --save-dev
18
+
19
+ ## Configuration
20
+
21
+ This helper should be configured in codecept.json or codecept.conf.js
22
+
23
+ - `url`: base url of website to be tested
24
+ - `show`: - show browser window.
25
+ - `windowSize`: (optional) - set browser window width and height
26
+ - `getPageTimeout` config option to set maximum navigation time in milliseconds.
27
+ - `waitForTimeout`: (optional) default wait\ timeout in ms. Default: 5000.
28
+ - `browser`: - See [https://devexpress.github.io/testcafe/documentation/using-testcafe/common-concepts/browsers/browser-support.html][2]
29
+
30
+ #### Example #1: Show chrome browser window
31
+
32
+ ```js
33
+ {
34
+ helpers: {
35
+ TestCafe : {
36
+ url: "http://localhost",
37
+ waitForTimeout: 15000,
38
+ show: true,
39
+ browser: "chrome"
40
+ }
41
+ }
42
+ }
43
+ ```
44
+
45
+ ## Access From Helpers
46
+
47
+ Call Testcafe methods directly using the testcafe controller.
48
+
49
+ ```js
50
+ const testcafeTestController = this.helpers['TestCafe'].t;
51
+ const comboBox = Selector('.combo-box');
52
+ await testcafeTestController
53
+ .hover(comboBox) // hover over combo box
54
+ .click('#i-prefer-both') // click some other element
55
+ ```
56
+
57
+ ## Methods
58
+
59
+ ### Parameters
60
+
61
+ - `config`
62
+
63
+ ### \_locate
64
+
65
+ Get elements by different locator types, including strict locator
66
+ Should be used in custom helpers:
67
+
68
+ ```js
69
+ const elements = await this.helpers['TestCafe']._locate('.item');
70
+ ```
71
+
72
+ #### Parameters
73
+
74
+ - `locator`
75
+
76
+ ### amOnPage
77
+
78
+ Opens a web page in a browser. Requires relative or absolute url.
79
+ If url starts with `/`, opens a web page of a site defined in `url` config parameter.
80
+
81
+ ```js
82
+ I.amOnPage('/'); // opens main page of website
83
+ I.amOnPage('https://github.com'); // opens github
84
+ I.amOnPage('/login'); // opens a login page
85
+ ```
86
+
87
+ #### Parameters
88
+
89
+ - `url` [string][3] url path or global url.
90
+
91
+
92
+
93
+ ### appendField
94
+
95
+ Appends text to a input field or textarea.
96
+ Field is located by name, label, CSS or XPath
97
+
98
+ ```js
99
+ I.appendField('#myTextField', 'appended');
100
+ ```
101
+
102
+ #### Parameters
103
+
104
+ - `field` ([string][3] \| [object][4]) located by label|name|CSS|XPath|strict locator
105
+ - `value` [string][3] text value to append.
106
+
107
+
108
+
109
+ ### attachFile
110
+
111
+ Appends text to a input field or textarea.
112
+ Field is located by name, label, CSS or XPath
113
+
114
+ ```js
115
+ I.appendField('#myTextField', 'appended');
116
+ ```
117
+
118
+ #### Parameters
119
+
120
+ - `field` ([string][3] \| [object][4]) located by label|name|CSS|XPath|strict locator
121
+ - `pathToFile`
122
+ - `value` [string][3] text value to append.
123
+
124
+
125
+
126
+ ### checkOption
127
+
128
+ Selects a checkbox or radio button.
129
+ Element is located by label or name or CSS or XPath.
130
+
131
+ The second parameter is a context (CSS or XPath locator) to narrow the search.
132
+
133
+ ```js
134
+ I.checkOption('#agree');
135
+ I.checkOption('I Agree to Terms and Conditions');
136
+ I.checkOption('agree', '//form');
137
+ ```
138
+
139
+ #### Parameters
140
+
141
+ - `field` ([string][3] \| [object][4]) checkbox located by label | name | CSS | XPath | strict locator.
142
+ - `context` [string][3] (optional, `null` by default) element located by CSS | XPath | strict locator.
143
+
144
+
145
+
146
+ ### clearCookie
147
+
148
+ Clears a cookie by name,
149
+ if none provided clears all cookies.
150
+
151
+ ```js
152
+ I.clearCookie();
153
+ I.clearCookie('test');
154
+ ```
155
+
156
+ #### Parameters
157
+
158
+ - `cookieName`
159
+ - `cookie` [string][3] (optional, `null` by default) cookie name
160
+
161
+
162
+
163
+ ### clearField
164
+
165
+ Clears a `<textarea>` or text `<input>` element's value.
166
+
167
+ ```js
168
+ I.clearField('Email');
169
+ I.clearField('user[email]');
170
+ I.clearField('#email');
171
+ ```
172
+
173
+ #### Parameters
174
+
175
+ - `field`
176
+ - `editable` ([string][3] \| [object][4]) field located by label|name|CSS|XPath|strict locator.
177
+
178
+
179
+
180
+ ### click
181
+
182
+ Perform a click on a link or a button, given by a locator.
183
+ If a fuzzy locator is given, the page will be searched for a button, link, or image matching the locator string.
184
+ For buttons, the "value" attribute, "name" attribute, and inner text are searched. For links, the link text is searched.
185
+ For images, the "alt" attribute and inner text of any parent links are searched.
186
+
187
+ The second parameter is a context (CSS or XPath locator) to narrow the search.
188
+
189
+ ```js
190
+ // simple link
191
+ I.click('Logout');
192
+ // button of form
193
+ I.click('Submit');
194
+ // CSS button
195
+ I.click('#form input[type=submit]');
196
+ // XPath
197
+ I.click('//form/[@type=submit]');
198
+ // link in context
199
+ I.click('Logout', '#nav');
200
+ // using strict locator
201
+ I.click({css: 'nav a.login'});
202
+ ```
203
+
204
+ #### Parameters
205
+
206
+ - `locator` ([string][3] \| [object][4]) clickable link or button located by text, or any element located by CSS|XPath|strict locator.
207
+ - `context` ([string][3] \| [object][4]) (optional, `null` by default) element to search in CSS|XPath|Strict locator.
208
+
209
+
210
+
211
+ ### dontSee
212
+
213
+ Opposite to `see`. Checks that a text is not present on a page.
214
+ Use context parameter to narrow down the search.
215
+
216
+ ```js
217
+ I.dontSee('Login'); // assume we are already logged in.
218
+ I.dontSee('Login', '.nav'); // no login inside .nav element
219
+ ```
220
+
221
+ #### Parameters
222
+
223
+ - `text` [string][3] which is not present.
224
+ - `context` ([string][3] \| [object][4]) (optional) element located by CSS|XPath|strict locator in which to perfrom search.
225
+
226
+
227
+ ### dontSeeCheckboxIsChecked
228
+
229
+ Verifies that the specified checkbox is not checked.
230
+
231
+ ```js
232
+ I.dontSeeeCheckboxIsChedcked('#agree'); // located by ID
233
+ I.dontSeeeCheckboxIsChedcked('I agree to terms'); // located by label
234
+ I.dontSeeeCheckboxIsChedcked('agree'); // located by name
235
+ ```
236
+
237
+ #### Parameters
238
+
239
+ - `field` ([string][3] \| [object][4]) located by label|name|CSS|XPath|strict locator.
240
+
241
+
242
+
243
+ ### dontSeeCookie
244
+
245
+ Checks that cookie with given name does not exist.
246
+
247
+ ```js
248
+ I.dontSeeCookie('auth'); // no auth cookie
249
+ ```
250
+
251
+ #### Parameters
252
+
253
+ - `name` [string][3] cookie name.
254
+
255
+
256
+
257
+ ### dontSeeCurrentUrlEquals
258
+
259
+ Checks that current url is not equal to provided one.
260
+ If a relative url provided, a configured url will be prepended to it.
261
+
262
+ ```js
263
+ I.dontSeeCurrentUrlEquals('/login'); // relative url are ok
264
+ I.dontSeeCurrentUrlEquals('http://mysite.com/login'); // absolute urls are also ok
265
+ ```
266
+
267
+ #### Parameters
268
+
269
+ - `url` [string][3] value to check.
270
+
271
+
272
+
273
+ ### dontSeeElement
274
+
275
+ Opposite to `seeElement`. Checks that element is not visible (or in DOM)
276
+
277
+ ```js
278
+ I.dontSeeElement('.modal'); // modal is not shown
279
+ ```
280
+
281
+ #### Parameters
282
+
283
+ - `locator` ([string][3] \| [object][4]) located by CSS|XPath|Strict locator.
284
+
285
+
286
+
287
+ ### dontSeeElementInDOM
288
+
289
+ Opposite to `seeElementInDOM`. Checks that element is not on page.
290
+
291
+ ```js
292
+ I.dontSeeElementInDOM('.nav'); // checks that element is not on page visible or not
293
+ ```
294
+
295
+ #### Parameters
296
+
297
+ - `locator` ([string][3] \| [object][4]) located by CSS|XPath|Strict locator.
298
+
299
+
300
+
301
+ ### dontSeeInCurrentUrl
302
+
303
+ Checks that current url does not contain a provided fragment.
304
+
305
+ #### Parameters
306
+
307
+ - `url` [string][3] value to check.
308
+
309
+
310
+
311
+ ### dontSeeInField
312
+
313
+ Checks that value of input field or textare doesn't equal to given value
314
+ Opposite to `seeInField`.
315
+
316
+ ```js
317
+ I.dontSeeInField('email', 'user@user.com'); // field by name
318
+ I.dontSeeInField({ css: 'form input.email' }, 'user@user.com'); // field by CSS
319
+ ```
320
+
321
+ #### Parameters
322
+
323
+ - `field` ([string][3] \| [object][4]) located by label|name|CSS|XPath|strict locator.
324
+ - `value` [string][3] value to check.
325
+
326
+
327
+
328
+ ### dontSeeInSource
329
+
330
+ Checks that the current page does not contains the given string in its raw source code.
331
+
332
+ ```js
333
+ I.dontSeeInSource('<!--'); // no comments in source
334
+ ```
335
+
336
+ #### Parameters
337
+
338
+ - `text`
339
+ - `value` [string][3] to check.
340
+
341
+
342
+
343
+ ### doubleClick
344
+
345
+ Performs a double-click on an element matched by link|button|label|CSS or XPath.
346
+ Context can be specified as second parameter to narrow search.
347
+
348
+ ```js
349
+ I.doubleClick('Edit');
350
+ I.doubleClick('Edit', '.actions');
351
+ I.doubleClick({css: 'button.accept'});
352
+ I.doubleClick('.btn.edit');
353
+ ```
354
+
355
+ #### Parameters
356
+
357
+ - `locator` ([string][3] \| [object][4]) clickable link or button located by text, or any element located by CSS|XPath|strict locator.
358
+ - `context` ([string][3] \| [object][4]) (optional, `null` by default) element to search in CSS|XPath|Strict locator.
359
+
360
+
361
+
362
+ ### executeScript
363
+
364
+ Executes sync script on a page.
365
+ Pass arguments to function as additional parameters.
366
+ Will return execution result to a test.
367
+ In this case you should use async function and await to receive results.
368
+
369
+ Example with jQuery DatePicker:
370
+
371
+ ```js
372
+ // change date of jQuery DatePicker
373
+ I.executeScript(function() {
374
+ // now we are inside browser context
375
+ $('date').datetimepicker('setDate', new Date());
376
+ });
377
+ ```
378
+
379
+ Can return values. Don't forget to use `await` to get them.
380
+
381
+ ```js
382
+ let date = await I.executeScript(function(el) {
383
+ // only basic types can be returned
384
+ return $(el).datetimepicker('getDate').toString();
385
+ }, '#date'); // passing jquery selector
386
+ ```
387
+
388
+ #### Parameters
389
+
390
+ - `fn` ([string][3] \| [function][5]) function to be executed in browser context.
391
+ - `args` ...any
392
+
393
+ ### fillField
394
+
395
+ Fills a text field or textarea, after clearing its value, with the given string.
396
+ Field is located by name, label, CSS, or XPath.
397
+
398
+ ```js
399
+ // by label
400
+ I.fillField('Email', 'hello@world.com');
401
+ // by name
402
+ I.fillField('password', secret('123456'));
403
+ // by CSS
404
+ I.fillField('form#login input[name=username]', 'John');
405
+ // or by strict locator
406
+ I.fillField({css: 'form#login input[name=username]'}, 'John');
407
+ ```
408
+
409
+ #### Parameters
410
+
411
+ - `field` ([string][3] \| [object][4]) located by label|name|CSS|XPath|strict locator.
412
+ - `value` [string][3] text value to fill.
413
+
414
+
415
+
416
+ ### grabAttributeFrom
417
+
418
+ Retrieves an attribute from an element located by CSS or XPath and returns it to test.
419
+ An array as a result will be returned if there are more than one matched element.
420
+ Resumes test execution, so should be used inside async with `await` operator.
421
+
422
+ ```js
423
+ let hint = await I.grabAttributeFrom('#tooltip', 'title');
424
+ ```
425
+
426
+ #### Parameters
427
+
428
+ - `locator` ([string][3] \| [object][4]) element located by CSS|XPath|strict locator.
429
+ - `attr` [string][3] attribute name.
430
+
431
+ Returns [Promise][6]&lt;[string][3]> attribute value
432
+
433
+
434
+
435
+ ### grabBrowserLogs
436
+
437
+ Get JS log from browser.
438
+
439
+ ```js
440
+ let logs = await I.grabBrowserLogs();
441
+ console.log(JSON.stringify(logs))
442
+ ```
443
+
444
+ ### grabCookie
445
+
446
+ Gets a cookie object by name.
447
+ If none provided gets all cookies.
448
+
449
+ - Resumes test execution, so should be used inside async with `await` operator.
450
+
451
+ ```js
452
+ let cookie = await I.grabCookie('auth');
453
+ assert(cookie.value, '123456');
454
+ ```
455
+
456
+ #### Parameters
457
+
458
+ - `name` cookie name.
459
+
460
+ Returns [Promise][6]&lt;[string][3]> attribute value
461
+
462
+ Returns cookie in JSON format. If name not passed returns all cookies for this domain.
463
+
464
+ ### grabCurrentUrl
465
+
466
+ Get current URL from browser.
467
+ Resumes test execution, so should be used inside an async function.
468
+
469
+ ```js
470
+ let url = await I.grabCurrentUrl();
471
+ console.log(`Current URL is [${url}]`);
472
+ ```
473
+
474
+ Returns [Promise][6]&lt;[string][3]> current URL
475
+
476
+
477
+
478
+ ### grabNumberOfVisibleElements
479
+
480
+ Grab number of visible elements by locator.
481
+
482
+ ```js
483
+ let numOfElements = await I.grabNumberOfVisibleElements('p');
484
+ ```
485
+
486
+ #### Parameters
487
+
488
+ - `locator` ([string][3] \| [object][4]) located by CSS|XPath|strict locator.
489
+
490
+ Returns [Promise][6]&lt;[number][7]> number of visible elements
491
+
492
+
493
+
494
+ ### grabPageScrollPosition
495
+
496
+ Retrieves a page scroll position and returns it to test.
497
+ Resumes test execution, so should be used inside an async function with `await` operator.
498
+
499
+ ```js
500
+ let { x, y } = await I.grabPageScrollPosition();
501
+ ```
502
+
503
+ Returns [Promise][6]&lt;[object][4]> scroll position
504
+
505
+
506
+
507
+ ### grabSource
508
+
509
+ Retrieves page source and returns it to test.
510
+ Resumes test execution, so should be used inside an async function.
511
+
512
+ ```js
513
+ let pageSource = await I.grabSource();
514
+ ```
515
+
516
+ Returns [Promise][6]&lt;[string][3]> source code
517
+
518
+
519
+
520
+ ### grabTextFrom
521
+
522
+ Retrieves a text from an element located by CSS or XPath and returns it to test.
523
+ Resumes test execution, so should be used inside async with `await` operator.
524
+
525
+ ```js
526
+ let pin = await I.grabTextFrom('#pin');
527
+ ```
528
+
529
+ If multiple elements found returns an array of texts.
530
+
531
+ #### Parameters
532
+
533
+ - `locator` element located by CSS|XPath|strict locator.
534
+
535
+ Returns [Promise][6]&lt;[string][3]> attribute value
536
+
537
+
538
+
539
+ ### grabValueFrom
540
+
541
+ Retrieves a value from a form element located by CSS or XPath and returns it to test.
542
+ Resumes test execution, so should be used inside async function with `await` operator.
543
+
544
+ ```js
545
+ let email = await I.grabValueFrom('input[name=email]');
546
+ ```
547
+
548
+ #### Parameters
549
+
550
+ - `locator` ([string][3] \| [object][4]) field located by label|name|CSS|XPath|strict locator.
551
+
552
+ Returns [Promise][6]&lt;[string][3]> attribute value
553
+
554
+
555
+
556
+ ### moveCursorTo
557
+
558
+ Moves cursor to element matched by locator.
559
+ Extra shift can be set with offsetX and offsetY options.
560
+
561
+ ```js
562
+ I.moveCursorTo('.tooltip');
563
+ I.moveCursorTo('#submit', 5,5);
564
+ ```
565
+
566
+ #### Parameters
567
+
568
+ - `locator` ([string][3] \| [object][4]) located by CSS|XPath|strict locator.
569
+ - `offsetX` [number][7] (optional, `0` by default) X-axis offset.
570
+ - `offsetY` [number][7] (optional, `0` by default) Y-axis offset.
571
+
572
+
573
+
574
+ ### pressKey
575
+
576
+ Presses a key on a focused element.
577
+ Special keys like 'Enter', 'Control', [etc][8]
578
+ will be replaced with corresponding unicode.
579
+ If modifier key is used (Control, Command, Alt, Shift) in array, it will be released afterwards.
580
+
581
+ ```js
582
+ I.pressKey('Enter');
583
+ I.pressKey(['Control','a']);
584
+ ```
585
+
586
+ #### Parameters
587
+
588
+ - `key` ([string][3] \| [array][9]) key or array of keys to press.
589
+
590
+
591
+
592
+
593
+ [Valid key names](https://w3c.github.io/webdriver/#keyboard-actions) are:
594
+
595
+ - `'Add'`,
596
+ - `'Alt'`,
597
+ - `'ArrowDown'` or `'Down arrow'`,
598
+ - `'ArrowLeft'` or `'Left arrow'`,
599
+ - `'ArrowRight'` or `'Right arrow'`,
600
+ - `'ArrowUp'` or `'Up arrow'`,
601
+ - `'Backspace'`,
602
+ - `'Command'`,
603
+ - `'Control'`,
604
+ - `'Del'`,
605
+ - `'Divide'`,
606
+ - `'End'`,
607
+ - `'Enter'`,
608
+ - `'Equals'`,
609
+ - `'Escape'`,
610
+ - `'F1 to F12'`,
611
+ - `'Home'`,
612
+ - `'Insert'`,
613
+ - `'Meta'`,
614
+ - `'Multiply'`,
615
+ - `'Numpad 0'` to `'Numpad 9'`,
616
+ - `'Pagedown'` or `'PageDown'`,
617
+ - `'Pageup'` or `'PageUp'`,
618
+ - `'Pause'`,
619
+ - `'Semicolon'`,
620
+ - `'Shift'`,
621
+ - `'Space'`,
622
+ - `'Subtract'`,
623
+ - `'Tab'`.
624
+
625
+ ### refreshPage
626
+
627
+ Reload the current page.
628
+
629
+ ```js
630
+ I.refreshPage();
631
+ ```
632
+
633
+
634
+
635
+
636
+ ### resizeWindow
637
+
638
+ Resize the current window to provided width and height.
639
+ First parameter can be set to `maximize`.
640
+
641
+ #### Parameters
642
+
643
+ - `width` [number][7] width in pixels or `maximize`.
644
+ - `height` [number][7] height in pixels.
645
+
646
+
647
+
648
+ ### rightClick
649
+
650
+ Performs right click on a clickable element matched by semantic locator, CSS or XPath.
651
+
652
+ ```js
653
+ // right click element with id el
654
+ I.rightClick('#el');
655
+ // right click link or button with text "Click me"
656
+ I.rightClick('Click me');
657
+ // right click button with text "Click me" inside .context
658
+ I.rightClick('Click me', '.context');
659
+ ```
660
+
661
+ #### Parameters
662
+
663
+ - `locator` ([string][3] \| [object][4]) clickable element located by CSS|XPath|strict locator.
664
+ - `context` ([string][3] \| [object][4]) (optional, `null` by default) element located by CSS|XPath|strict locator.
665
+
666
+
667
+
668
+ ### saveScreenshot
669
+
670
+ Saves a screenshot to ouput folder (set in codecept.json or codecept.conf.js).
671
+ Filename is relative to output folder.
672
+ Optionally resize the window to the full available page `scrollHeight` and `scrollWidth` to capture the entire page by passing `true` in as the second argument.
673
+
674
+ ```js
675
+ I.saveScreenshot('debug.png');
676
+ I.saveScreenshot('debug.png', true) //resizes to available scrollHeight and scrollWidth before taking screenshot
677
+ ```
678
+
679
+ #### Parameters
680
+
681
+ - `fileName` [string][3] file name to save.
682
+ - `fullPage` [boolean][10] (optional, `false` by default) flag to enable fullscreen screenshot mode.
683
+
684
+
685
+
686
+ ### scrollPageToBottom
687
+
688
+ Scroll page to the bottom.
689
+
690
+ ```js
691
+ I.scrollPageToBottom();
692
+ ```
693
+
694
+
695
+
696
+
697
+ ### scrollPageToTop
698
+
699
+ Scroll page to the top.
700
+
701
+ ```js
702
+ I.scrollPageToTop();
703
+ ```
704
+
705
+
706
+
707
+
708
+ ### scrollTo
709
+
710
+ Scrolls to element matched by locator.
711
+ Extra shift can be set with offsetX and offsetY options.
712
+
713
+ ```js
714
+ I.scrollTo('footer');
715
+ I.scrollTo('#submit', 5, 5);
716
+ ```
717
+
718
+ #### Parameters
719
+
720
+ - `locator` ([string][3] \| [object][4]) located by CSS|XPath|strict locator.
721
+ - `offsetX` [number][7] (optional, `0` by default) X-axis offset.
722
+ - `offsetY` [number][7] (optional, `0` by default) Y-axis offset.
723
+
724
+
725
+
726
+ ### see
727
+
728
+ Checks that a page contains a visible text.
729
+ Use context parameter to narrow down the search.
730
+
731
+ ```js
732
+ I.see('Welcome'); // text welcome on a page
733
+ I.see('Welcome', '.content'); // text inside .content div
734
+ I.see('Register', {css: 'form.register'}); // use strict locator
735
+ ```
736
+
737
+ #### Parameters
738
+
739
+ - `text` [string][3] expected on page.
740
+ - `context` ([string][3] \| [object][4]) (optional, `null` by default) element located by CSS|Xpath|strict locator in which to search for text.
741
+
742
+
743
+
744
+ ### seeCheckboxIsChecked
745
+
746
+ Verifies that the specified checkbox is checked.
747
+
748
+ ```js
749
+ I.seeCheckboxIsChecked('Agree');
750
+ I.seeCheckboxIsChecked('#agree'); // I suppose user agreed to terms
751
+ I.seeCheckboxIsChecked({css: '#signup_form input[type=checkbox]'});
752
+ ```
753
+
754
+ #### Parameters
755
+
756
+ - `field` ([string][3] \| [object][4]) located by label|name|CSS|XPath|strict locator.
757
+
758
+
759
+
760
+ ### seeCookie
761
+
762
+ Checks that cookie with given name exists.
763
+
764
+ ```js
765
+ I.seeCookie('Auth');
766
+ ```
767
+
768
+ #### Parameters
769
+
770
+ - `name` [string][3] cookie name.
771
+
772
+
773
+
774
+ ### seeCurrentUrlEquals
775
+
776
+ Checks that current url is equal to provided one.
777
+ If a relative url provided, a configured url will be prepended to it.
778
+ So both examples will work:
779
+
780
+ ```js
781
+ I.seeCurrentUrlEquals('/register');
782
+ I.seeCurrentUrlEquals('http://my.site.com/register');
783
+ ```
784
+
785
+ #### Parameters
786
+
787
+ - `url` [string][3] value to check.
788
+
789
+
790
+
791
+ ### seeElement
792
+
793
+ Checks that a given Element is visible
794
+ Element is located by CSS or XPath.
795
+
796
+ ```js
797
+ I.seeElement('#modal');
798
+ ```
799
+
800
+ #### Parameters
801
+
802
+ - `locator` ([string][3] \| [object][4]) located by CSS|XPath|strict locator.
803
+
804
+
805
+
806
+ ### seeElementInDOM
807
+
808
+ Checks that a given Element is present in the DOM
809
+ Element is located by CSS or XPath.
810
+
811
+ ```js
812
+ I.seeElementInDOM('#modal');
813
+ ```
814
+
815
+ #### Parameters
816
+
817
+ - `locator` ([string][3] \| [object][4]) element located by CSS|XPath|strict locator.
818
+
819
+
820
+
821
+ ### seeInCurrentUrl
822
+
823
+ Checks that current url contains a provided fragment.
824
+
825
+ ```js
826
+ I.seeInCurrentUrl('/register'); // we are on registration page
827
+ ```
828
+
829
+ #### Parameters
830
+
831
+ - `url` [string][3] a fragment to check
832
+
833
+
834
+
835
+ ### seeInField
836
+
837
+ Checks that the given input field or textarea equals to given value.
838
+ For fuzzy locators, fields are matched by label text, the "name" attribute, CSS, and XPath.
839
+
840
+ ```js
841
+ I.seeInField('Username', 'davert');
842
+ I.seeInField({css: 'form textarea'},'Type your comment here');
843
+ I.seeInField('form input[type=hidden]','hidden_value');
844
+ I.seeInField('#searchform input','Search');
845
+ ```
846
+
847
+ #### Parameters
848
+
849
+ - `field` ([string][3] \| [object][4]) located by label|name|CSS|XPath|strict locator.
850
+ - `value` [string][3] value to check.
851
+
852
+
853
+
854
+ ### seeInSource
855
+
856
+ Checks that the current page contains the given string in its raw source code.
857
+
858
+ ```js
859
+ I.seeInSource('<h1>Green eggs &amp; ham</h1>');
860
+ ```
861
+
862
+ #### Parameters
863
+
864
+ - `text` [string][3] value to check.
865
+
866
+
867
+
868
+ ### seeNumberOfVisibleElements
869
+
870
+ Asserts that an element is visible a given number of times.
871
+ Element is located by CSS or XPath.
872
+
873
+ ```js
874
+ I.seeNumberOfVisibleElements('.buttons', 3);
875
+ ```
876
+
877
+ #### Parameters
878
+
879
+ - `locator` ([string][3] \| [object][4]) element located by CSS|XPath|strict locator.
880
+ - `num` [number][7] number of elements.
881
+
882
+
883
+
884
+ ### seeTextEquals
885
+
886
+ Checks that text is equal to provided one.
887
+
888
+ ```js
889
+ I.seeTextEquals('text', 'h1');
890
+ ```
891
+
892
+ #### Parameters
893
+
894
+ - `text`
895
+ - `context`
896
+
897
+ ### selectOption
898
+
899
+ Selects an option in a drop-down select.
900
+ Field is searched by label | name | CSS | XPath.
901
+ Option is selected by visible text or by value.
902
+
903
+ ```js
904
+ I.selectOption('Choose Plan', 'Monthly'); // select by label
905
+ I.selectOption('subscription', 'Monthly'); // match option by text
906
+ I.selectOption('subscription', '0'); // or by value
907
+ I.selectOption('//form/select[@name=account]','Premium');
908
+ I.selectOption('form select[name=account]', 'Premium');
909
+ I.selectOption({css: 'form select[name=account]'}, 'Premium');
910
+ ```
911
+
912
+ Provide an array for the second argument to select multiple options.
913
+
914
+ ```js
915
+ I.selectOption('Which OS do you use?', ['Android', 'iOS']);
916
+ ```
917
+
918
+ #### Parameters
919
+
920
+ - `select` ([string][3] \| [object][4]) field located by label|name|CSS|XPath|strict locator.
921
+ - `option` ([string][3] \| [array][9]) visible text or value of option.
922
+
923
+
924
+
925
+ ### setCookie
926
+
927
+ Sets a cookie.
928
+
929
+ ```js
930
+ I.setCookie({name: 'auth', value: true});
931
+ ```
932
+
933
+ #### Parameters
934
+
935
+ - `cookie` [object][4] a cookie object.
936
+
937
+
938
+
939
+ ### switchTo
940
+
941
+ Switches frame or in case of null locator reverts to parent.
942
+
943
+ ```js
944
+ I.switchTo('iframe'); // switch to first iframe
945
+ I.switchTo(); // switch back to main page
946
+ ```
947
+
948
+ #### Parameters
949
+
950
+ - `locator` ([string][3] \| [object][4]) (optional, `null` by default) element located by CSS|XPath|strict locator.
951
+
952
+
953
+
954
+ ### uncheckOption
955
+
956
+ Unselects a checkbox or radio button.
957
+ Element is located by label or name or CSS or XPath.
958
+
959
+ The second parameter is a context (CSS or XPath locator) to narrow the search.
960
+
961
+ ```js
962
+ I.uncheckOption('#agree');
963
+ I.uncheckOption('I Agree to Terms and Conditions');
964
+ I.uncheckOption('agree', '//form');
965
+ ```
966
+
967
+ #### Parameters
968
+
969
+ - `field` ([string][3] \| [object][4]) checkbox located by label | name | CSS | XPath | strict locator.
970
+ - `context` [string][3] (optional, `null` by default) element located by CSS | XPath | strict locator.
971
+
972
+
973
+
974
+ ### wait
975
+
976
+ Pauses execution for a number of seconds.
977
+
978
+ ```js
979
+ I.wait(2); // wait 2 secs
980
+ ```
981
+
982
+ #### Parameters
983
+
984
+ - `sec` [number][7] number of second to wait.
985
+
986
+
987
+
988
+ ### waitForElement
989
+
990
+ Waits for element to be present on page (by default waits for 1sec).
991
+ Element can be located by CSS or XPath.
992
+
993
+ ```js
994
+ I.waitForElement('.btn.continue');
995
+ I.waitForElement('.btn.continue', 5); // wait for 5 secs
996
+ ```
997
+
998
+ #### Parameters
999
+
1000
+ - `locator` ([string][3] \| [object][4]) element located by CSS|XPath|strict locator.
1001
+ - `sec` [number][7] (optional, `1` by default) time in seconds to wait
1002
+
1003
+
1004
+
1005
+ ### waitForFunction
1006
+
1007
+ Waits for a function to return true (waits for 1 sec by default).
1008
+ Running in browser context.
1009
+
1010
+ ```js
1011
+ I.waitForFunction(fn[, [args[, timeout]])
1012
+ ```
1013
+
1014
+ ```js
1015
+ I.waitForFunction(() => window.requests == 0);
1016
+ I.waitForFunction(() => window.requests == 0, 5); // waits for 5 sec
1017
+ I.waitForFunction((count) => window.requests == count, [3], 5) // pass args and wait for 5 sec
1018
+ ```
1019
+
1020
+ #### Parameters
1021
+
1022
+ - `fn` ([string][3] \| [function][5]) to be executed in browser context.
1023
+ - `argsOrSec` ([array][9] \| [number][7]) (optional, `1` by default) arguments for function or seconds.
1024
+ - `sec` [number][7] (optional, `1` by default) time in seconds to wait
1025
+
1026
+
1027
+
1028
+ ### waitForInvisible
1029
+
1030
+ Waits for an element to be removed or become invisible on a page (by default waits for 1sec).
1031
+ Element can be located by CSS or XPath.
1032
+
1033
+ ```js
1034
+ I.waitForInvisible('#popup');
1035
+ ```
1036
+
1037
+ #### Parameters
1038
+
1039
+ - `locator` ([string][3] \| [object][4]) element located by CSS|XPath|strict locator.
1040
+ - `sec` [number][7] (optional, `1` by default) time in seconds to wait
1041
+
1042
+
1043
+
1044
+ ### waitForText
1045
+
1046
+ Waits for a text to appear (by default waits for 1sec).
1047
+ Element can be located by CSS or XPath.
1048
+ Narrow down search results by providing context.
1049
+
1050
+ ```js
1051
+ I.waitForText('Thank you, form has been submitted');
1052
+ I.waitForText('Thank you, form has been submitted', 5, '#modal');
1053
+ ```
1054
+
1055
+ #### Parameters
1056
+
1057
+ - `text` [string][3] to wait for.
1058
+ - `sec` [number][7] (optional, `1` by default) time in seconds to wait
1059
+ - `context` ([string][3] \| [object][4]) (optional) element located by CSS|XPath|strict locator.
1060
+
1061
+
1062
+
1063
+ ### waitForVisible
1064
+
1065
+ Waits for an element to become visible on a page (by default waits for 1sec).
1066
+ Element can be located by CSS or XPath.
1067
+
1068
+ ```js
1069
+ I.waitForVisible('#popup');
1070
+ ```
1071
+
1072
+ #### Parameters
1073
+
1074
+ - `locator` ([string][3] \| [object][4]) element located by CSS|XPath|strict locator.
1075
+ - `sec` [number][7] (optional, `1` by default) time in seconds to wait
1076
+
1077
+
1078
+
1079
+ ### waitInUrl
1080
+
1081
+ Waiting for the part of the URL to match the expected. Useful for SPA to understand that page was changed.
1082
+
1083
+ ```js
1084
+ I.waitInUrl('/info', 2);
1085
+ ```
1086
+
1087
+ #### Parameters
1088
+
1089
+ - `urlPart` [string][3] value to check.
1090
+ - `sec` [number][7] (optional, `1` by default) time in seconds to wait
1091
+
1092
+
1093
+
1094
+ ### waitNumberOfVisibleElements
1095
+
1096
+ Waits for a specified number of elements on the page.
1097
+
1098
+ ```js
1099
+ I.waitNumberOfVisibleElements('a', 3);
1100
+ ```
1101
+
1102
+ #### Parameters
1103
+
1104
+ - `locator` ([string][3] \| [object][4]) element located by CSS|XPath|strict locator.
1105
+ - `num` [number][7] number of elements.
1106
+ - `sec` [number][7] (optional, `1` by default) time in seconds to wait
1107
+
1108
+
1109
+
1110
+ ### waitToHide
1111
+
1112
+ Waits for an element to hide (by default waits for 1sec).
1113
+ Element can be located by CSS or XPath.
1114
+
1115
+ ```js
1116
+ I.waitToHide('#popup');
1117
+ ```
1118
+
1119
+ #### Parameters
1120
+
1121
+ - `locator` ([string][3] \| [object][4]) element located by CSS|XPath|strict locator.
1122
+ - `sec` [number][7] (optional, `1` by default) time in seconds to wait
1123
+
1124
+
1125
+
1126
+ ### waitUrlEquals
1127
+
1128
+ Waits for the entire URL to match the expected
1129
+
1130
+ ```js
1131
+ I.waitUrlEquals('/info', 2);
1132
+ I.waitUrlEquals('http://127.0.0.1:8000/info');
1133
+ ```
1134
+
1135
+ #### Parameters
1136
+
1137
+ - `urlPart` [string][3] value to check.
1138
+ - `sec` [number][7] (optional, `1` by default) time in seconds to wait
1139
+
1140
+
1141
+
1142
+ ## getPageUrl
1143
+
1144
+ Client Functions
1145
+
1146
+ ### Parameters
1147
+
1148
+ - `t`
1149
+
1150
+ [1]: https://github.com/DevExpress/testcafe
1151
+
1152
+ [2]: https://devexpress.github.io/testcafe/documentation/using-testcafe/common-concepts/browsers/browser-support.html
1153
+
1154
+ [3]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
1155
+
1156
+ [4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
1157
+
1158
+ [5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function
1159
+
1160
+ [6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise
1161
+
1162
+ [7]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
1163
+
1164
+ [8]: https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/element/:id/value
1165
+
1166
+ [9]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array
1167
+
1168
+ [10]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean