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,1305 @@
1
+ ---
2
+ permalink: /helpers/Nightmare
3
+ editLink: false
4
+ sidebar: auto
5
+ title: Nightmare
6
+ ---
7
+
8
+ <!-- Generated by documentation.js. Update this documentation by updating the source code. -->
9
+
10
+ ## Nightmare
11
+
12
+ **Extends Helper**
13
+
14
+ Nightmare helper wraps [Nightmare][1] library to provide
15
+ fastest headless testing using Electron engine. Unlike Selenium-based drivers this uses
16
+ Chromium-based browser with Electron with lots of client side scripts, thus should be less stable and
17
+ less trusted.
18
+
19
+ Requires `nightmare` package to be installed.
20
+
21
+ ## Configuration
22
+
23
+ This helper should be configured in codecept.conf.ts or codecept.conf.js
24
+
25
+ - `url` - base url of website to be tested
26
+ - `restart` - restart browser between tests.
27
+ - `disableScreenshots` - don't save screenshot on failure.
28
+ - `uniqueScreenshotNames` - option to prevent screenshot override if you have scenarios with the same name in different suites.
29
+ - `fullPageScreenshots` - make full page screenshots on failure.
30
+ - `keepBrowserState` - keep browser state between tests when `restart` set to false.
31
+ - `keepCookies` - keep cookies between tests when `restart` set to false.
32
+ - `waitForAction`: (optional) how long to wait after click, doubleClick or PressKey actions in ms. Default: 500.
33
+ - `waitForTimeout`: (optional) default wait* timeout in ms. Default: 1000.
34
+ - `windowSize`: (optional) default window size. Set a dimension like `640x480`.
35
+
36
+
37
+ - options from [Nightmare configuration][2]
38
+
39
+ ## Methods
40
+
41
+ ### Parameters
42
+
43
+ - `config`
44
+
45
+ ### _locate
46
+
47
+ Locate elements by different locator types, including strict locator.
48
+ Should be used in custom helpers.
49
+
50
+ This method return promise with array of IDs of found elements.
51
+ Actual elements can be accessed inside `evaluate` by using `codeceptjs.fetchElement()`
52
+ client-side function:
53
+
54
+ ```js
55
+ // get an inner text of an element
56
+
57
+ let browser = this.helpers['Nightmare'].browser;
58
+ let value = this.helpers['Nightmare']._locate({name: 'password'}).then(function(els) {
59
+ return browser.evaluate(function(el) {
60
+ return codeceptjs.fetchElement(el).value;
61
+ }, els[0]);
62
+ });
63
+ ```
64
+
65
+ #### Parameters
66
+
67
+ - `locator`
68
+
69
+ ### amOnPage
70
+
71
+ Opens a web page in a browser. Requires relative or absolute url.
72
+ If url starts with `/`, opens a web page of a site defined in `url` config parameter.
73
+
74
+ ```js
75
+ I.amOnPage('/'); // opens main page of website
76
+ I.amOnPage('https://github.com'); // opens github
77
+ I.amOnPage('/login'); // opens a login page
78
+ ```
79
+
80
+ #### Parameters
81
+
82
+ - `url` **[string][3]** url path or global url.
83
+ - `headers` **[object][4]?** list of request headers can be passed
84
+
85
+ Returns **void** automatically synchronized promise through #recorder
86
+
87
+ ### appendField
88
+
89
+ Appends text to a input field or textarea.
90
+ Field is located by name, label, CSS or XPath
91
+
92
+ ```js
93
+ I.appendField('#myTextField', 'appended');
94
+ // typing secret
95
+ I.appendField('password', secret('123456'));
96
+ ```
97
+
98
+ #### Parameters
99
+
100
+ - `field` **([string][3] | [object][4])** located by label|name|CSS|XPath|strict locator
101
+ - `value` **[string][3]** text value to append.
102
+
103
+ Returns **void** automatically synchronized promise through #recorder
104
+
105
+ ### attachFile
106
+
107
+ Attaches a file to element located by label, name, CSS or XPath
108
+ Path to file is relative current codecept directory (where codecept.conf.ts or codecept.conf.js is located).
109
+ File will be uploaded to remote system (if tests are running remotely).
110
+
111
+ ```js
112
+ I.attachFile('Avatar', 'data/avatar.jpg');
113
+ I.attachFile('form input[name=avatar]', 'data/avatar.jpg');
114
+ ```
115
+
116
+ #### Parameters
117
+
118
+ - `locator` **([string][3] | [object][4])** field located by label|name|CSS|XPath|strict locator.
119
+ - `pathToFile` **[string][3]** local file path relative to codecept.conf.ts or codecept.conf.js config file.
120
+
121
+ Returns **void** automatically synchronized promise through #recorderDoesn't work if the Chromium DevTools panel is open (as Chromium allows only one attachment to the debugger at a time. [See more][5])
122
+
123
+ ### checkOption
124
+
125
+ Selects a checkbox or radio button.
126
+ Element is located by label or name or CSS or XPath.
127
+
128
+ The second parameter is a context (CSS or XPath locator) to narrow the search.
129
+
130
+ ```js
131
+ I.checkOption('#agree');
132
+ I.checkOption('I Agree to Terms and Conditions');
133
+ I.checkOption('agree', '//form');
134
+ ```
135
+
136
+ #### Parameters
137
+
138
+ - `field` **([string][3] | [object][4])** checkbox located by label | name | CSS | XPath | strict locator.
139
+ - `context` **([string][3]? | [object][4])** (optional, `null` by default) element located by CSS | XPath | strict locator.
140
+
141
+ Returns **void** automatically synchronized promise through #recorder
142
+
143
+ ### clearCookie
144
+
145
+ Clears a cookie by name,
146
+ if none provided clears all cookies.
147
+
148
+ ```js
149
+ I.clearCookie();
150
+ I.clearCookie('test'); // Playwright currently doesn't support clear a particular cookie name
151
+ ```
152
+
153
+ #### Parameters
154
+
155
+ - `cookie` **[string][3]?** (optional, `null` by default) cookie name
156
+
157
+ ### clearField
158
+
159
+ Clears a `<textarea>` or text `<input>` element's value.
160
+
161
+ ```js
162
+ I.clearField('Email');
163
+ I.clearField('user[email]');
164
+ I.clearField('#email');
165
+ ```
166
+
167
+ #### Parameters
168
+
169
+ - `field`
170
+ - `editable` **([string][3] | [object][4])** field located by label|name|CSS|XPath|strict locator.
171
+
172
+ Returns **void** automatically synchronized promise through #recorder.
173
+
174
+ ### click
175
+
176
+ Perform a click on a link or a button, given by a locator.
177
+ If a fuzzy locator is given, the page will be searched for a button, link, or image matching the locator string.
178
+ For buttons, the "value" attribute, "name" attribute, and inner text are searched. For links, the link text is searched.
179
+ For images, the "alt" attribute and inner text of any parent links are searched.
180
+
181
+ The second parameter is a context (CSS or XPath locator) to narrow the search.
182
+
183
+ ```js
184
+ // simple link
185
+ I.click('Logout');
186
+ // button of form
187
+ I.click('Submit');
188
+ // CSS button
189
+ I.click('#form input[type=submit]');
190
+ // XPath
191
+ I.click('//form/*[@type=submit]');
192
+ // link in context
193
+ I.click('Logout', '#nav');
194
+ // using strict locator
195
+ I.click({css: 'nav a.login'});
196
+ ```
197
+
198
+ #### Parameters
199
+
200
+ - `locator` **([string][3] | [object][4])** clickable link or button located by text, or any element located by CSS|XPath|strict locator.
201
+ - `context` **([string][3]? | [object][4] | null)** (optional, `null` by default) element to search in CSS|XPath|Strict locator.
202
+
203
+ Returns **void** automatically synchronized promise through #recorder
204
+
205
+ ### dontSee
206
+
207
+ Opposite to `see`. Checks that a text is not present on a page.
208
+ Use context parameter to narrow down the search.
209
+
210
+ ```js
211
+ I.dontSee('Login'); // assume we are already logged in.
212
+ I.dontSee('Login', '.nav'); // no login inside .nav element
213
+ ```
214
+
215
+ #### Parameters
216
+
217
+ - `text` **[string][3]** which is not present.
218
+ - `context` **([string][3] | [object][4])?** (optional) element located by CSS|XPath|strict locator in which to perfrom search.
219
+
220
+ Returns **void** automatically synchronized promise through #recorder
221
+
222
+ ### dontSeeCheckboxIsChecked
223
+
224
+ Verifies that the specified checkbox is not checked.
225
+
226
+ ```js
227
+ I.dontSeeCheckboxIsChecked('#agree'); // located by ID
228
+ I.dontSeeCheckboxIsChecked('I agree to terms'); // located by label
229
+ I.dontSeeCheckboxIsChecked('agree'); // located by name
230
+ ```
231
+
232
+ #### Parameters
233
+
234
+ - `field` **([string][3] | [object][4])** located by label|name|CSS|XPath|strict locator.
235
+
236
+ Returns **void** automatically synchronized promise through #recorder
237
+
238
+ ### dontSeeCookie
239
+
240
+ Checks that cookie with given name does not exist.
241
+
242
+ ```js
243
+ I.dontSeeCookie('auth'); // no auth cookie
244
+ ```
245
+
246
+ #### Parameters
247
+
248
+ - `name` **[string][3]** cookie name.
249
+
250
+ Returns **void** automatically synchronized promise through #recorder
251
+
252
+ ### dontSeeCurrentUrlEquals
253
+
254
+ Checks that current url is not equal to provided one.
255
+ If a relative url provided, a configured url will be prepended to it.
256
+
257
+ ```js
258
+ I.dontSeeCurrentUrlEquals('/login'); // relative url are ok
259
+ I.dontSeeCurrentUrlEquals('http://mysite.com/login'); // absolute urls are also ok
260
+ ```
261
+
262
+ #### Parameters
263
+
264
+ - `url` **[string][3]** value to check.
265
+
266
+ Returns **void** automatically synchronized promise through #recorder
267
+
268
+ ### dontSeeElement
269
+
270
+ Opposite to `seeElement`. Checks that element is not visible (or in DOM)
271
+
272
+ ```js
273
+ I.dontSeeElement('.modal'); // modal is not shown
274
+ ```
275
+
276
+ #### Parameters
277
+
278
+ - `locator` **([string][3] | [object][4])** located by CSS|XPath|Strict locator.
279
+
280
+ Returns **void** automatically synchronized promise through #recorder
281
+
282
+ ### dontSeeElementInDOM
283
+
284
+ Opposite to `seeElementInDOM`. Checks that element is not on page.
285
+
286
+ ```js
287
+ I.dontSeeElementInDOM('.nav'); // checks that element is not on page visible or not
288
+ ```
289
+
290
+ #### Parameters
291
+
292
+ - `locator` **([string][3] | [object][4])** located by CSS|XPath|Strict locator.
293
+
294
+ Returns **void** automatically synchronized promise through #recorder
295
+
296
+ ### dontSeeInCurrentUrl
297
+
298
+ Checks that current url does not contain a provided fragment.
299
+
300
+ #### Parameters
301
+
302
+ - `url` **[string][3]** value to check.
303
+
304
+ Returns **void** automatically synchronized promise through #recorder
305
+
306
+ ### dontSeeInField
307
+
308
+ Checks that value of input field or textarea doesn't equal to given value
309
+ Opposite to `seeInField`.
310
+
311
+ ```js
312
+ I.dontSeeInField('email', 'user@user.com'); // field by name
313
+ I.dontSeeInField({ css: 'form input.email' }, 'user@user.com'); // field by CSS
314
+ ```
315
+
316
+ #### Parameters
317
+
318
+ - `field` **([string][3] | [object][4])** located by label|name|CSS|XPath|strict locator.
319
+ - `value` **([string][3] | [object][4])** value to check.
320
+
321
+ Returns **void** automatically synchronized promise through #recorder
322
+
323
+ ### dontSeeInSource
324
+
325
+ Checks that the current page does not contains the given string in its raw source code.
326
+
327
+ ```js
328
+ I.dontSeeInSource('<!--'); // no comments in source
329
+ ```
330
+
331
+ #### Parameters
332
+
333
+ - `text`
334
+ - `value` **[string][3]** to check.
335
+
336
+ Returns **void** automatically synchronized promise through #recorder
337
+
338
+ ### dontSeeInTitle
339
+
340
+ Checks that title does not contain text.
341
+
342
+ ```js
343
+ I.dontSeeInTitle('Error');
344
+ ```
345
+
346
+ #### Parameters
347
+
348
+ - `text` **[string][3]** value to check.
349
+
350
+ Returns **void** automatically synchronized promise through #recorder
351
+
352
+ ### doubleClick
353
+
354
+ Performs a double-click on an element matched by link|button|label|CSS or XPath.
355
+ Context can be specified as second parameter to narrow search.
356
+
357
+ ```js
358
+ I.doubleClick('Edit');
359
+ I.doubleClick('Edit', '.actions');
360
+ I.doubleClick({css: 'button.accept'});
361
+ I.doubleClick('.btn.edit');
362
+ ```
363
+
364
+ #### Parameters
365
+
366
+ - `locator` **([string][3] | [object][4])** clickable link or button located by text, or any element located by CSS|XPath|strict locator.
367
+ - `context` **([string][3]? | [object][4])** (optional, `null` by default) element to search in CSS|XPath|Strict locator.
368
+
369
+ Returns **void** automatically synchronized promise through #recorder
370
+
371
+ ### executeAsyncScript
372
+
373
+ Executes async script on page.
374
+ Provided function should execute a passed callback (as first argument) to signal it is finished.
375
+
376
+ Example: In Vue.js to make components completely rendered we are waiting for [nextTick][6].
377
+
378
+ ```js
379
+ I.executeAsyncScript(function(done) {
380
+ Vue.nextTick(done); // waiting for next tick
381
+ });
382
+ ```
383
+
384
+ By passing value to `done()` function you can return values.
385
+ Additional arguments can be passed as well, while `done` function is always last parameter in arguments list.
386
+
387
+ ```js
388
+ let val = await I.executeAsyncScript(function(url, done) {
389
+ // in browser context
390
+ $.ajax(url, { success: (data) => done(data); }
391
+ }, 'http://ajax.callback.url/');
392
+ ```
393
+
394
+ #### Parameters
395
+
396
+ - `args` **...any** to be passed to function.
397
+ - `fn` **([string][3] | [function][7])** function to be executed in browser context.
398
+
399
+ Returns **[Promise][8]&lt;any>** script return valueWrapper for asynchronous [evaluate][9].
400
+ Unlike NightmareJS implementation calling `done` will return its first argument.
401
+
402
+ ### executeScript
403
+
404
+ Executes sync script on a page.
405
+ Pass arguments to function as additional parameters.
406
+ Will return execution result to a test.
407
+ In this case you should use async function and await to receive results.
408
+
409
+ Example with jQuery DatePicker:
410
+
411
+ ```js
412
+ // change date of jQuery DatePicker
413
+ I.executeScript(function() {
414
+ // now we are inside browser context
415
+ $('date').datetimepicker('setDate', new Date());
416
+ });
417
+ ```
418
+
419
+ Can return values. Don't forget to use `await` to get them.
420
+
421
+ ```js
422
+ let date = await I.executeScript(function(el) {
423
+ // only basic types can be returned
424
+ return $(el).datetimepicker('getDate').toString();
425
+ }, '#date'); // passing jquery selector
426
+ ```
427
+
428
+ #### Parameters
429
+
430
+ - `args` **...any** to be passed to function.
431
+ - `fn` **([string][3] | [function][7])** function to be executed in browser context.
432
+
433
+ Returns **[Promise][8]&lt;any>** script return valueWrapper for synchronous [evaluate][9]
434
+
435
+ ### fillField
436
+
437
+ Fills a text field or textarea, after clearing its value, with the given string.
438
+ Field is located by name, label, CSS, or XPath.
439
+
440
+ ```js
441
+ // by label
442
+ I.fillField('Email', 'hello@world.com');
443
+ // by name
444
+ I.fillField('password', secret('123456'));
445
+ // by CSS
446
+ I.fillField('form#login input[name=username]', 'John');
447
+ // or by strict locator
448
+ I.fillField({css: 'form#login input[name=username]'}, 'John');
449
+ ```
450
+
451
+ #### Parameters
452
+
453
+ - `field` **([string][3] | [object][4])** located by label|name|CSS|XPath|strict locator.
454
+ - `value` **([string][3] | [object][4])** text value to fill.
455
+
456
+ Returns **void** automatically synchronized promise through #recorder
457
+
458
+ ### grabAttributeFrom
459
+
460
+ Retrieves an attribute from an element located by CSS or XPath and returns it to test.
461
+ Resumes test execution, so **should be used inside async with `await`** operator.
462
+ If more than one element is found - attribute of first element is returned.
463
+
464
+ ```js
465
+ let hint = await I.grabAttributeFrom('#tooltip', 'title');
466
+ ```
467
+
468
+ #### Parameters
469
+
470
+ - `locator` **([string][3] | [object][4])** element located by CSS|XPath|strict locator.
471
+ - `attr` **[string][3]** attribute name.
472
+
473
+ Returns **[Promise][8]&lt;[string][3]>** attribute value
474
+
475
+ ### grabAttributeFromAll
476
+
477
+ Retrieves an array of attributes from elements located by CSS or XPath and returns it to test.
478
+ Resumes test execution, so **should be used inside async with `await`** operator.
479
+
480
+ ```js
481
+ let hints = await I.grabAttributeFromAll('.tooltip', 'title');
482
+ ```
483
+
484
+ #### Parameters
485
+
486
+ - `locator` **([string][3] | [object][4])** element located by CSS|XPath|strict locator.
487
+ - `attr` **[string][3]** attribute name.
488
+
489
+ Returns **[Promise][8]&lt;[Array][10]&lt;[string][3]>>** attribute value
490
+
491
+ ### grabCookie
492
+
493
+ Gets a cookie object by name.
494
+ If none provided gets all cookies.
495
+ Resumes test execution, so **should be used inside async function with `await`** operator.
496
+
497
+ ```js
498
+ let cookie = await I.grabCookie('auth');
499
+ assert(cookie.value, '123456');
500
+ ```
501
+
502
+ #### Parameters
503
+
504
+ - `name` **[string][3]?** cookie name.
505
+
506
+ Returns **any** attribute valueCookie in JSON format. If name not passed returns all cookies for this domain.Multiple cookies can be received by passing query object `I.grabCookie({ secure: true});`. If you'd like get all cookies for all urls, use: `.grabCookie({ url: null }).`
507
+
508
+ ### grabCssPropertyFrom
509
+
510
+ Grab CSS property for given locator
511
+ Resumes test execution, so **should be used inside an async function with `await`** operator.
512
+ If more than one element is found - value of first element is returned.
513
+
514
+ ```js
515
+ const value = await I.grabCssPropertyFrom('h3', 'font-weight');
516
+ ```
517
+
518
+ #### Parameters
519
+
520
+ - `locator` **([string][3] | [object][4])** element located by CSS|XPath|strict locator.
521
+ - `cssProperty` **[string][3]** CSS property name.
522
+
523
+ Returns **[Promise][8]&lt;[string][3]>** CSS value
524
+
525
+ ### grabCurrentUrl
526
+
527
+ Get current URL from browser.
528
+ Resumes test execution, so should be used inside an async function.
529
+
530
+ ```js
531
+ let url = await I.grabCurrentUrl();
532
+ console.log(`Current URL is [${url}]`);
533
+ ```
534
+
535
+ Returns **[Promise][8]&lt;[string][3]>** current URL
536
+
537
+ ### grabElementBoundingRect
538
+
539
+ Grab the width, height, location of given locator.
540
+ Provide `width` or `height`as second param to get your desired prop.
541
+ Resumes test execution, so **should be used inside an async function with `await`** operator.
542
+
543
+ Returns an object with `x`, `y`, `width`, `height` keys.
544
+
545
+ ```js
546
+ const value = await I.grabElementBoundingRect('h3');
547
+ // value is like { x: 226.5, y: 89, width: 527, height: 220 }
548
+ ```
549
+
550
+ To get only one metric use second parameter:
551
+
552
+ ```js
553
+ const width = await I.grabElementBoundingRect('h3', 'width');
554
+ // width == 527
555
+ ```
556
+
557
+ #### Parameters
558
+
559
+ - `locator` **([string][3] | [object][4])** element located by CSS|XPath|strict locator.
560
+ - `prop`
561
+ - `elementSize` **[string][3]?** x, y, width or height of the given element.
562
+
563
+ Returns **([Promise][8]&lt;DOMRect> | [Promise][8]&lt;[number][11]>)** Element bounding rectangle
564
+
565
+ ### grabHAR
566
+
567
+ Get HAR
568
+
569
+ ```js
570
+ let har = await I.grabHAR();
571
+ fs.writeFileSync('sample.har', JSON.stringify({log: har}));
572
+ ```
573
+
574
+ ### grabHTMLFrom
575
+
576
+ Retrieves the innerHTML from an element located by CSS or XPath and returns it to test.
577
+ Resumes test execution, so **should be used inside async function with `await`** operator.
578
+ If more than one element is found - HTML of first element is returned.
579
+
580
+ ```js
581
+ let postHTML = await I.grabHTMLFrom('#post');
582
+ ```
583
+
584
+ #### Parameters
585
+
586
+ - `locator`
587
+ - `element` **([string][3] | [object][4])** located by CSS|XPath|strict locator.
588
+
589
+ Returns **[Promise][8]&lt;[string][3]>** HTML code for an element
590
+
591
+ ### grabHTMLFromAll
592
+
593
+ Retrieves all the innerHTML from elements located by CSS or XPath and returns it to test.
594
+ Resumes test execution, so **should be used inside async function with `await`** operator.
595
+
596
+ ```js
597
+ let postHTMLs = await I.grabHTMLFromAll('.post');
598
+ ```
599
+
600
+ #### Parameters
601
+
602
+ - `locator`
603
+ - `element` **([string][3] | [object][4])** located by CSS|XPath|strict locator.
604
+
605
+ Returns **[Promise][8]&lt;[Array][10]&lt;[string][3]>>** HTML code for an element
606
+
607
+ ### grabNumberOfVisibleElements
608
+
609
+ Grab number of visible elements by locator.
610
+ Resumes test execution, so **should be used inside async function with `await`** operator.
611
+
612
+ ```js
613
+ let numOfElements = await I.grabNumberOfVisibleElements('p');
614
+ ```
615
+
616
+ #### Parameters
617
+
618
+ - `locator` **([string][3] | [object][4])** located by CSS|XPath|strict locator.
619
+
620
+ Returns **[Promise][8]&lt;[number][11]>** number of visible elements
621
+
622
+ ### grabPageScrollPosition
623
+
624
+ Retrieves a page scroll position and returns it to test.
625
+ Resumes test execution, so **should be used inside an async function with `await`** operator.
626
+
627
+ ```js
628
+ let { x, y } = await I.grabPageScrollPosition();
629
+ ```
630
+
631
+ Returns **[Promise][8]&lt;PageScrollPosition>** scroll position
632
+
633
+ ### grabTextFrom
634
+
635
+ Retrieves a text from an element located by CSS or XPath and returns it to test.
636
+ Resumes test execution, so **should be used inside async with `await`** operator.
637
+
638
+ ```js
639
+ let pin = await I.grabTextFrom('#pin');
640
+ ```
641
+
642
+ If multiple elements found returns first element.
643
+
644
+ #### Parameters
645
+
646
+ - `locator` **([string][3] | [object][4])** element located by CSS|XPath|strict locator.
647
+
648
+ Returns **[Promise][8]&lt;[string][3]>** attribute value
649
+
650
+ ### grabTextFromAll
651
+
652
+ Retrieves all texts from an element located by CSS or XPath and returns it to test.
653
+ Resumes test execution, so **should be used inside async with `await`** operator.
654
+
655
+ ```js
656
+ let pins = await I.grabTextFromAll('#pin li');
657
+ ```
658
+
659
+ #### Parameters
660
+
661
+ - `locator` **([string][3] | [object][4])** element located by CSS|XPath|strict locator.
662
+
663
+ Returns **[Promise][8]&lt;[Array][10]&lt;[string][3]>>** attribute value
664
+
665
+ ### grabTitle
666
+
667
+ Retrieves a page title and returns it to test.
668
+ Resumes test execution, so **should be used inside async with `await`** operator.
669
+
670
+ ```js
671
+ let title = await I.grabTitle();
672
+ ```
673
+
674
+ Returns **[Promise][8]&lt;[string][3]>** title
675
+
676
+ ### grabValueFrom
677
+
678
+ Retrieves a value from a form element located by CSS or XPath and returns it to test.
679
+ Resumes test execution, so **should be used inside async function with `await`** operator.
680
+ If more than one element is found - value of first element is returned.
681
+
682
+ ```js
683
+ let email = await I.grabValueFrom('input[name=email]');
684
+ ```
685
+
686
+ #### Parameters
687
+
688
+ - `locator` **([string][3] | [object][4])** field located by label|name|CSS|XPath|strict locator.
689
+
690
+ Returns **[Promise][8]&lt;[string][3]>** attribute value
691
+
692
+ ### grabValueFromAll
693
+
694
+ Retrieves an array of value from a form located by CSS or XPath and returns it to test.
695
+ Resumes test execution, so **should be used inside async function with `await`** operator.
696
+
697
+ ```js
698
+ let inputs = await I.grabValueFromAll('//form/input');
699
+ ```
700
+
701
+ #### Parameters
702
+
703
+ - `locator` **([string][3] | [object][4])** field located by label|name|CSS|XPath|strict locator.
704
+
705
+ Returns **[Promise][8]&lt;[Array][10]&lt;[string][3]>>** attribute value
706
+
707
+ ### haveHeader
708
+
709
+ Add a header override for all HTTP requests. If header is undefined, the header overrides will be reset.
710
+
711
+ ```js
712
+ I.haveHeader('x-my-custom-header', 'some value');
713
+ I.haveHeader(); // clear headers
714
+ ```
715
+
716
+ #### Parameters
717
+
718
+ - `header`
719
+ - `value`
720
+
721
+ ### moveCursorTo
722
+
723
+ Moves cursor to element matched by locator.
724
+ Extra shift can be set with offsetX and offsetY options.
725
+
726
+ ```js
727
+ I.moveCursorTo('.tooltip');
728
+ I.moveCursorTo('#submit', 5,5);
729
+ ```
730
+
731
+ #### Parameters
732
+
733
+ - `locator` **([string][3] | [object][4])** located by CSS|XPath|strict locator.
734
+ - `offsetX` **[number][11]** (optional, `0` by default) X-axis offset.
735
+ - `offsetY` **[number][11]** (optional, `0` by default) Y-axis offset.
736
+
737
+ Returns **void** automatically synchronized promise through #recorder
738
+
739
+ ### pressKey
740
+
741
+ Sends [input event][12] on a page.
742
+ Can submit special keys like 'Enter', 'Backspace', etc
743
+
744
+ #### Parameters
745
+
746
+ - `key`
747
+
748
+ ### refresh
749
+
750
+ Reload the page
751
+
752
+ ### refreshPage
753
+
754
+ Reload the current page.
755
+
756
+ ```js
757
+ I.refreshPage();
758
+ ```
759
+
760
+ Returns **void** automatically synchronized promise through #recorder
761
+
762
+ ### resizeWindow
763
+
764
+ Resize the current window to provided width and height.
765
+ First parameter can be set to `maximize`.
766
+
767
+ #### Parameters
768
+
769
+ - `width` **[number][11]** width in pixels or `maximize`.
770
+ - `height` **[number][11]** height in pixels.
771
+
772
+ Returns **void** automatically synchronized promise through #recorder
773
+
774
+ ### rightClick
775
+
776
+ Performs right click on a clickable element matched by semantic locator, CSS or XPath.
777
+
778
+ ```js
779
+ // right click element with id el
780
+ I.rightClick('#el');
781
+ // right click link or button with text "Click me"
782
+ I.rightClick('Click me');
783
+ // right click button with text "Click me" inside .context
784
+ I.rightClick('Click me', '.context');
785
+ ```
786
+
787
+ #### Parameters
788
+
789
+ - `locator` **([string][3] | [object][4])** clickable element located by CSS|XPath|strict locator.
790
+ - `context` **([string][3]? | [object][4])** (optional, `null` by default) element located by CSS|XPath|strict locator.
791
+
792
+ Returns **void** automatically synchronized promise through #recorder
793
+
794
+ ### saveElementScreenshot
795
+
796
+ Saves screenshot of the specified locator to ouput folder (set in codecept.conf.ts or codecept.conf.js).
797
+ Filename is relative to output folder.
798
+
799
+ ```js
800
+ I.saveElementScreenshot(`#submit`,'debug.png');
801
+ ```
802
+
803
+ #### Parameters
804
+
805
+ - `locator` **([string][3] | [object][4])** element located by CSS|XPath|strict locator.
806
+ - `fileName` **[string][3]** file name to save.
807
+
808
+ Returns **void** automatically synchronized promise through #recorder
809
+
810
+ ### saveScreenshot
811
+
812
+ Saves a screenshot to ouput folder (set in codecept.conf.ts or codecept.conf.js).
813
+ Filename is relative to output folder.
814
+ 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.
815
+
816
+ ```js
817
+ I.saveScreenshot('debug.png');
818
+ I.saveScreenshot('debug.png', true) //resizes to available scrollHeight and scrollWidth before taking screenshot
819
+ ```
820
+
821
+ #### Parameters
822
+
823
+ - `fileName` **[string][3]** file name to save.
824
+ - `fullPage` **[boolean][13]** (optional, `false` by default) flag to enable fullscreen screenshot mode.
825
+
826
+ Returns **void** automatically synchronized promise through #recorder
827
+
828
+ ### scrollPageToBottom
829
+
830
+ Scroll page to the bottom.
831
+
832
+ ```js
833
+ I.scrollPageToBottom();
834
+ ```
835
+
836
+ Returns **void** automatically synchronized promise through #recorder
837
+
838
+ ### scrollPageToTop
839
+
840
+ Scroll page to the top.
841
+
842
+ ```js
843
+ I.scrollPageToTop();
844
+ ```
845
+
846
+ Returns **void** automatically synchronized promise through #recorder
847
+
848
+ ### scrollTo
849
+
850
+ Scrolls to element matched by locator.
851
+ Extra shift can be set with offsetX and offsetY options.
852
+
853
+ ```js
854
+ I.scrollTo('footer');
855
+ I.scrollTo('#submit', 5, 5);
856
+ ```
857
+
858
+ #### Parameters
859
+
860
+ - `locator` **([string][3] | [object][4])** located by CSS|XPath|strict locator.
861
+ - `offsetX` **[number][11]** (optional, `0` by default) X-axis offset.
862
+ - `offsetY` **[number][11]** (optional, `0` by default) Y-axis offset.
863
+
864
+ Returns **void** automatically synchronized promise through #recorder
865
+
866
+ ### see
867
+
868
+ Checks that a page contains a visible text.
869
+ Use context parameter to narrow down the search.
870
+
871
+ ```js
872
+ I.see('Welcome'); // text welcome on a page
873
+ I.see('Welcome', '.content'); // text inside .content div
874
+ I.see('Register', {css: 'form.register'}); // use strict locator
875
+ ```
876
+
877
+ #### Parameters
878
+
879
+ - `text` **[string][3]** expected on page.
880
+ - `context` **([string][3]? | [object][4])** (optional, `null` by default) element located by CSS|Xpath|strict locator in which to search for text.
881
+
882
+ Returns **void** automatically synchronized promise through #recorder
883
+
884
+ ### seeCheckboxIsChecked
885
+
886
+ Verifies that the specified checkbox is checked.
887
+
888
+ ```js
889
+ I.seeCheckboxIsChecked('Agree');
890
+ I.seeCheckboxIsChecked('#agree'); // I suppose user agreed to terms
891
+ I.seeCheckboxIsChecked({css: '#signup_form input[type=checkbox]'});
892
+ ```
893
+
894
+ #### Parameters
895
+
896
+ - `field` **([string][3] | [object][4])** located by label|name|CSS|XPath|strict locator.
897
+
898
+ Returns **void** automatically synchronized promise through #recorder
899
+
900
+ ### seeCookie
901
+
902
+ Checks that cookie with given name exists.
903
+
904
+ ```js
905
+ I.seeCookie('Auth');
906
+ ```
907
+
908
+ #### Parameters
909
+
910
+ - `name` **[string][3]** cookie name.
911
+
912
+ Returns **void** automatically synchronized promise through #recorder
913
+
914
+ ### seeCurrentUrlEquals
915
+
916
+ Checks that current url is equal to provided one.
917
+ If a relative url provided, a configured url will be prepended to it.
918
+ So both examples will work:
919
+
920
+ ```js
921
+ I.seeCurrentUrlEquals('/register');
922
+ I.seeCurrentUrlEquals('http://my.site.com/register');
923
+ ```
924
+
925
+ #### Parameters
926
+
927
+ - `url` **[string][3]** value to check.
928
+
929
+ Returns **void** automatically synchronized promise through #recorder
930
+
931
+ ### seeElement
932
+
933
+ Checks that a given Element is visible
934
+ Element is located by CSS or XPath.
935
+
936
+ ```js
937
+ I.seeElement('#modal');
938
+ ```
939
+
940
+ #### Parameters
941
+
942
+ - `locator` **([string][3] | [object][4])** located by CSS|XPath|strict locator.
943
+
944
+ Returns **void** automatically synchronized promise through #recorder
945
+
946
+ ### seeElementInDOM
947
+
948
+ Checks that a given Element is present in the DOM
949
+ Element is located by CSS or XPath.
950
+
951
+ ```js
952
+ I.seeElementInDOM('#modal');
953
+ ```
954
+
955
+ #### Parameters
956
+
957
+ - `locator` **([string][3] | [object][4])** element located by CSS|XPath|strict locator.
958
+
959
+ Returns **void** automatically synchronized promise through #recorder
960
+
961
+ ### seeInCurrentUrl
962
+
963
+ Checks that current url contains a provided fragment.
964
+
965
+ ```js
966
+ I.seeInCurrentUrl('/register'); // we are on registration page
967
+ ```
968
+
969
+ #### Parameters
970
+
971
+ - `url` **[string][3]** a fragment to check
972
+
973
+ Returns **void** automatically synchronized promise through #recorder
974
+
975
+ ### seeInField
976
+
977
+ Checks that the given input field or textarea equals to given value.
978
+ For fuzzy locators, fields are matched by label text, the "name" attribute, CSS, and XPath.
979
+
980
+ ```js
981
+ I.seeInField('Username', 'davert');
982
+ I.seeInField({css: 'form textarea'},'Type your comment here');
983
+ I.seeInField('form input[type=hidden]','hidden_value');
984
+ I.seeInField('#searchform input','Search');
985
+ ```
986
+
987
+ #### Parameters
988
+
989
+ - `field` **([string][3] | [object][4])** located by label|name|CSS|XPath|strict locator.
990
+ - `value` **([string][3] | [object][4])** value to check.
991
+
992
+ Returns **void** automatically synchronized promise through #recorder
993
+
994
+ ### seeInSource
995
+
996
+ Checks that the current page contains the given string in its raw source code.
997
+
998
+ ```js
999
+ I.seeInSource('<h1>Green eggs &amp; ham</h1>');
1000
+ ```
1001
+
1002
+ #### Parameters
1003
+
1004
+ - `text` **[string][3]** value to check.
1005
+
1006
+ Returns **void** automatically synchronized promise through #recorder
1007
+
1008
+ ### seeInTitle
1009
+
1010
+ Checks that title contains text.
1011
+
1012
+ ```js
1013
+ I.seeInTitle('Home Page');
1014
+ ```
1015
+
1016
+ #### Parameters
1017
+
1018
+ - `text` **[string][3]** text value to check.
1019
+
1020
+ Returns **void** automatically synchronized promise through #recorder
1021
+
1022
+ ### seeNumberOfElements
1023
+
1024
+ Asserts that an element appears a given number of times in the DOM.
1025
+ Element is located by label or name or CSS or XPath.
1026
+
1027
+ ```js
1028
+ I.seeNumberOfElements('#submitBtn', 1);
1029
+ ```
1030
+
1031
+ #### Parameters
1032
+
1033
+ - `locator` **([string][3] | [object][4])** element located by CSS|XPath|strict locator.
1034
+ - `num` **[number][11]** number of elements.
1035
+
1036
+ Returns **void** automatically synchronized promise through #recorder
1037
+
1038
+ ### seeNumberOfVisibleElements
1039
+
1040
+ Asserts that an element is visible a given number of times.
1041
+ Element is located by CSS or XPath.
1042
+
1043
+ ```js
1044
+ I.seeNumberOfVisibleElements('.buttons', 3);
1045
+ ```
1046
+
1047
+ #### Parameters
1048
+
1049
+ - `locator` **([string][3] | [object][4])** element located by CSS|XPath|strict locator.
1050
+ - `num` **[number][11]** number of elements.
1051
+
1052
+ Returns **void** automatically synchronized promise through #recorder
1053
+
1054
+ ### selectOption
1055
+
1056
+ Selects an option in a drop-down select.
1057
+ Field is searched by label | name | CSS | XPath.
1058
+ Option is selected by visible text or by value.
1059
+
1060
+ ```js
1061
+ I.selectOption('Choose Plan', 'Monthly'); // select by label
1062
+ I.selectOption('subscription', 'Monthly'); // match option by text
1063
+ I.selectOption('subscription', '0'); // or by value
1064
+ I.selectOption('//form/select[@name=account]','Premium');
1065
+ I.selectOption('form select[name=account]', 'Premium');
1066
+ I.selectOption({css: 'form select[name=account]'}, 'Premium');
1067
+ ```
1068
+
1069
+ Provide an array for the second argument to select multiple options.
1070
+
1071
+ ```js
1072
+ I.selectOption('Which OS do you use?', ['Android', 'iOS']);
1073
+ ```
1074
+
1075
+ #### Parameters
1076
+
1077
+ - `select` **([string][3] | [object][4])** field located by label|name|CSS|XPath|strict locator.
1078
+ - `option` **([string][3] | [Array][10]&lt;any>)** visible text or value of option.
1079
+
1080
+ Returns **void** automatically synchronized promise through #recorder
1081
+
1082
+ ### setCookie
1083
+
1084
+ Sets cookie(s).
1085
+
1086
+ Can be a single cookie object or an array of cookies:
1087
+
1088
+ ```js
1089
+ I.setCookie({name: 'auth', value: true});
1090
+
1091
+ // as array
1092
+ I.setCookie([
1093
+ {name: 'auth', value: true},
1094
+ {name: 'agree', value: true}
1095
+ ]);
1096
+ ```
1097
+
1098
+ #### Parameters
1099
+
1100
+ - `cookie` **(Cookie | [Array][10]&lt;Cookie>)** a cookie object or array of cookie objects.
1101
+
1102
+ Returns **void** automatically synchronized promise through #recorderWrapper for `.cookies.set(cookie)`.
1103
+ [See more][14]
1104
+
1105
+ ### triggerMouseEvent
1106
+
1107
+ Sends [input event][15] on a page.
1108
+ Should be a mouse event like:
1109
+ {
1110
+ type: 'mouseDown',
1111
+ x: args.x,
1112
+ y: args.y,
1113
+ button: "left"
1114
+ }
1115
+
1116
+ #### Parameters
1117
+
1118
+ - `event`
1119
+
1120
+ ### uncheckOption
1121
+
1122
+ Unselects a checkbox or radio button.
1123
+ Element is located by label or name or CSS or XPath.
1124
+
1125
+ The second parameter is a context (CSS or XPath locator) to narrow the search.
1126
+
1127
+ ```js
1128
+ I.uncheckOption('#agree');
1129
+ I.uncheckOption('I Agree to Terms and Conditions');
1130
+ I.uncheckOption('agree', '//form');
1131
+ ```
1132
+
1133
+ #### Parameters
1134
+
1135
+ - `field` **([string][3] | [object][4])** checkbox located by label | name | CSS | XPath | strict locator.
1136
+ - `context` **([string][3]? | [object][4])** (optional, `null` by default) element located by CSS | XPath | strict locator.
1137
+
1138
+ Returns **void** automatically synchronized promise through #recorder
1139
+
1140
+ ### wait
1141
+
1142
+ Pauses execution for a number of seconds.
1143
+
1144
+ ```js
1145
+ I.wait(2); // wait 2 secs
1146
+ ```
1147
+
1148
+ #### Parameters
1149
+
1150
+ - `sec` **[number][11]** number of second to wait.
1151
+
1152
+ Returns **void** automatically synchronized promise through #recorder
1153
+
1154
+ ### waitForDetached
1155
+
1156
+ Waits for an element to become not attached to the DOM on a page (by default waits for 1sec).
1157
+ Element can be located by CSS or XPath.
1158
+
1159
+ ```js
1160
+ I.waitForDetached('#popup');
1161
+ ```
1162
+
1163
+ #### Parameters
1164
+
1165
+ - `locator` **([string][3] | [object][4])** element located by CSS|XPath|strict locator.
1166
+ - `sec` **[number][11]** (optional, `1` by default) time in seconds to wait
1167
+
1168
+ Returns **void** automatically synchronized promise through #recorder
1169
+
1170
+ ### waitForElement
1171
+
1172
+ Waits for element to be present on page (by default waits for 1sec).
1173
+ Element can be located by CSS or XPath.
1174
+
1175
+ ```js
1176
+ I.waitForElement('.btn.continue');
1177
+ I.waitForElement('.btn.continue', 5); // wait for 5 secs
1178
+ ```
1179
+
1180
+ #### Parameters
1181
+
1182
+ - `locator` **([string][3] | [object][4])** element located by CSS|XPath|strict locator.
1183
+ - `sec` **[number][11]?** (optional, `1` by default) time in seconds to wait
1184
+
1185
+ Returns **void** automatically synchronized promise through #recorder
1186
+
1187
+ ### waitForFunction
1188
+
1189
+ Waits for a function to return true (waits for 1 sec by default).
1190
+ Running in browser context.
1191
+
1192
+ ```js
1193
+ I.waitForFunction(fn[, [args[, timeout]])
1194
+ ```
1195
+
1196
+ ```js
1197
+ I.waitForFunction(() => window.requests == 0);
1198
+ I.waitForFunction(() => window.requests == 0, 5); // waits for 5 sec
1199
+ I.waitForFunction((count) => window.requests == count, [3], 5) // pass args and wait for 5 sec
1200
+ ```
1201
+
1202
+ #### Parameters
1203
+
1204
+ - `fn` **([string][3] | [function][7])** to be executed in browser context.
1205
+ - `argsOrSec` **([Array][10]&lt;any> | [number][11])?** (optional, `1` by default) arguments for function or seconds.
1206
+ - `sec` **[number][11]?** (optional, `1` by default) time in seconds to wait
1207
+
1208
+ Returns **void** automatically synchronized promise through #recorder
1209
+
1210
+ ### waitForInvisible
1211
+
1212
+ Waits for an element to be removed or become invisible on a page (by default waits for 1sec).
1213
+ Element can be located by CSS or XPath.
1214
+
1215
+ ```js
1216
+ I.waitForInvisible('#popup');
1217
+ ```
1218
+
1219
+ #### Parameters
1220
+
1221
+ - `locator` **([string][3] | [object][4])** element located by CSS|XPath|strict locator.
1222
+ - `sec` **[number][11]** (optional, `1` by default) time in seconds to wait
1223
+
1224
+ Returns **void** automatically synchronized promise through #recorder
1225
+
1226
+ ### waitForText
1227
+
1228
+ Waits for a text to appear (by default waits for 1sec).
1229
+ Element can be located by CSS or XPath.
1230
+ Narrow down search results by providing context.
1231
+
1232
+ ```js
1233
+ I.waitForText('Thank you, form has been submitted');
1234
+ I.waitForText('Thank you, form has been submitted', 5, '#modal');
1235
+ ```
1236
+
1237
+ #### Parameters
1238
+
1239
+ - `text` **[string][3]** to wait for.
1240
+ - `sec` **[number][11]** (optional, `1` by default) time in seconds to wait
1241
+ - `context` **([string][3] | [object][4])?** (optional) element located by CSS|XPath|strict locator.
1242
+
1243
+ Returns **void** automatically synchronized promise through #recorder
1244
+
1245
+ ### waitForVisible
1246
+
1247
+ Waits for an element to become visible on a page (by default waits for 1sec).
1248
+ Element can be located by CSS or XPath.
1249
+
1250
+ ```js
1251
+ I.waitForVisible('#popup');
1252
+ ```
1253
+
1254
+ #### Parameters
1255
+
1256
+ - `locator` **([string][3] | [object][4])** element located by CSS|XPath|strict locator.
1257
+ - `sec` **[number][11]** (optional, `1` by default) time in seconds to wait
1258
+
1259
+ Returns **void** automatically synchronized promise through #recorder
1260
+
1261
+ ### waitToHide
1262
+
1263
+ Waits for an element to hide (by default waits for 1sec).
1264
+ Element can be located by CSS or XPath.
1265
+
1266
+ ```js
1267
+ I.waitToHide('#popup');
1268
+ ```
1269
+
1270
+ #### Parameters
1271
+
1272
+ - `locator` **([string][3] | [object][4])** element located by CSS|XPath|strict locator.
1273
+ - `sec` **[number][11]** (optional, `1` by default) time in seconds to wait
1274
+
1275
+ Returns **void** automatically synchronized promise through #recorder
1276
+
1277
+ [1]: https://github.com/segmentio/nightmare
1278
+
1279
+ [2]: https://github.com/segmentio/nightmare#api
1280
+
1281
+ [3]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
1282
+
1283
+ [4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
1284
+
1285
+ [5]: https://github.com/rosshinkley/nightmare-upload#important-note-about-setting-file-upload-inputs
1286
+
1287
+ [6]: https://vuejs.org/v2/api/#Vue-nextTick
1288
+
1289
+ [7]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function
1290
+
1291
+ [8]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise
1292
+
1293
+ [9]: https://github.com/segmentio/nightmare#evaluatefn-arg1-arg2
1294
+
1295
+ [10]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array
1296
+
1297
+ [11]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
1298
+
1299
+ [12]: http://electron.atom.io/docs/api/web-contents/#webcontentssendinputeventevent
1300
+
1301
+ [13]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
1302
+
1303
+ [14]: https://github.com/segmentio/nightmare/blob/master/Readme.md#cookiessetcookie
1304
+
1305
+ [15]: http://electron.atom.io/docs/api/web-contents/#contentssendinputeventevent