codeceptjs 3.4.1 → 3.5.1-2.beta.7

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