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