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