codeceptjs 3.5.11 → 3.5.12-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (221) hide show
  1. package/README.md +3 -3
  2. package/lib/command/run-multiple.js +3 -1
  3. package/lib/command/run-workers.js +32 -1
  4. package/lib/command/workers/runTests.js +2 -2
  5. package/lib/helper/Playwright.js +21 -2
  6. package/lib/helper/Puppeteer.js +18 -0
  7. package/lib/helper/WebDriver.js +140 -31
  8. package/lib/locator.js +17 -4
  9. package/lib/plugin/retryFailedStep.js +5 -1
  10. package/lib/plugin/retryTo.js +2 -2
  11. package/package.json +14 -11
  12. package/typings/index.d.ts +9 -6
  13. package/typings/promiseBasedTypes.d.ts +84 -1
  14. package/typings/types.d.ts +102 -2
  15. package/docs/advanced.md +0 -351
  16. package/docs/ai.md +0 -248
  17. package/docs/api.md +0 -323
  18. package/docs/basics.md +0 -979
  19. package/docs/bdd.md +0 -539
  20. package/docs/best.md +0 -237
  21. package/docs/books.md +0 -37
  22. package/docs/bootstrap.md +0 -135
  23. package/docs/build/ApiDataFactory.js +0 -410
  24. package/docs/build/Appium.js +0 -2027
  25. package/docs/build/Expect.js +0 -422
  26. package/docs/build/FileSystem.js +0 -228
  27. package/docs/build/GraphQL.js +0 -229
  28. package/docs/build/GraphQLDataFactory.js +0 -309
  29. package/docs/build/JSONResponse.js +0 -338
  30. package/docs/build/Mochawesome.js +0 -71
  31. package/docs/build/Nightmare.js +0 -2152
  32. package/docs/build/OpenAI.js +0 -126
  33. package/docs/build/Playwright.js +0 -5082
  34. package/docs/build/Protractor.js +0 -2706
  35. package/docs/build/Puppeteer.js +0 -3878
  36. package/docs/build/REST.js +0 -344
  37. package/docs/build/TestCafe.js +0 -2125
  38. package/docs/build/WebDriver.js +0 -4122
  39. package/docs/changelog.md +0 -2572
  40. package/docs/commands.md +0 -266
  41. package/docs/community-helpers.md +0 -58
  42. package/docs/configuration.md +0 -157
  43. package/docs/continuous-integration.md +0 -22
  44. package/docs/custom-helpers.md +0 -306
  45. package/docs/data.md +0 -379
  46. package/docs/detox.md +0 -235
  47. package/docs/docker.md +0 -136
  48. package/docs/email.md +0 -183
  49. package/docs/examples.md +0 -149
  50. package/docs/helpers/ApiDataFactory.md +0 -266
  51. package/docs/helpers/Appium.md +0 -1374
  52. package/docs/helpers/Detox.md +0 -586
  53. package/docs/helpers/Expect.md +0 -275
  54. package/docs/helpers/FileSystem.md +0 -152
  55. package/docs/helpers/GraphQL.md +0 -151
  56. package/docs/helpers/GraphQLDataFactory.md +0 -226
  57. package/docs/helpers/JSONResponse.md +0 -254
  58. package/docs/helpers/Mochawesome.md +0 -8
  59. package/docs/helpers/MockRequest.md +0 -377
  60. package/docs/helpers/Nightmare.md +0 -1305
  61. package/docs/helpers/OpenAI.md +0 -70
  62. package/docs/helpers/Playwright.md +0 -2744
  63. package/docs/helpers/Polly.md +0 -44
  64. package/docs/helpers/Protractor.md +0 -1769
  65. package/docs/helpers/Puppeteer-firefox.md +0 -86
  66. package/docs/helpers/Puppeteer.md +0 -2302
  67. package/docs/helpers/REST.md +0 -218
  68. package/docs/helpers/TestCafe.md +0 -1321
  69. package/docs/helpers/WebDriver.md +0 -2473
  70. package/docs/hooks.md +0 -340
  71. package/docs/index.md +0 -111
  72. package/docs/installation.md +0 -75
  73. package/docs/internal-api.md +0 -266
  74. package/docs/locators.md +0 -331
  75. package/docs/mobile-react-native-locators.md +0 -67
  76. package/docs/mobile.md +0 -338
  77. package/docs/pageobjects.md +0 -291
  78. package/docs/parallel.md +0 -400
  79. package/docs/playwright.md +0 -632
  80. package/docs/plugins.md +0 -1259
  81. package/docs/puppeteer.md +0 -316
  82. package/docs/quickstart.md +0 -162
  83. package/docs/react.md +0 -70
  84. package/docs/reports.md +0 -392
  85. package/docs/secrets.md +0 -36
  86. package/docs/shadow.md +0 -68
  87. package/docs/shared/keys.mustache +0 -31
  88. package/docs/shared/react.mustache +0 -1
  89. package/docs/testcafe.md +0 -174
  90. package/docs/translation.md +0 -247
  91. package/docs/tutorial.md +0 -271
  92. package/docs/typescript.md +0 -180
  93. package/docs/ui.md +0 -59
  94. package/docs/videos.md +0 -28
  95. package/docs/visual.md +0 -202
  96. package/docs/vue.md +0 -143
  97. package/docs/webapi/amOnPage.mustache +0 -11
  98. package/docs/webapi/appendField.mustache +0 -11
  99. package/docs/webapi/attachFile.mustache +0 -12
  100. package/docs/webapi/blur.mustache +0 -18
  101. package/docs/webapi/checkOption.mustache +0 -13
  102. package/docs/webapi/clearCookie.mustache +0 -9
  103. package/docs/webapi/clearField.mustache +0 -9
  104. package/docs/webapi/click.mustache +0 -25
  105. package/docs/webapi/clickLink.mustache +0 -8
  106. package/docs/webapi/closeCurrentTab.mustache +0 -7
  107. package/docs/webapi/closeOtherTabs.mustache +0 -8
  108. package/docs/webapi/dontSee.mustache +0 -11
  109. package/docs/webapi/dontSeeCheckboxIsChecked.mustache +0 -10
  110. package/docs/webapi/dontSeeCookie.mustache +0 -8
  111. package/docs/webapi/dontSeeCurrentUrlEquals.mustache +0 -10
  112. package/docs/webapi/dontSeeElement.mustache +0 -8
  113. package/docs/webapi/dontSeeElementInDOM.mustache +0 -8
  114. package/docs/webapi/dontSeeInCurrentUrl.mustache +0 -4
  115. package/docs/webapi/dontSeeInField.mustache +0 -11
  116. package/docs/webapi/dontSeeInSource.mustache +0 -8
  117. package/docs/webapi/dontSeeInTitle.mustache +0 -8
  118. package/docs/webapi/doubleClick.mustache +0 -13
  119. package/docs/webapi/downloadFile.mustache +0 -12
  120. package/docs/webapi/dragAndDrop.mustache +0 -9
  121. package/docs/webapi/dragSlider.mustache +0 -11
  122. package/docs/webapi/executeAsyncScript.mustache +0 -24
  123. package/docs/webapi/executeScript.mustache +0 -26
  124. package/docs/webapi/fillField.mustache +0 -16
  125. package/docs/webapi/focus.mustache +0 -13
  126. package/docs/webapi/forceClick.mustache +0 -28
  127. package/docs/webapi/forceRightClick.mustache +0 -18
  128. package/docs/webapi/grabAllWindowHandles.mustache +0 -7
  129. package/docs/webapi/grabAttributeFrom.mustache +0 -10
  130. package/docs/webapi/grabAttributeFromAll.mustache +0 -9
  131. package/docs/webapi/grabBrowserLogs.mustache +0 -9
  132. package/docs/webapi/grabCookie.mustache +0 -11
  133. package/docs/webapi/grabCssPropertyFrom.mustache +0 -11
  134. package/docs/webapi/grabCssPropertyFromAll.mustache +0 -10
  135. package/docs/webapi/grabCurrentUrl.mustache +0 -9
  136. package/docs/webapi/grabCurrentWindowHandle.mustache +0 -6
  137. package/docs/webapi/grabDataFromPerformanceTiming.mustache +0 -20
  138. package/docs/webapi/grabElementBoundingRect.mustache +0 -20
  139. package/docs/webapi/grabGeoLocation.mustache +0 -8
  140. package/docs/webapi/grabHTMLFrom.mustache +0 -10
  141. package/docs/webapi/grabHTMLFromAll.mustache +0 -9
  142. package/docs/webapi/grabNumberOfOpenTabs.mustache +0 -8
  143. package/docs/webapi/grabNumberOfVisibleElements.mustache +0 -9
  144. package/docs/webapi/grabPageScrollPosition.mustache +0 -8
  145. package/docs/webapi/grabPopupText.mustache +0 -5
  146. package/docs/webapi/grabSource.mustache +0 -8
  147. package/docs/webapi/grabTextFrom.mustache +0 -10
  148. package/docs/webapi/grabTextFromAll.mustache +0 -9
  149. package/docs/webapi/grabTitle.mustache +0 -8
  150. package/docs/webapi/grabValueFrom.mustache +0 -9
  151. package/docs/webapi/grabValueFromAll.mustache +0 -8
  152. package/docs/webapi/grabWebElement.mustache +0 -9
  153. package/docs/webapi/grabWebElements.mustache +0 -9
  154. package/docs/webapi/moveCursorTo.mustache +0 -12
  155. package/docs/webapi/openNewTab.mustache +0 -7
  156. package/docs/webapi/pressKey.mustache +0 -12
  157. package/docs/webapi/pressKeyDown.mustache +0 -12
  158. package/docs/webapi/pressKeyUp.mustache +0 -12
  159. package/docs/webapi/pressKeyWithKeyNormalization.mustache +0 -60
  160. package/docs/webapi/refreshPage.mustache +0 -6
  161. package/docs/webapi/resizeWindow.mustache +0 -6
  162. package/docs/webapi/rightClick.mustache +0 -14
  163. package/docs/webapi/saveElementScreenshot.mustache +0 -10
  164. package/docs/webapi/saveScreenshot.mustache +0 -12
  165. package/docs/webapi/say.mustache +0 -10
  166. package/docs/webapi/scrollIntoView.mustache +0 -11
  167. package/docs/webapi/scrollPageToBottom.mustache +0 -6
  168. package/docs/webapi/scrollPageToTop.mustache +0 -6
  169. package/docs/webapi/scrollTo.mustache +0 -12
  170. package/docs/webapi/see.mustache +0 -11
  171. package/docs/webapi/seeAttributesOnElements.mustache +0 -9
  172. package/docs/webapi/seeCheckboxIsChecked.mustache +0 -10
  173. package/docs/webapi/seeCookie.mustache +0 -8
  174. package/docs/webapi/seeCssPropertiesOnElements.mustache +0 -9
  175. package/docs/webapi/seeCurrentUrlEquals.mustache +0 -11
  176. package/docs/webapi/seeElement.mustache +0 -8
  177. package/docs/webapi/seeElementInDOM.mustache +0 -8
  178. package/docs/webapi/seeInCurrentUrl.mustache +0 -8
  179. package/docs/webapi/seeInField.mustache +0 -12
  180. package/docs/webapi/seeInPopup.mustache +0 -8
  181. package/docs/webapi/seeInSource.mustache +0 -7
  182. package/docs/webapi/seeInTitle.mustache +0 -8
  183. package/docs/webapi/seeNumberOfElements.mustache +0 -11
  184. package/docs/webapi/seeNumberOfVisibleElements.mustache +0 -10
  185. package/docs/webapi/seeTextEquals.mustache +0 -9
  186. package/docs/webapi/seeTitleEquals.mustache +0 -8
  187. package/docs/webapi/selectOption.mustache +0 -21
  188. package/docs/webapi/setCookie.mustache +0 -16
  189. package/docs/webapi/setGeoLocation.mustache +0 -12
  190. package/docs/webapi/switchTo.mustache +0 -9
  191. package/docs/webapi/switchToNextTab.mustache +0 -10
  192. package/docs/webapi/switchToPreviousTab.mustache +0 -10
  193. package/docs/webapi/type.mustache +0 -21
  194. package/docs/webapi/uncheckOption.mustache +0 -13
  195. package/docs/webapi/wait.mustache +0 -8
  196. package/docs/webapi/waitForClickable.mustache +0 -11
  197. package/docs/webapi/waitForDetached.mustache +0 -10
  198. package/docs/webapi/waitForElement.mustache +0 -11
  199. package/docs/webapi/waitForEnabled.mustache +0 -6
  200. package/docs/webapi/waitForFunction.mustache +0 -17
  201. package/docs/webapi/waitForInvisible.mustache +0 -10
  202. package/docs/webapi/waitForText.mustache +0 -13
  203. package/docs/webapi/waitForValue.mustache +0 -10
  204. package/docs/webapi/waitForVisible.mustache +0 -10
  205. package/docs/webapi/waitInUrl.mustache +0 -9
  206. package/docs/webapi/waitNumberOfVisibleElements.mustache +0 -10
  207. package/docs/webapi/waitToHide.mustache +0 -10
  208. package/docs/webapi/waitUrlEquals.mustache +0 -10
  209. package/docs/webdriver.md +0 -655
  210. package/docs/wiki/Books-&-Posts.md +0 -27
  211. package/docs/wiki/Community-Helpers-&-Plugins.md +0 -53
  212. package/docs/wiki/Converting-Playwright-to-Istanbul-Coverage.md +0 -61
  213. package/docs/wiki/Examples.md +0 -145
  214. package/docs/wiki/Google-Summer-of-Code-(GSoC)-2020.md +0 -68
  215. package/docs/wiki/Home.md +0 -16
  216. package/docs/wiki/Migration-to-Appium-v2---CodeceptJS.md +0 -83
  217. package/docs/wiki/Release-Process.md +0 -24
  218. package/docs/wiki/Roadmap.md +0 -23
  219. package/docs/wiki/Tests.md +0 -1393
  220. package/docs/wiki/Upgrading-to-CodeceptJS-3.md +0 -153
  221. package/docs/wiki/Videos.md +0 -19
@@ -1,2473 +0,0 @@
1
- ---
2
- permalink: /helpers/WebDriver
3
- editLink: false
4
- sidebar: auto
5
- title: WebDriver
6
- ---
7
-
8
- <!-- Generated by documentation.js. Update this documentation by updating the source code. -->
9
-
10
- ## WebDriver
11
-
12
- **Extends Helper**
13
-
14
- WebDriver helper which wraps [webdriverio][1] library to
15
- manipulate browser using Selenium WebDriver or PhantomJS.
16
-
17
- WebDriver requires Selenium Server and ChromeDriver/GeckoDriver to be installed. Those tools can be easily installed via NPM. Please check [Testing with WebDriver][2] for more details.
18
-
19
-
20
-
21
- ## Configuration
22
-
23
- This helper should be configured in codecept.conf.js
24
-
25
- Type: [object][16]
26
-
27
- ### Properties
28
-
29
- - `url` **[string][17]** base url of website to be tested.
30
- - `browser` **[string][17]** Browser in which to perform testing.
31
- - `basicAuth` **[string][17]?** (optional) the basic authentication to pass to base url. Example: {username: 'username', password: 'password'}
32
- - `host` **[string][17]?** WebDriver host to connect.
33
- - `port` **[number][22]?** WebDriver port to connect.
34
- - `protocol` **[string][17]?** protocol for WebDriver server.
35
- - `path` **[string][17]?** path to WebDriver server.
36
- - `restart` **[boolean][32]?** restart browser between tests.
37
- - `smartWait` **([boolean][32] | [number][22])?** **enables [SmartWait][36]**; wait for additional milliseconds for element to appear. Enable for 5 secs: "smartWait": 5000.
38
- - `disableScreenshots` **[boolean][32]?** don't save screenshots on failure.
39
- - `fullPageScreenshots` **[boolean][32]?** (optional - make full page screenshots on failure.
40
- - `uniqueScreenshotNames` **[boolean][32]?** option to prevent screenshot override if you have scenarios with the same name in different suites.
41
- - `keepBrowserState` **[boolean][32]?** keep browser state between tests when `restart` is set to false.
42
- - `keepCookies` **[boolean][32]?** keep cookies between tests when `restart` set to false.
43
- - `windowSize` **[string][17]?** default window size. Set to `maximize` or a dimension in the format `640x480`.
44
- - `waitForTimeout` **[number][22]?** sets default wait time in _ms_ for all `wait*` functions.
45
- - `desiredCapabilities` **[object][16]?** Selenium's [desired capabilities][6].
46
- - `manualStart` **[boolean][32]?** do not start browser before a test, start it manually inside a helper with `this.helpers["WebDriver"]._startBrowser()`.
47
- - `timeouts` **[object][16]?** [WebDriver timeouts][37] defined as hash.
48
- - `highlightElement` **[boolean][32]?** highlight the interacting elements. Default: false. Note: only activate under verbose mode (--verbose).
49
-
50
-
51
-
52
- Example:
53
-
54
- ```js
55
- {
56
- helpers: {
57
- WebDriver : {
58
- smartWait: 5000,
59
- browser: "chrome",
60
- restart: false,
61
- windowSize: "maximize",
62
- timeouts: {
63
- "script": 60000,
64
- "page load": 10000
65
- }
66
- }
67
- }
68
- }
69
- ```
70
-
71
- Example with basic authentication
72
-
73
- ```js
74
- {
75
- helpers: {
76
- WebDriver : {
77
- smartWait: 5000,
78
- browser: "chrome",
79
- basicAuth: {username: 'username', password: 'password'},
80
- restart: false,
81
- windowSize: "maximize",
82
- timeouts: {
83
- "script": 60000,
84
- "page load": 10000
85
- }
86
- }
87
- }
88
- }
89
- ```
90
-
91
- Additional configuration params can be used from [webdriverio
92
- website][3].
93
-
94
- ### Headless Chrome
95
-
96
- ```js
97
- {
98
- helpers: {
99
- WebDriver : {
100
- url: "http://localhost",
101
- browser: "chrome",
102
- desiredCapabilities: {
103
- chromeOptions: {
104
- args: [ "--headless", "--disable-gpu", "--no-sandbox" ]
105
- }
106
- }
107
- }
108
- }
109
- }
110
- ```
111
-
112
- ### Internet Explorer
113
-
114
- Additional configuration params can be used from [IE options][4]
115
-
116
- ```js
117
- {
118
- helpers: {
119
- WebDriver : {
120
- url: "http://localhost",
121
- browser: "internet explorer",
122
- desiredCapabilities: {
123
- ieOptions: {
124
- "ie.browserCommandLineSwitches": "-private",
125
- "ie.usePerProcessProxy": true,
126
- "ie.ensureCleanSession": true,
127
- }
128
- }
129
- }
130
- }
131
- }
132
- ```
133
-
134
- ### Selenoid Options
135
-
136
- [Selenoid][5] is a modern way to run Selenium inside Docker containers.
137
- Selenoid is easy to set up and provides more features than original Selenium Server. Use `selenoidOptions` to set Selenoid capabilities
138
-
139
- ```js
140
- {
141
- helpers: {
142
- WebDriver : {
143
- url: "http://localhost",
144
- browser: "chrome",
145
- desiredCapabilities: {
146
- selenoidOptions: {
147
- enableVNC: true,
148
- }
149
- }
150
- }
151
- }
152
- }
153
- ```
154
-
155
- ### Connect Through proxy
156
-
157
- CodeceptJS also provides flexible options when you want to execute tests to Selenium servers through proxy. You will
158
- need to update the `helpers.WebDriver.capabilities.proxy` key.
159
-
160
- ```js
161
- {
162
- helpers: {
163
- WebDriver: {
164
- capabilities: {
165
- proxy: {
166
- "proxyType": "manual|pac",
167
- "proxyAutoconfigUrl": "URL TO PAC FILE",
168
- "httpProxy": "PROXY SERVER",
169
- "sslProxy": "PROXY SERVER",
170
- "ftpProxy": "PROXY SERVER",
171
- "socksProxy": "PROXY SERVER",
172
- "socksUsername": "USERNAME",
173
- "socksPassword": "PASSWORD",
174
- "noProxy": "BYPASS ADDRESSES"
175
- }
176
- }
177
- }
178
- }
179
- }
180
- ```
181
-
182
- For example,
183
-
184
- ```js
185
- {
186
- helpers: {
187
- WebDriver: {
188
- capabilities: {
189
- proxy: {
190
- "proxyType": "manual",
191
- "httpProxy": "http://corporate.proxy:8080",
192
- "socksUsername": "codeceptjs",
193
- "socksPassword": "secret",
194
- "noProxy": "127.0.0.1,localhost"
195
- }
196
- }
197
- }
198
- }
199
- }
200
- ```
201
-
202
- Please refer to [Selenium - Proxy Object][6] for more
203
- information.
204
-
205
- ### Cloud Providers
206
-
207
- WebDriver makes it possible to execute tests against services like `Sauce Labs` `BrowserStack` `TestingBot`
208
- Check out their documentation on [available parameters][7]
209
-
210
- Connecting to `BrowserStack` and `Sauce Labs` is simple. All you need to do
211
- is set the `user` and `key` parameters. WebDriver automatically know which
212
- service provider to connect to.
213
-
214
- ```js
215
- {
216
- helpers:{
217
- WebDriver: {
218
- url: "YOUR_DESIRED_HOST",
219
- user: "YOUR_BROWSERSTACK_USER",
220
- key: "YOUR_BROWSERSTACK_KEY",
221
- capabilities: {
222
- "browserName": "chrome",
223
-
224
- // only set this if you're using BrowserStackLocal to test a local domain
225
- // "browserstack.local": true,
226
-
227
- // set this option to tell browserstack to provide addition debugging info
228
- // "browserstack.debug": true,
229
- }
230
- }
231
- }
232
- }
233
- ```
234
-
235
- #### SauceLabs
236
-
237
- SauceLabs can be configured via wdio service, which should be installed additionally:
238
-
239
- npm i @wdio/sauce-service --save
240
-
241
- It is important to make sure it is compatible with current webdriverio version.
242
-
243
- Enable `wdio` plugin in plugins list and add `sauce` service:
244
-
245
- ```js
246
- plugins: {
247
- wdio: {
248
- enabled: true,
249
- services: ['sauce'],
250
- user: ... ,// saucelabs username
251
- key: ... // saucelabs api key
252
- // additional config, from sauce service
253
- }
254
- }
255
- ```
256
-
257
- See [complete reference on webdriver.io][8].
258
-
259
- > Alternatively, use [codeceptjs-saucehelper][9] for better reporting.
260
-
261
- #### BrowserStack
262
-
263
- BrowserStack can be configured via wdio service, which should be installed additionally:
264
-
265
- npm i @wdio/browserstack-service --save
266
-
267
- It is important to make sure it is compatible with current webdriverio version.
268
-
269
- Enable `wdio` plugin in plugins list and add `browserstack` service:
270
-
271
- ```js
272
- plugins: {
273
- wdio: {
274
- enabled: true,
275
- services: ['browserstack'],
276
- user: ... ,// browserstack username
277
- key: ... // browserstack api key
278
- // additional config, from browserstack service
279
- }
280
- }
281
- ```
282
-
283
- See [complete reference on webdriver.io][10].
284
-
285
- > Alternatively, use [codeceptjs-bshelper][11] for better reporting.
286
-
287
- #### TestingBot
288
-
289
- > **Recommended**: use official [TestingBot Helper][12].
290
-
291
- Alternatively, TestingBot can be configured via wdio service, which should be installed additionally:
292
-
293
- npm i @wdio/testingbot-service --save
294
-
295
- It is important to make sure it is compatible with current webdriverio version.
296
-
297
- Enable `wdio` plugin in plugins list and add `testingbot` service:
298
-
299
- ```js
300
- plugins: {
301
- wdio: {
302
- enabled: true,
303
- services: ['testingbot'],
304
- user: ... ,// testingbot key
305
- key: ... // testingbot secret
306
- // additional config, from testingbot service
307
- }
308
- }
309
- ```
310
-
311
- See [complete reference on webdriver.io][13].
312
-
313
- #### Applitools
314
-
315
- Visual testing via Applitools service
316
-
317
- > Use [CodeceptJS Applitools Helper][14] with Applitools wdio service.
318
-
319
- ### Multiremote Capabilities
320
-
321
- This is a work in progress but you can control two browsers at a time right out of the box.
322
- Individual control is something that is planned for a later version.
323
-
324
- Here is the [webdriverio docs][15] on the subject
325
-
326
- ```js
327
- {
328
- helpers: {
329
- WebDriver: {
330
- "multiremote": {
331
- "MyChrome": {
332
- "desiredCapabilities": {
333
- "browserName": "chrome"
334
- }
335
- },
336
- "MyFirefox": {
337
- "desiredCapabilities": {
338
- "browserName": "firefox"
339
- }
340
- }
341
- }
342
- }
343
- }
344
- }
345
- ```
346
-
347
- ## Access From Helpers
348
-
349
- Receive a WebDriver client from a custom helper by accessing `browser` property:
350
-
351
- ```js
352
- const { WebDriver } = this.helpers;
353
- const browser = WebDriver.browser
354
- ```
355
-
356
- ## Methods
357
-
358
- ### Parameters
359
-
360
- - `config`
361
-
362
- ### _isShadowLocator
363
-
364
- Check if locator is type of "Shadow"
365
-
366
- #### Parameters
367
-
368
- - `locator` **[object][16]**
369
-
370
- ### _locate
371
-
372
- Get elements by different locator types, including strict locator.
373
- Should be used in custom helpers:
374
-
375
- ```js
376
- this.helpers['WebDriver']._locate({name: 'password'}).then //...
377
- ```
378
-
379
- #### Parameters
380
-
381
- - `locator` **([string][17] | [object][16])** element located by CSS|XPath|strict locator.
382
- - `smartWait`
383
-
384
- ### _locateCheckable
385
-
386
- Find a checkbox by providing human-readable text:
387
-
388
- ```js
389
- this.helpers['WebDriver']._locateCheckable('I agree with terms and conditions').then // ...
390
- ```
391
-
392
- #### Parameters
393
-
394
- - `locator` **([string][17] | [object][16])** element located by CSS|XPath|strict locator.
395
-
396
- ### _locateClickable
397
-
398
- Find a clickable element by providing human-readable text:
399
-
400
- ```js
401
- const els = await this.helpers.WebDriver._locateClickable('Next page');
402
- const els = await this.helpers.WebDriver._locateClickable('Next page', '.pages');
403
- ```
404
-
405
- #### Parameters
406
-
407
- - `locator` **([string][17] | [object][16])** element located by CSS|XPath|strict locator.
408
- - `context`
409
-
410
- ### _locateFields
411
-
412
- Find field elements by providing human-readable text:
413
-
414
- ```js
415
- this.helpers['WebDriver']._locateFields('Your email').then // ...
416
- ```
417
-
418
- #### Parameters
419
-
420
- - `locator` **([string][17] | [object][16])** element located by CSS|XPath|strict locator.
421
-
422
- ### _locateShadow
423
-
424
- Locate Element within the Shadow Dom
425
-
426
- #### Parameters
427
-
428
- - `locator` **[object][16]**
429
-
430
- ### _smartWait
431
-
432
- Smart Wait to locate an element
433
-
434
- #### Parameters
435
-
436
- - `locator` **[object][16]**
437
-
438
- ### acceptPopup
439
-
440
- Accepts the active JavaScript native popup window, as created by window.alert|window.confirm|window.prompt.
441
- Don't confuse popups with modal windows, as created by [various
442
- libraries][18].
443
-
444
- ### amOnPage
445
-
446
- Opens a web page in a browser. Requires relative or absolute url.
447
- If url starts with `/`, opens a web page of a site defined in `url` config parameter.
448
-
449
- ```js
450
- I.amOnPage('/'); // opens main page of website
451
- I.amOnPage('https://github.com'); // opens github
452
- I.amOnPage('/login'); // opens a login page
453
- ```
454
-
455
- #### Parameters
456
-
457
- - `url` **[string][17]** url path or global url.
458
-
459
- Returns **void** automatically synchronized promise through #recorder
460
-
461
- ### appendField
462
-
463
- Appends text to a input field or textarea.
464
- Field is located by name, label, CSS or XPath
465
-
466
- ```js
467
- I.appendField('#myTextField', 'appended');
468
- // typing secret
469
- I.appendField('password', secret('123456'));
470
- ```
471
-
472
- #### Parameters
473
-
474
- - `field` **([string][17] | [object][16])** located by label|name|CSS|XPath|strict locator
475
- - `value` **[string][17]** text value to append.
476
-
477
- Returns **void** automatically synchronized promise through #recorder
478
-
479
-
480
- This action supports [React locators](https://codecept.io/react#locators)
481
-
482
-
483
- ### attachFile
484
-
485
- Appium: not tested
486
-
487
- Attaches a file to element located by label, name, CSS or XPath
488
- Path to file is relative current codecept directory (where codecept.conf.ts or codecept.conf.js is located).
489
- File will be uploaded to remote system (if tests are running remotely).
490
-
491
- ```js
492
- I.attachFile('Avatar', 'data/avatar.jpg');
493
- I.attachFile('form input[name=avatar]', 'data/avatar.jpg');
494
- ```
495
-
496
- #### Parameters
497
-
498
- - `locator` **([string][17] | [object][16])** field located by label|name|CSS|XPath|strict locator.
499
- - `pathToFile` **[string][17]** local file path relative to codecept.conf.ts or codecept.conf.js config file.
500
-
501
- Returns **void** automatically synchronized promise through #recorder
502
-
503
- ### blur
504
-
505
- Remove focus from a text input, button, etc.
506
- Calls [blur][19] on the element.
507
-
508
- Examples:
509
-
510
- ```js
511
- I.blur('.text-area')
512
- ```
513
-
514
- ```js
515
- //element `#product-tile` is focused
516
- I.see('#add-to-cart-btn');
517
- I.blur('#product-tile')
518
- I.dontSee('#add-to-cart-btn');
519
- ```
520
-
521
- #### Parameters
522
-
523
- - `locator` **([string][17] | [object][16])** field located by label|name|CSS|XPath|strict locator.
524
- - `options` **any?** Playwright only: [Additional options][20] for available options object as 2nd argument.
525
-
526
- Returns **void** automatically synchronized promise through #recorder
527
-
528
- ### cancelPopup
529
-
530
- Dismisses the active JavaScript popup, as created by `window.alert|window.confirm|window.prompt`.
531
-
532
- ### checkOption
533
-
534
- Appium: not tested
535
- Selects a checkbox or radio button.
536
- Element is located by label or name or CSS or XPath.
537
-
538
- The second parameter is a context (CSS or XPath locator) to narrow the search.
539
-
540
- ```js
541
- I.checkOption('#agree');
542
- I.checkOption('I Agree to Terms and Conditions');
543
- I.checkOption('agree', '//form');
544
- ```
545
-
546
- #### Parameters
547
-
548
- - `field` **([string][17] | [object][16])** checkbox located by label | name | CSS | XPath | strict locator.
549
- - `context` **([string][17]? | [object][16])** (optional, `null` by default) element located by CSS | XPath | strict locator.
550
-
551
- Returns **void** automatically synchronized promise through #recorder
552
-
553
- ### clearCookie
554
-
555
- Clears a cookie by name,
556
- if none provided clears all cookies.
557
-
558
- ```js
559
- I.clearCookie();
560
- I.clearCookie('test'); // Playwright currently doesn't support clear a particular cookie name
561
- ```
562
-
563
- #### Parameters
564
-
565
- - `cookie` **[string][17]?** (optional, `null` by default) cookie name
566
-
567
- ### clearField
568
-
569
- Clears a `<textarea>` or text `<input>` element's value.
570
-
571
- ```js
572
- I.clearField('Email');
573
- I.clearField('user[email]');
574
- I.clearField('#email');
575
- ```
576
-
577
- #### Parameters
578
-
579
- - `field`
580
- - `editable` **([string][17] | [object][16])** field located by label|name|CSS|XPath|strict locator.
581
-
582
- Returns **void** automatically synchronized promise through #recorder.
583
-
584
- ### click
585
-
586
- Perform a click on a link or a button, given by a locator.
587
- If a fuzzy locator is given, the page will be searched for a button, link, or image matching the locator string.
588
- For buttons, the "value" attribute, "name" attribute, and inner text are searched. For links, the link text is searched.
589
- For images, the "alt" attribute and inner text of any parent links are searched.
590
-
591
- The second parameter is a context (CSS or XPath locator) to narrow the search.
592
-
593
- ```js
594
- // simple link
595
- I.click('Logout');
596
- // button of form
597
- I.click('Submit');
598
- // CSS button
599
- I.click('#form input[type=submit]');
600
- // XPath
601
- I.click('//form/*[@type=submit]');
602
- // link in context
603
- I.click('Logout', '#nav');
604
- // using strict locator
605
- I.click({css: 'nav a.login'});
606
- ```
607
-
608
- #### Parameters
609
-
610
- - `locator` **([string][17] | [object][16])** clickable link or button located by text, or any element located by CSS|XPath|strict locator.
611
- - `context` **([string][17]? | [object][16] | null)** (optional, `null` by default) element to search in CSS|XPath|Strict locator.
612
-
613
- Returns **void** automatically synchronized promise through #recorder
614
-
615
-
616
- This action supports [React locators](https://codecept.io/react#locators)
617
-
618
-
619
- ### closeCurrentTab
620
-
621
- Close current tab.
622
-
623
- ```js
624
- I.closeCurrentTab();
625
- ```
626
-
627
- Returns **void** automatically synchronized promise through #recorder
628
-
629
- ### closeOtherTabs
630
-
631
- Close all tabs except for the current one.
632
-
633
- ```js
634
- I.closeOtherTabs();
635
- ```
636
-
637
- Returns **void** automatically synchronized promise through #recorder
638
-
639
- ### defineTimeout
640
-
641
- Set [WebDriver timeouts][21] in realtime.
642
-
643
- Timeouts are expected to be passed as object:
644
-
645
- ```js
646
- I.defineTimeout({ script: 5000 });
647
- I.defineTimeout({ implicit: 10000, pageLoad: 10000, script: 5000 });
648
- ```
649
-
650
- #### Parameters
651
-
652
- - `timeouts` **any** WebDriver timeouts object.
653
-
654
- ### dontSee
655
-
656
- Opposite to `see`. Checks that a text is not present on a page.
657
- Use context parameter to narrow down the search.
658
-
659
- ```js
660
- I.dontSee('Login'); // assume we are already logged in.
661
- I.dontSee('Login', '.nav'); // no login inside .nav element
662
- ```
663
-
664
- #### Parameters
665
-
666
- - `text` **[string][17]** which is not present.
667
- - `context` **([string][17] | [object][16])?** (optional) element located by CSS|XPath|strict locator in which to perfrom search.
668
-
669
- Returns **void** automatically synchronized promise through #recorder
670
-
671
-
672
- This action supports [React locators](https://codecept.io/react#locators)
673
-
674
-
675
- ### dontSeeCheckboxIsChecked
676
-
677
- Appium: not tested
678
- Verifies that the specified checkbox is not checked.
679
-
680
- ```js
681
- I.dontSeeCheckboxIsChecked('#agree'); // located by ID
682
- I.dontSeeCheckboxIsChecked('I agree to terms'); // located by label
683
- I.dontSeeCheckboxIsChecked('agree'); // located by name
684
- ```
685
-
686
- #### Parameters
687
-
688
- - `field` **([string][17] | [object][16])** located by label|name|CSS|XPath|strict locator.
689
-
690
- Returns **void** automatically synchronized promise through #recorder
691
-
692
- ### dontSeeCookie
693
-
694
- Checks that cookie with given name does not exist.
695
-
696
- ```js
697
- I.dontSeeCookie('auth'); // no auth cookie
698
- ```
699
-
700
- #### Parameters
701
-
702
- - `name` **[string][17]** cookie name.
703
-
704
- Returns **void** automatically synchronized promise through #recorder
705
-
706
- ### dontSeeCurrentUrlEquals
707
-
708
- Checks that current url is not equal to provided one.
709
- If a relative url provided, a configured url will be prepended to it.
710
-
711
- ```js
712
- I.dontSeeCurrentUrlEquals('/login'); // relative url are ok
713
- I.dontSeeCurrentUrlEquals('http://mysite.com/login'); // absolute urls are also ok
714
- ```
715
-
716
- #### Parameters
717
-
718
- - `url` **[string][17]** value to check.
719
-
720
- Returns **void** automatically synchronized promise through #recorder
721
-
722
- ### dontSeeElement
723
-
724
- Opposite to `seeElement`. Checks that element is not visible (or in DOM)
725
-
726
- ```js
727
- I.dontSeeElement('.modal'); // modal is not shown
728
- ```
729
-
730
- #### Parameters
731
-
732
- - `locator` **([string][17] | [object][16])** located by CSS|XPath|Strict locator.
733
-
734
- Returns **void** automatically synchronized promise through #recorder
735
-
736
-
737
- This action supports [React locators](https://codecept.io/react#locators)
738
-
739
-
740
- ### dontSeeElementInDOM
741
-
742
- Opposite to `seeElementInDOM`. Checks that element is not on page.
743
-
744
- ```js
745
- I.dontSeeElementInDOM('.nav'); // checks that element is not on page visible or not
746
- ```
747
-
748
- #### Parameters
749
-
750
- - `locator` **([string][17] | [object][16])** located by CSS|XPath|Strict locator.
751
-
752
- Returns **void** automatically synchronized promise through #recorder
753
-
754
- ### dontSeeInCurrentUrl
755
-
756
- Checks that current url does not contain a provided fragment.
757
-
758
- #### Parameters
759
-
760
- - `url` **[string][17]** value to check.
761
-
762
- Returns **void** automatically synchronized promise through #recorder
763
-
764
- ### dontSeeInField
765
-
766
- Checks that value of input field or textarea doesn't equal to given value
767
- Opposite to `seeInField`.
768
-
769
- ```js
770
- I.dontSeeInField('email', 'user@user.com'); // field by name
771
- I.dontSeeInField({ css: 'form input.email' }, 'user@user.com'); // field by CSS
772
- ```
773
-
774
- #### Parameters
775
-
776
- - `field` **([string][17] | [object][16])** located by label|name|CSS|XPath|strict locator.
777
- - `value` **([string][17] | [object][16])** value to check.
778
-
779
- Returns **void** automatically synchronized promise through #recorder
780
-
781
- ### dontSeeInSource
782
-
783
- Checks that the current page does not contains the given string in its raw source code.
784
-
785
- ```js
786
- I.dontSeeInSource('<!--'); // no comments in source
787
- ```
788
-
789
- #### Parameters
790
-
791
- - `text`
792
- - `value` **[string][17]** to check.
793
-
794
- Returns **void** automatically synchronized promise through #recorder
795
-
796
- ### dontSeeInTitle
797
-
798
- Checks that title does not contain text.
799
-
800
- ```js
801
- I.dontSeeInTitle('Error');
802
- ```
803
-
804
- #### Parameters
805
-
806
- - `text` **[string][17]** value to check.
807
-
808
- Returns **void** automatically synchronized promise through #recorder
809
-
810
- ### doubleClick
811
-
812
- Performs a double-click on an element matched by link|button|label|CSS or XPath.
813
- Context can be specified as second parameter to narrow search.
814
-
815
- ```js
816
- I.doubleClick('Edit');
817
- I.doubleClick('Edit', '.actions');
818
- I.doubleClick({css: 'button.accept'});
819
- I.doubleClick('.btn.edit');
820
- ```
821
-
822
- #### Parameters
823
-
824
- - `locator` **([string][17] | [object][16])** clickable link or button located by text, or any element located by CSS|XPath|strict locator.
825
- - `context` **([string][17]? | [object][16])** (optional, `null` by default) element to search in CSS|XPath|Strict locator.
826
-
827
- Returns **void** automatically synchronized promise through #recorder
828
-
829
-
830
- This action supports [React locators](https://codecept.io/react#locators)
831
-
832
-
833
- ### dragAndDrop
834
-
835
- Appium: not tested
836
- Drag an item to a destination element.
837
-
838
- ```js
839
- I.dragAndDrop('#dragHandle', '#container');
840
- ```
841
-
842
- #### Parameters
843
-
844
- - `srcElement` **([string][17] | [object][16])** located by CSS|XPath|strict locator.
845
- - `destElement` **([string][17] | [object][16])** located by CSS|XPath|strict locator.
846
-
847
- Returns **void** automatically synchronized promise through #recorder
848
-
849
- ### dragSlider
850
-
851
- Drag the scrubber of a slider to a given position
852
- For fuzzy locators, fields are matched by label text, the "name" attribute, CSS, and XPath.
853
-
854
- ```js
855
- I.dragSlider('#slider', 30);
856
- I.dragSlider('#slider', -70);
857
- ```
858
-
859
- #### Parameters
860
-
861
- - `locator` **([string][17] | [object][16])** located by label|name|CSS|XPath|strict locator.
862
- - `offsetX` **[number][22]** position to drag.
863
-
864
- Returns **void** automatically synchronized promise through #recorder
865
-
866
- ### executeAsyncScript
867
-
868
- Executes async script on page.
869
- Provided function should execute a passed callback (as first argument) to signal it is finished.
870
-
871
- Example: In Vue.js to make components completely rendered we are waiting for [nextTick][23].
872
-
873
- ```js
874
- I.executeAsyncScript(function(done) {
875
- Vue.nextTick(done); // waiting for next tick
876
- });
877
- ```
878
-
879
- By passing value to `done()` function you can return values.
880
- Additional arguments can be passed as well, while `done` function is always last parameter in arguments list.
881
-
882
- ```js
883
- let val = await I.executeAsyncScript(function(url, done) {
884
- // in browser context
885
- $.ajax(url, { success: (data) => done(data); }
886
- }, 'http://ajax.callback.url/');
887
- ```
888
-
889
- #### Parameters
890
-
891
- - `args` **...any** to be passed to function.
892
- - `fn` **([string][17] | [function][24])** function to be executed in browser context.
893
-
894
- Returns **[Promise][25]&lt;any>** script return value
895
-
896
- ### executeScript
897
-
898
- Wraps [execute][26] command.
899
-
900
- Executes sync script on a page.
901
- Pass arguments to function as additional parameters.
902
- Will return execution result to a test.
903
- In this case you should use async function and await to receive results.
904
-
905
- Example with jQuery DatePicker:
906
-
907
- ```js
908
- // change date of jQuery DatePicker
909
- I.executeScript(function() {
910
- // now we are inside browser context
911
- $('date').datetimepicker('setDate', new Date());
912
- });
913
- ```
914
-
915
- Can return values. Don't forget to use `await` to get them.
916
-
917
- ```js
918
- let date = await I.executeScript(function(el) {
919
- // only basic types can be returned
920
- return $(el).datetimepicker('getDate').toString();
921
- }, '#date'); // passing jquery selector
922
- ```
923
-
924
- #### Parameters
925
-
926
- - `args` **...any** to be passed to function.
927
- - `fn` **([string][17] | [function][24])** function to be executed in browser context.
928
-
929
- Returns **[Promise][25]&lt;any>** script return value
930
-
931
- ### fillField
932
-
933
- Fills a text field or textarea, after clearing its value, with the given string.
934
- Field is located by name, label, CSS, or XPath.
935
-
936
- ```js
937
- // by label
938
- I.fillField('Email', 'hello@world.com');
939
- // by name
940
- I.fillField('password', secret('123456'));
941
- // by CSS
942
- I.fillField('form#login input[name=username]', 'John');
943
- // or by strict locator
944
- I.fillField({css: 'form#login input[name=username]'}, 'John');
945
- ```
946
-
947
- #### Parameters
948
-
949
- - `field` **([string][17] | [object][16])** located by label|name|CSS|XPath|strict locator.
950
- - `value` **([string][17] | [object][16])** text value to fill.
951
-
952
- Returns **void** automatically synchronized promise through #recorder
953
-
954
-
955
- This action supports [React locators](https://codecept.io/react#locators)
956
-
957
- {{ custom }}
958
-
959
- ### focus
960
-
961
- Calls [focus][19] on the matching element.
962
-
963
- Examples:
964
-
965
- ```js
966
- I.dontSee('#add-to-cart-btn');
967
- I.focus('#product-tile')
968
- I.see('#add-to-cart-bnt');
969
- ```
970
-
971
- #### Parameters
972
-
973
- - `locator` **([string][17] | [object][16])** field located by label|name|CSS|XPath|strict locator.
974
- - `options` **any?** Playwright only: [Additional options][27] for available options object as 2nd argument.
975
-
976
- Returns **void** automatically synchronized promise through #recorder
977
-
978
- ### forceClick
979
-
980
- Perform an emulated click on a link or a button, given by a locator.
981
- Unlike normal click instead of sending native event, emulates a click with JavaScript.
982
- This works on hidden, animated or inactive elements as well.
983
-
984
- If a fuzzy locator is given, the page will be searched for a button, link, or image matching the locator string.
985
- For buttons, the "value" attribute, "name" attribute, and inner text are searched. For links, the link text is searched.
986
- For images, the "alt" attribute and inner text of any parent links are searched.
987
-
988
- The second parameter is a context (CSS or XPath locator) to narrow the search.
989
-
990
- ```js
991
- // simple link
992
- I.forceClick('Logout');
993
- // button of form
994
- I.forceClick('Submit');
995
- // CSS button
996
- I.forceClick('#form input[type=submit]');
997
- // XPath
998
- I.forceClick('//form/*[@type=submit]');
999
- // link in context
1000
- I.forceClick('Logout', '#nav');
1001
- // using strict locator
1002
- I.forceClick({css: 'nav a.login'});
1003
- ```
1004
-
1005
- #### Parameters
1006
-
1007
- - `locator` **([string][17] | [object][16])** clickable link or button located by text, or any element located by CSS|XPath|strict locator.
1008
- - `context` **([string][17]? | [object][16])** (optional, `null` by default) element to search in CSS|XPath|Strict locator.
1009
-
1010
- Returns **void** automatically synchronized promise through #recorder
1011
-
1012
-
1013
- This action supports [React locators](https://codecept.io/react#locators)
1014
-
1015
-
1016
- ### forceRightClick
1017
-
1018
- Emulates right click on an element.
1019
- Unlike normal click instead of sending native event, emulates a click with JavaScript.
1020
- This works on hidden, animated or inactive elements as well.
1021
-
1022
- If a fuzzy locator is given, the page will be searched for a button, link, or image matching the locator string.
1023
- For buttons, the "value" attribute, "name" attribute, and inner text are searched. For links, the link text is searched.
1024
- For images, the "alt" attribute and inner text of any parent links are searched.
1025
-
1026
- The second parameter is a context (CSS or XPath locator) to narrow the search.
1027
-
1028
- ```js
1029
- // simple link
1030
- I.forceRightClick('Menu');
1031
- ```
1032
-
1033
- #### Parameters
1034
-
1035
- - `locator` **([string][17] | [object][16])** clickable link or button located by text, or any element located by CSS|XPath|strict locator.
1036
- - `context` **([string][17]? | [object][16])** (optional, `null` by default) element to search in CSS|XPath|Strict locator.
1037
-
1038
- Returns **void** automatically synchronized promise through #recorder
1039
-
1040
-
1041
- This action supports [React locators](https://codecept.io/react#locators)
1042
-
1043
-
1044
- ### grabAllWindowHandles
1045
-
1046
- Get all Window Handles.
1047
- Useful for referencing a specific handle when calling `I.switchToWindow(handle)`
1048
-
1049
- ```js
1050
- const windows = await I.grabAllWindowHandles();
1051
- ```
1052
-
1053
- Returns **[Promise][25]&lt;[Array][28]&lt;[string][17]>>**
1054
-
1055
- ### grabAttributeFrom
1056
-
1057
- Retrieves an attribute from an element located by CSS or XPath and returns it to test.
1058
- Resumes test execution, so **should be used inside async with `await`** operator.
1059
- If more than one element is found - attribute of first element is returned.
1060
-
1061
- ```js
1062
- let hint = await I.grabAttributeFrom('#tooltip', 'title');
1063
- ```
1064
-
1065
- #### Parameters
1066
-
1067
- - `locator` **([string][17] | [object][16])** element located by CSS|XPath|strict locator.
1068
- - `attr` **[string][17]** attribute name.
1069
-
1070
- Returns **[Promise][25]&lt;[string][17]>** attribute value
1071
-
1072
- ### grabAttributeFromAll
1073
-
1074
- Retrieves an array of attributes from elements located by CSS or XPath and returns it to test.
1075
- Resumes test execution, so **should be used inside async with `await`** operator.
1076
-
1077
- ```js
1078
- let hints = await I.grabAttributeFromAll('.tooltip', 'title');
1079
- ```
1080
-
1081
- #### Parameters
1082
-
1083
- - `locator` **([string][17] | [object][16])** element located by CSS|XPath|strict locator.
1084
- - `attr` **[string][17]** attribute name.
1085
-
1086
- Returns **[Promise][25]&lt;[Array][28]&lt;[string][17]>>** attribute value
1087
-
1088
- ### grabBrowserLogs
1089
-
1090
- Get JS log from browser. Log buffer is reset after each request.
1091
- Resumes test execution, so **should be used inside an async function with `await`** operator.
1092
-
1093
- ```js
1094
- let logs = await I.grabBrowserLogs();
1095
- console.log(JSON.stringify(logs))
1096
- ```
1097
-
1098
- Returns **([Promise][25]&lt;[Array][28]&lt;[object][16]>> | [undefined][29])** all browser logs
1099
-
1100
- ### grabCookie
1101
-
1102
- Gets a cookie object by name.
1103
- If none provided gets all cookies.
1104
- Resumes test execution, so **should be used inside async function with `await`** operator.
1105
-
1106
- ```js
1107
- let cookie = await I.grabCookie('auth');
1108
- assert(cookie.value, '123456');
1109
- ```
1110
-
1111
- #### Parameters
1112
-
1113
- - `name` **[string][17]?** cookie name.
1114
-
1115
- Returns **any** attribute value
1116
-
1117
- ### grabCssPropertyFrom
1118
-
1119
- Grab CSS property for given locator
1120
- Resumes test execution, so **should be used inside an async function with `await`** operator.
1121
- If more than one element is found - value of first element is returned.
1122
-
1123
- ```js
1124
- const value = await I.grabCssPropertyFrom('h3', 'font-weight');
1125
- ```
1126
-
1127
- #### Parameters
1128
-
1129
- - `locator` **([string][17] | [object][16])** element located by CSS|XPath|strict locator.
1130
- - `cssProperty` **[string][17]** CSS property name.
1131
-
1132
- Returns **[Promise][25]&lt;[string][17]>** CSS value
1133
-
1134
- ### grabCssPropertyFromAll
1135
-
1136
- Grab array of CSS properties for given locator
1137
- Resumes test execution, so **should be used inside an async function with `await`** operator.
1138
-
1139
- ```js
1140
- const values = await I.grabCssPropertyFromAll('h3', 'font-weight');
1141
- ```
1142
-
1143
- #### Parameters
1144
-
1145
- - `locator` **([string][17] | [object][16])** element located by CSS|XPath|strict locator.
1146
- - `cssProperty` **[string][17]** CSS property name.
1147
-
1148
- Returns **[Promise][25]&lt;[Array][28]&lt;[string][17]>>** CSS value
1149
-
1150
- ### grabCurrentUrl
1151
-
1152
- Get current URL from browser.
1153
- Resumes test execution, so should be used inside an async function.
1154
-
1155
- ```js
1156
- let url = await I.grabCurrentUrl();
1157
- console.log(`Current URL is [${url}]`);
1158
- ```
1159
-
1160
- Returns **[Promise][25]&lt;[string][17]>** current URL
1161
-
1162
- ### grabCurrentWindowHandle
1163
-
1164
- Get the current Window Handle.
1165
- Useful for referencing it when calling `I.switchToWindow(handle)`
1166
-
1167
- ```js
1168
- const window = await I.grabCurrentWindowHandle();
1169
- ```
1170
-
1171
- Returns **[Promise][25]&lt;[string][17]>**
1172
-
1173
- ### grabElementBoundingRect
1174
-
1175
- Grab the width, height, location of given locator.
1176
- Provide `width` or `height`as second param to get your desired prop.
1177
- Resumes test execution, so **should be used inside an async function with `await`** operator.
1178
-
1179
- Returns an object with `x`, `y`, `width`, `height` keys.
1180
-
1181
- ```js
1182
- const value = await I.grabElementBoundingRect('h3');
1183
- // value is like { x: 226.5, y: 89, width: 527, height: 220 }
1184
- ```
1185
-
1186
- To get only one metric use second parameter:
1187
-
1188
- ```js
1189
- const width = await I.grabElementBoundingRect('h3', 'width');
1190
- // width == 527
1191
- ```
1192
-
1193
- #### Parameters
1194
-
1195
- - `locator` **([string][17] | [object][16])** element located by CSS|XPath|strict locator.
1196
- - `prop`
1197
- - `elementSize` **[string][17]?** x, y, width or height of the given element.
1198
-
1199
- Returns **([Promise][25]&lt;DOMRect> | [Promise][25]&lt;[number][22]>)** Element bounding rectangle
1200
-
1201
- ### grabGeoLocation
1202
-
1203
- Return the current geo location
1204
- Resumes test execution, so **should be used inside async function with `await`** operator.
1205
-
1206
- ```js
1207
- let geoLocation = await I.grabGeoLocation();
1208
- ```
1209
-
1210
- Returns **[Promise][25]&lt;{latitude: [number][22], longitude: [number][22], altitude: [number][22]}>**
1211
-
1212
- ### grabHTMLFrom
1213
-
1214
- Retrieves the innerHTML from an element located by CSS or XPath and returns it to test.
1215
- Resumes test execution, so **should be used inside async function with `await`** operator.
1216
- If more than one element is found - HTML of first element is returned.
1217
-
1218
- ```js
1219
- let postHTML = await I.grabHTMLFrom('#post');
1220
- ```
1221
-
1222
- #### Parameters
1223
-
1224
- - `locator`
1225
- - `element` **([string][17] | [object][16])** located by CSS|XPath|strict locator.
1226
-
1227
- Returns **[Promise][25]&lt;[string][17]>** HTML code for an element
1228
-
1229
- ### grabHTMLFromAll
1230
-
1231
- Retrieves all the innerHTML from elements located by CSS or XPath and returns it to test.
1232
- Resumes test execution, so **should be used inside async function with `await`** operator.
1233
-
1234
- ```js
1235
- let postHTMLs = await I.grabHTMLFromAll('.post');
1236
- ```
1237
-
1238
- #### Parameters
1239
-
1240
- - `locator`
1241
- - `element` **([string][17] | [object][16])** located by CSS|XPath|strict locator.
1242
-
1243
- Returns **[Promise][25]&lt;[Array][28]&lt;[string][17]>>** HTML code for an element
1244
-
1245
- ### grabNumberOfOpenTabs
1246
-
1247
- Grab number of open tabs.
1248
- Resumes test execution, so **should be used inside async function with `await`** operator.
1249
-
1250
- ```js
1251
- let tabs = await I.grabNumberOfOpenTabs();
1252
- ```
1253
-
1254
- Returns **[Promise][25]&lt;[number][22]>** number of open tabs
1255
-
1256
- ### grabNumberOfVisibleElements
1257
-
1258
- Grab number of visible elements by locator.
1259
- Resumes test execution, so **should be used inside async function with `await`** operator.
1260
-
1261
- ```js
1262
- let numOfElements = await I.grabNumberOfVisibleElements('p');
1263
- ```
1264
-
1265
- #### Parameters
1266
-
1267
- - `locator` **([string][17] | [object][16])** located by CSS|XPath|strict locator.
1268
-
1269
- Returns **[Promise][25]&lt;[number][22]>** number of visible elements
1270
-
1271
- ### grabPageScrollPosition
1272
-
1273
- Retrieves a page scroll position and returns it to test.
1274
- Resumes test execution, so **should be used inside an async function with `await`** operator.
1275
-
1276
- ```js
1277
- let { x, y } = await I.grabPageScrollPosition();
1278
- ```
1279
-
1280
- Returns **[Promise][25]&lt;PageScrollPosition>** scroll position
1281
-
1282
- ### grabPopupText
1283
-
1284
- Grab the text within the popup. If no popup is visible then it will return null.
1285
-
1286
- ```js
1287
- await I.grabPopupText();
1288
- ```
1289
-
1290
- Returns **[Promise][25]&lt;[string][17]>**
1291
-
1292
- ### grabSource
1293
-
1294
- Retrieves page source and returns it to test.
1295
- Resumes test execution, so **should be used inside async function with `await`** operator.
1296
-
1297
- ```js
1298
- let pageSource = await I.grabSource();
1299
- ```
1300
-
1301
- Returns **[Promise][25]&lt;[string][17]>** source code
1302
-
1303
- ### grabTextFrom
1304
-
1305
- Retrieves a text from an element located by CSS or XPath and returns it to test.
1306
- Resumes test execution, so **should be used inside async with `await`** operator.
1307
-
1308
- ```js
1309
- let pin = await I.grabTextFrom('#pin');
1310
- ```
1311
-
1312
- If multiple elements found returns first element.
1313
-
1314
- #### Parameters
1315
-
1316
- - `locator` **([string][17] | [object][16])** element located by CSS|XPath|strict locator.
1317
-
1318
- Returns **[Promise][25]&lt;[string][17]>** attribute value
1319
-
1320
- ### grabTextFromAll
1321
-
1322
- Retrieves all texts from an element located by CSS or XPath and returns it to test.
1323
- Resumes test execution, so **should be used inside async with `await`** operator.
1324
-
1325
- ```js
1326
- let pins = await I.grabTextFromAll('#pin li');
1327
- ```
1328
-
1329
- #### Parameters
1330
-
1331
- - `locator` **([string][17] | [object][16])** element located by CSS|XPath|strict locator.
1332
-
1333
- Returns **[Promise][25]&lt;[Array][28]&lt;[string][17]>>** attribute value
1334
-
1335
- ### grabTitle
1336
-
1337
- Retrieves a page title and returns it to test.
1338
- Resumes test execution, so **should be used inside async with `await`** operator.
1339
-
1340
- ```js
1341
- let title = await I.grabTitle();
1342
- ```
1343
-
1344
- Returns **[Promise][25]&lt;[string][17]>** title
1345
-
1346
- ### grabValueFrom
1347
-
1348
- Retrieves a value from a form element located by CSS or XPath and returns it to test.
1349
- Resumes test execution, so **should be used inside async function with `await`** operator.
1350
- If more than one element is found - value of first element is returned.
1351
-
1352
- ```js
1353
- let email = await I.grabValueFrom('input[name=email]');
1354
- ```
1355
-
1356
- #### Parameters
1357
-
1358
- - `locator` **([string][17] | [object][16])** field located by label|name|CSS|XPath|strict locator.
1359
-
1360
- Returns **[Promise][25]&lt;[string][17]>** attribute value
1361
-
1362
- ### grabValueFromAll
1363
-
1364
- Retrieves an array of value from a form located by CSS or XPath and returns it to test.
1365
- Resumes test execution, so **should be used inside async function with `await`** operator.
1366
-
1367
- ```js
1368
- let inputs = await I.grabValueFromAll('//form/input');
1369
- ```
1370
-
1371
- #### Parameters
1372
-
1373
- - `locator` **([string][17] | [object][16])** field located by label|name|CSS|XPath|strict locator.
1374
-
1375
- Returns **[Promise][25]&lt;[Array][28]&lt;[string][17]>>** attribute value
1376
-
1377
- ### grabWebElements
1378
-
1379
- Grab WebElements for given locator
1380
- Resumes test execution, so **should be used inside an async function with `await`** operator.
1381
-
1382
- ```js
1383
- const webElements = await I.grabWebElements('#button');
1384
- ```
1385
-
1386
- #### Parameters
1387
-
1388
- - `locator` **([string][17] | [object][16])** element located by CSS|XPath|strict locator.
1389
-
1390
- Returns **[Promise][25]&lt;any>** WebElement of being used Web helper
1391
-
1392
- ### moveCursorTo
1393
-
1394
- Moves cursor to element matched by locator.
1395
- Extra shift can be set with offsetX and offsetY options.
1396
-
1397
- ```js
1398
- I.moveCursorTo('.tooltip');
1399
- I.moveCursorTo('#submit', 5,5);
1400
- ```
1401
-
1402
- #### Parameters
1403
-
1404
- - `locator` **([string][17] | [object][16])** located by CSS|XPath|strict locator.
1405
- - `xOffset`
1406
- - `yOffset`
1407
- - `offsetX` **[number][22]** (optional, `0` by default) X-axis offset.
1408
- - `offsetY` **[number][22]** (optional, `0` by default) Y-axis offset.
1409
-
1410
- Returns **void** automatically synchronized promise through #recorder
1411
-
1412
- ### openNewTab
1413
-
1414
- Open new tab and switch to it.
1415
-
1416
- ```js
1417
- I.openNewTab();
1418
- ```
1419
-
1420
- #### Parameters
1421
-
1422
- - `url`
1423
- - `windowName`
1424
-
1425
- Returns **void** automatically synchronized promise through #recorder
1426
-
1427
- ### pressKey
1428
-
1429
- _Note:_ In case a text field or textarea is focused be aware that some browsers do not respect active modifier when combining modifier keys with other keys.
1430
-
1431
- Presses a key in the browser (on a focused element).
1432
-
1433
- _Hint:_ For populating text field or textarea, it is recommended to use [`fillField`][30].
1434
-
1435
- ```js
1436
- I.pressKey('Backspace');
1437
- ```
1438
-
1439
- To press a key in combination with modifier keys, pass the sequence as an array. All modifier keys (`'Alt'`, `'Control'`, `'Meta'`, `'Shift'`) will be released afterwards.
1440
-
1441
- ```js
1442
- I.pressKey(['Control', 'Z']);
1443
- ```
1444
-
1445
- For specifying operation modifier key based on operating system it is suggested to use `'CommandOrControl'`.
1446
- This will press `'Command'` (also known as `'Meta'`) on macOS machines and `'Control'` on non-macOS machines.
1447
-
1448
- ```js
1449
- I.pressKey(['CommandOrControl', 'Z']);
1450
- ```
1451
-
1452
- Some of the supported key names are:
1453
-
1454
- - `'AltLeft'` or `'Alt'`
1455
- - `'AltRight'`
1456
- - `'ArrowDown'`
1457
- - `'ArrowLeft'`
1458
- - `'ArrowRight'`
1459
- - `'ArrowUp'`
1460
- - `'Backspace'`
1461
- - `'Clear'`
1462
- - `'ControlLeft'` or `'Control'`
1463
- - `'ControlRight'`
1464
- - `'Command'`
1465
- - `'CommandOrControl'`
1466
- - `'Delete'`
1467
- - `'End'`
1468
- - `'Enter'`
1469
- - `'Escape'`
1470
- - `'F1'` to `'F12'`
1471
- - `'Home'`
1472
- - `'Insert'`
1473
- - `'MetaLeft'` or `'Meta'`
1474
- - `'MetaRight'`
1475
- - `'Numpad0'` to `'Numpad9'`
1476
- - `'NumpadAdd'`
1477
- - `'NumpadDecimal'`
1478
- - `'NumpadDivide'`
1479
- - `'NumpadMultiply'`
1480
- - `'NumpadSubtract'`
1481
- - `'PageDown'`
1482
- - `'PageUp'`
1483
- - `'Pause'`
1484
- - `'Return'`
1485
- - `'ShiftLeft'` or `'Shift'`
1486
- - `'ShiftRight'`
1487
- - `'Space'`
1488
- - `'Tab'`
1489
-
1490
- #### Parameters
1491
-
1492
- - `key` **([string][17] | [Array][28]&lt;[string][17]>)** key or array of keys to press.
1493
-
1494
- Returns **void** automatically synchronized promise through #recorder
1495
-
1496
- ### pressKeyDown
1497
-
1498
- Presses a key in the browser and leaves it in a down state.
1499
-
1500
- To make combinations with modifier key and user operation (e.g. `'Control'` + [`click`][31]).
1501
-
1502
- ```js
1503
- I.pressKeyDown('Control');
1504
- I.click('#element');
1505
- I.pressKeyUp('Control');
1506
- ```
1507
-
1508
- #### Parameters
1509
-
1510
- - `key` **[string][17]** name of key to press down.
1511
-
1512
- Returns **void** automatically synchronized promise through #recorder
1513
-
1514
- ### pressKeyUp
1515
-
1516
- Releases a key in the browser which was previously set to a down state.
1517
-
1518
- To make combinations with modifier key and user operation (e.g. `'Control'` + [`click`][31]).
1519
-
1520
- ```js
1521
- I.pressKeyDown('Control');
1522
- I.click('#element');
1523
- I.pressKeyUp('Control');
1524
- ```
1525
-
1526
- #### Parameters
1527
-
1528
- - `key` **[string][17]** name of key to release.
1529
-
1530
- Returns **void** automatically synchronized promise through #recorder
1531
-
1532
- ### refreshPage
1533
-
1534
- Reload the current page.
1535
-
1536
- ```js
1537
- I.refreshPage();
1538
- ```
1539
-
1540
- Returns **void** automatically synchronized promise through #recorder
1541
-
1542
- ### resizeWindow
1543
-
1544
- Appium: not tested in web, in apps doesn't work
1545
-
1546
- Resize the current window to provided width and height.
1547
- First parameter can be set to `maximize`.
1548
-
1549
- #### Parameters
1550
-
1551
- - `width` **[number][22]** width in pixels or `maximize`.
1552
- - `height` **[number][22]** height in pixels.
1553
-
1554
- Returns **void** automatically synchronized promise through #recorder
1555
-
1556
- ### rightClick
1557
-
1558
- Performs right click on a clickable element matched by semantic locator, CSS or XPath.
1559
-
1560
- ```js
1561
- // right click element with id el
1562
- I.rightClick('#el');
1563
- // right click link or button with text "Click me"
1564
- I.rightClick('Click me');
1565
- // right click button with text "Click me" inside .context
1566
- I.rightClick('Click me', '.context');
1567
- ```
1568
-
1569
- #### Parameters
1570
-
1571
- - `locator` **([string][17] | [object][16])** clickable element located by CSS|XPath|strict locator.
1572
- - `context` **([string][17]? | [object][16])** (optional, `null` by default) element located by CSS|XPath|strict locator.
1573
-
1574
- Returns **void** automatically synchronized promise through #recorder
1575
-
1576
-
1577
- This action supports [React locators](https://codecept.io/react#locators)
1578
-
1579
-
1580
- ### runInWeb
1581
-
1582
- Placeholder for ~ locator only test case write once run on both Appium and WebDriver.
1583
-
1584
- #### Parameters
1585
-
1586
- - `fn`
1587
-
1588
- ### runOnAndroid
1589
-
1590
- Placeholder for ~ locator only test case write once run on both Appium and WebDriver.
1591
-
1592
- #### Parameters
1593
-
1594
- - `caps` **any**
1595
- - `fn` **any**
1596
-
1597
- ### runOnIOS
1598
-
1599
- Placeholder for ~ locator only test case write once run on both Appium and WebDriver.
1600
-
1601
- #### Parameters
1602
-
1603
- - `caps` **any**
1604
- - `fn` **any**
1605
-
1606
- ### saveElementScreenshot
1607
-
1608
- Saves screenshot of the specified locator to ouput folder (set in codecept.conf.ts or codecept.conf.js).
1609
- Filename is relative to output folder.
1610
-
1611
- ```js
1612
- I.saveElementScreenshot(`#submit`,'debug.png');
1613
- ```
1614
-
1615
- #### Parameters
1616
-
1617
- - `locator` **([string][17] | [object][16])** element located by CSS|XPath|strict locator.
1618
- - `fileName` **[string][17]** file name to save.
1619
-
1620
- Returns **void** automatically synchronized promise through #recorder
1621
-
1622
- ### saveScreenshot
1623
-
1624
- Saves a screenshot to ouput folder (set in codecept.conf.ts or codecept.conf.js).
1625
- Filename is relative to output folder.
1626
- 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.
1627
-
1628
- ```js
1629
- I.saveScreenshot('debug.png');
1630
- I.saveScreenshot('debug.png', true) //resizes to available scrollHeight and scrollWidth before taking screenshot
1631
- ```
1632
-
1633
- #### Parameters
1634
-
1635
- - `fileName` **[string][17]** file name to save.
1636
- - `fullPage` **[boolean][32]** (optional, `false` by default) flag to enable fullscreen screenshot mode.
1637
-
1638
- Returns **void** automatically synchronized promise through #recorder
1639
-
1640
- ### scrollIntoView
1641
-
1642
- Scroll element into viewport.
1643
-
1644
- ```js
1645
- I.scrollIntoView('#submit');
1646
- I.scrollIntoView('#submit', true);
1647
- I.scrollIntoView('#submit', { behavior: "smooth", block: "center", inline: "center" });
1648
- ```
1649
-
1650
- #### Parameters
1651
-
1652
- - `locator` **([string][17] | [object][16])** located by CSS|XPath|strict locator.
1653
- - `scrollIntoViewOptions` **(ScrollIntoViewOptions | [boolean][32])** either alignToTop=true|false or scrollIntoViewOptions. See [https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView][33].
1654
-
1655
- Returns **void** automatically synchronized promise through #recorder
1656
-
1657
- ### scrollPageToBottom
1658
-
1659
- Scroll page to the bottom.
1660
-
1661
- ```js
1662
- I.scrollPageToBottom();
1663
- ```
1664
-
1665
- Returns **void** automatically synchronized promise through #recorder
1666
-
1667
- ### scrollPageToTop
1668
-
1669
- Scroll page to the top.
1670
-
1671
- ```js
1672
- I.scrollPageToTop();
1673
- ```
1674
-
1675
- Returns **void** automatically synchronized promise through #recorder
1676
-
1677
- ### scrollTo
1678
-
1679
- Scrolls to element matched by locator.
1680
- Extra shift can be set with offsetX and offsetY options.
1681
-
1682
- ```js
1683
- I.scrollTo('footer');
1684
- I.scrollTo('#submit', 5, 5);
1685
- ```
1686
-
1687
- #### Parameters
1688
-
1689
- - `locator` **([string][17] | [object][16])** located by CSS|XPath|strict locator.
1690
- - `offsetX` **[number][22]** (optional, `0` by default) X-axis offset.
1691
- - `offsetY` **[number][22]** (optional, `0` by default) Y-axis offset.
1692
-
1693
- Returns **void** automatically synchronized promise through #recorder
1694
-
1695
- ### see
1696
-
1697
- Checks that a page contains a visible text.
1698
- Use context parameter to narrow down the search.
1699
-
1700
- ```js
1701
- I.see('Welcome'); // text welcome on a page
1702
- I.see('Welcome', '.content'); // text inside .content div
1703
- I.see('Register', {css: 'form.register'}); // use strict locator
1704
- ```
1705
-
1706
- #### Parameters
1707
-
1708
- - `text` **[string][17]** expected on page.
1709
- - `context` **([string][17]? | [object][16])** (optional, `null` by default) element located by CSS|Xpath|strict locator in which to search for text.
1710
-
1711
- Returns **void** automatically synchronized promise through #recorder
1712
-
1713
-
1714
- This action supports [React locators](https://codecept.io/react#locators)
1715
-
1716
-
1717
- ### seeAttributesOnElements
1718
-
1719
- Checks that all elements with given locator have given attributes.
1720
-
1721
- ```js
1722
- I.seeAttributesOnElements('//form', { method: "post"});
1723
- ```
1724
-
1725
- #### Parameters
1726
-
1727
- - `locator` **([string][17] | [object][16])** located by CSS|XPath|strict locator.
1728
- - `attributes` **[object][16]** attributes and their values to check.
1729
-
1730
- Returns **void** automatically synchronized promise through #recorder
1731
-
1732
- ### seeCheckboxIsChecked
1733
-
1734
- Appium: not tested
1735
- Verifies that the specified checkbox is checked.
1736
-
1737
- ```js
1738
- I.seeCheckboxIsChecked('Agree');
1739
- I.seeCheckboxIsChecked('#agree'); // I suppose user agreed to terms
1740
- I.seeCheckboxIsChecked({css: '#signup_form input[type=checkbox]'});
1741
- ```
1742
-
1743
- #### Parameters
1744
-
1745
- - `field` **([string][17] | [object][16])** located by label|name|CSS|XPath|strict locator.
1746
-
1747
- Returns **void** automatically synchronized promise through #recorder
1748
-
1749
- ### seeCookie
1750
-
1751
- Checks that cookie with given name exists.
1752
-
1753
- ```js
1754
- I.seeCookie('Auth');
1755
- ```
1756
-
1757
- #### Parameters
1758
-
1759
- - `name` **[string][17]** cookie name.
1760
-
1761
- Returns **void** automatically synchronized promise through #recorder
1762
-
1763
- ### seeCssPropertiesOnElements
1764
-
1765
- Checks that all elements with given locator have given CSS properties.
1766
-
1767
- ```js
1768
- I.seeCssPropertiesOnElements('h3', { 'font-weight': "bold"});
1769
- ```
1770
-
1771
- #### Parameters
1772
-
1773
- - `locator` **([string][17] | [object][16])** located by CSS|XPath|strict locator.
1774
- - `cssProperties` **[object][16]** object with CSS properties and their values to check.
1775
-
1776
- Returns **void** automatically synchronized promise through #recorder
1777
-
1778
- ### seeCurrentUrlEquals
1779
-
1780
- Checks that current url is equal to provided one.
1781
- If a relative url provided, a configured url will be prepended to it.
1782
- So both examples will work:
1783
-
1784
- ```js
1785
- I.seeCurrentUrlEquals('/register');
1786
- I.seeCurrentUrlEquals('http://my.site.com/register');
1787
- ```
1788
-
1789
- #### Parameters
1790
-
1791
- - `url` **[string][17]** value to check.
1792
-
1793
- Returns **void** automatically synchronized promise through #recorder
1794
-
1795
- ### seeElement
1796
-
1797
- Checks that a given Element is visible
1798
- Element is located by CSS or XPath.
1799
-
1800
- ```js
1801
- I.seeElement('#modal');
1802
- ```
1803
-
1804
- #### Parameters
1805
-
1806
- - `locator` **([string][17] | [object][16])** located by CSS|XPath|strict locator.
1807
-
1808
- Returns **void** automatically synchronized promise through #recorder
1809
-
1810
-
1811
- This action supports [React locators](https://codecept.io/react#locators)
1812
-
1813
-
1814
- ### seeElementInDOM
1815
-
1816
- Checks that a given Element is present in the DOM
1817
- Element is located by CSS or XPath.
1818
-
1819
- ```js
1820
- I.seeElementInDOM('#modal');
1821
- ```
1822
-
1823
- #### Parameters
1824
-
1825
- - `locator` **([string][17] | [object][16])** element located by CSS|XPath|strict locator.
1826
-
1827
- Returns **void** automatically synchronized promise through #recorder
1828
-
1829
- ### seeInCurrentUrl
1830
-
1831
- Checks that current url contains a provided fragment.
1832
-
1833
- ```js
1834
- I.seeInCurrentUrl('/register'); // we are on registration page
1835
- ```
1836
-
1837
- #### Parameters
1838
-
1839
- - `url` **[string][17]** a fragment to check
1840
-
1841
- Returns **void** automatically synchronized promise through #recorder
1842
-
1843
- ### seeInField
1844
-
1845
- Checks that the given input field or textarea equals to given value.
1846
- For fuzzy locators, fields are matched by label text, the "name" attribute, CSS, and XPath.
1847
-
1848
- ```js
1849
- I.seeInField('Username', 'davert');
1850
- I.seeInField({css: 'form textarea'},'Type your comment here');
1851
- I.seeInField('form input[type=hidden]','hidden_value');
1852
- I.seeInField('#searchform input','Search');
1853
- ```
1854
-
1855
- #### Parameters
1856
-
1857
- - `field` **([string][17] | [object][16])** located by label|name|CSS|XPath|strict locator.
1858
- - `value` **([string][17] | [object][16])** value to check.
1859
-
1860
- Returns **void** automatically synchronized promise through #recorder
1861
-
1862
- ### seeInPopup
1863
-
1864
- Checks that the active JavaScript popup, as created by `window.alert|window.confirm|window.prompt`, contains the
1865
- given string.
1866
-
1867
- #### Parameters
1868
-
1869
- - `text` **[string][17]** value to check.
1870
-
1871
- ### seeInSource
1872
-
1873
- Checks that the current page contains the given string in its raw source code.
1874
-
1875
- ```js
1876
- I.seeInSource('<h1>Green eggs &amp; ham</h1>');
1877
- ```
1878
-
1879
- #### Parameters
1880
-
1881
- - `text` **[string][17]** value to check.
1882
-
1883
- Returns **void** automatically synchronized promise through #recorder
1884
-
1885
- ### seeInTitle
1886
-
1887
- Checks that title contains text.
1888
-
1889
- ```js
1890
- I.seeInTitle('Home Page');
1891
- ```
1892
-
1893
- #### Parameters
1894
-
1895
- - `text` **[string][17]** text value to check.
1896
-
1897
- Returns **void** automatically synchronized promise through #recorder
1898
-
1899
- ### seeNumberOfElements
1900
-
1901
- Asserts that an element appears a given number of times in the DOM.
1902
- Element is located by label or name or CSS or XPath.
1903
-
1904
- ```js
1905
- I.seeNumberOfElements('#submitBtn', 1);
1906
- ```
1907
-
1908
- #### Parameters
1909
-
1910
- - `locator` **([string][17] | [object][16])** element located by CSS|XPath|strict locator.
1911
- - `num` **[number][22]** number of elements.
1912
-
1913
- Returns **void** automatically synchronized promise through #recorder
1914
-
1915
-
1916
- This action supports [React locators](https://codecept.io/react#locators)
1917
-
1918
-
1919
- ### seeNumberOfVisibleElements
1920
-
1921
- Asserts that an element is visible a given number of times.
1922
- Element is located by CSS or XPath.
1923
-
1924
- ```js
1925
- I.seeNumberOfVisibleElements('.buttons', 3);
1926
- ```
1927
-
1928
- #### Parameters
1929
-
1930
- - `locator` **([string][17] | [object][16])** element located by CSS|XPath|strict locator.
1931
- - `num` **[number][22]** number of elements.
1932
-
1933
- Returns **void** automatically synchronized promise through #recorder
1934
-
1935
-
1936
- This action supports [React locators](https://codecept.io/react#locators)
1937
-
1938
-
1939
- ### seeTextEquals
1940
-
1941
- Checks that text is equal to provided one.
1942
-
1943
- ```js
1944
- I.seeTextEquals('text', 'h1');
1945
- ```
1946
-
1947
- #### Parameters
1948
-
1949
- - `text` **[string][17]** element value to check.
1950
- - `context` **([string][17] | [object][16])?** element located by CSS|XPath|strict locator.
1951
-
1952
- Returns **void** automatically synchronized promise through #recorder
1953
-
1954
- ### seeTitleEquals
1955
-
1956
- Checks that title is equal to provided one.
1957
-
1958
- ```js
1959
- I.seeTitleEquals('Test title.');
1960
- ```
1961
-
1962
- #### Parameters
1963
-
1964
- - `text` **[string][17]** value to check.
1965
-
1966
- Returns **void** automatically synchronized promise through #recorder
1967
-
1968
- ### selectOption
1969
-
1970
- Selects an option in a drop-down select.
1971
- Field is searched by label | name | CSS | XPath.
1972
- Option is selected by visible text or by value.
1973
-
1974
- ```js
1975
- I.selectOption('Choose Plan', 'Monthly'); // select by label
1976
- I.selectOption('subscription', 'Monthly'); // match option by text
1977
- I.selectOption('subscription', '0'); // or by value
1978
- I.selectOption('//form/select[@name=account]','Premium');
1979
- I.selectOption('form select[name=account]', 'Premium');
1980
- I.selectOption({css: 'form select[name=account]'}, 'Premium');
1981
- ```
1982
-
1983
- Provide an array for the second argument to select multiple options.
1984
-
1985
- ```js
1986
- I.selectOption('Which OS do you use?', ['Android', 'iOS']);
1987
- ```
1988
-
1989
- #### Parameters
1990
-
1991
- - `select` **([string][17] | [object][16])** field located by label|name|CSS|XPath|strict locator.
1992
- - `option` **([string][17] | [Array][28]&lt;any>)** visible text or value of option.
1993
-
1994
- Returns **void** automatically synchronized promise through #recorder
1995
-
1996
- ### setCookie
1997
-
1998
- Uses Selenium's JSON [cookie format][34].
1999
- Sets cookie(s).
2000
-
2001
- Can be a single cookie object or an array of cookies:
2002
-
2003
- ```js
2004
- I.setCookie({name: 'auth', value: true});
2005
-
2006
- // as array
2007
- I.setCookie([
2008
- {name: 'auth', value: true},
2009
- {name: 'agree', value: true}
2010
- ]);
2011
- ```
2012
-
2013
- #### Parameters
2014
-
2015
- - `cookie` **(Cookie | [Array][28]&lt;Cookie>)** a cookie object or array of cookie objects.
2016
-
2017
- Returns **void** automatically synchronized promise through #recorder
2018
-
2019
- ### setGeoLocation
2020
-
2021
- Set the current geo location
2022
-
2023
- ```js
2024
- I.setGeoLocation(121.21, 11.56);
2025
- I.setGeoLocation(121.21, 11.56, 10);
2026
- ```
2027
-
2028
- #### Parameters
2029
-
2030
- - `latitude` **[number][22]** to set.
2031
- - `longitude` **[number][22]** to set
2032
- - `altitude` **[number][22]?** (optional, null by default) to set
2033
-
2034
- Returns **void** automatically synchronized promise through #recorder
2035
-
2036
- ### switchTo
2037
-
2038
- Switches frame or in case of null locator reverts to parent.
2039
-
2040
- ```js
2041
- I.switchTo('iframe'); // switch to first iframe
2042
- I.switchTo(); // switch back to main page
2043
- ```
2044
-
2045
- #### Parameters
2046
-
2047
- - `locator` **([string][17]? | [object][16])** (optional, `null` by default) element located by CSS|XPath|strict locator.
2048
-
2049
- Returns **void** automatically synchronized promise through #recorder
2050
-
2051
- ### switchToNextTab
2052
-
2053
- Switch focus to a particular tab by its number. It waits tabs loading and then switch tab.
2054
-
2055
- ```js
2056
- I.switchToNextTab();
2057
- I.switchToNextTab(2);
2058
- ```
2059
-
2060
- #### Parameters
2061
-
2062
- - `num` **[number][22]?** (optional) number of tabs to switch forward, default: 1.
2063
- - `sec` **([number][22] | null)?** (optional) time in seconds to wait.
2064
-
2065
- Returns **void** automatically synchronized promise through #recorder
2066
-
2067
- ### switchToPreviousTab
2068
-
2069
- Switch focus to a particular tab by its number. It waits tabs loading and then switch tab.
2070
-
2071
- ```js
2072
- I.switchToPreviousTab();
2073
- I.switchToPreviousTab(2);
2074
- ```
2075
-
2076
- #### Parameters
2077
-
2078
- - `num` **[number][22]?** (optional) number of tabs to switch backward, default: 1.
2079
- - `sec` **[number][22]??** (optional) time in seconds to wait.
2080
-
2081
- Returns **void** automatically synchronized promise through #recorder
2082
-
2083
- ### switchToWindow
2084
-
2085
- Switch to the window with a specified handle.
2086
-
2087
- ```js
2088
- const windows = await I.grabAllWindowHandles();
2089
- // ... do something
2090
- await I.switchToWindow( windows[0] );
2091
-
2092
- const window = await I.grabCurrentWindowHandle();
2093
- // ... do something
2094
- await I.switchToWindow( window );
2095
- ```
2096
-
2097
- #### Parameters
2098
-
2099
- - `window` **[string][17]** name of window handle.
2100
-
2101
- ### type
2102
-
2103
- Types out the given text into an active field.
2104
- To slow down typing use a second parameter, to set interval between key presses.
2105
- _Note:_ Should be used when [`fillField`][30] is not an option.
2106
-
2107
- ```js
2108
- // passing in a string
2109
- I.type('Type this out.');
2110
-
2111
- // typing values with a 100ms interval
2112
- I.type('4141555311111111', 100);
2113
-
2114
- // passing in an array
2115
- I.type(['T', 'E', 'X', 'T']);
2116
-
2117
- // passing a secret
2118
- I.type(secret('123456'));
2119
- ```
2120
-
2121
- #### Parameters
2122
-
2123
- - `keys`
2124
- - `delay` **[number][22]?** (optional) delay in ms between key presses
2125
- - `key` **([string][17] | [Array][28]&lt;[string][17]>)** or array of keys to type.
2126
-
2127
- Returns **void** automatically synchronized promise through #recorder
2128
-
2129
- ### uncheckOption
2130
-
2131
- Appium: not tested
2132
- Unselects a checkbox or radio button.
2133
- Element is located by label or name or CSS or XPath.
2134
-
2135
- The second parameter is a context (CSS or XPath locator) to narrow the search.
2136
-
2137
- ```js
2138
- I.uncheckOption('#agree');
2139
- I.uncheckOption('I Agree to Terms and Conditions');
2140
- I.uncheckOption('agree', '//form');
2141
- ```
2142
-
2143
- #### Parameters
2144
-
2145
- - `field` **([string][17] | [object][16])** checkbox located by label | name | CSS | XPath | strict locator.
2146
- - `context` **([string][17]? | [object][16])** (optional, `null` by default) element located by CSS | XPath | strict locator.
2147
-
2148
- Returns **void** automatically synchronized promise through #recorder
2149
-
2150
- ### useWebDriverTo
2151
-
2152
- Use [webdriverio][35] API inside a test.
2153
-
2154
- First argument is a description of an action.
2155
- Second argument is async function that gets this helper as parameter.
2156
-
2157
- { [`browser`][35]) } object from WebDriver API is available.
2158
-
2159
- ```js
2160
- I.useWebDriverTo('open multiple windows', async ({ browser }) {
2161
- // create new window
2162
- await browser.newWindow('https://webdriver.io');
2163
- });
2164
- ```
2165
-
2166
- #### Parameters
2167
-
2168
- - `description` **[string][17]** used to show in logs.
2169
- - `fn` **[function][24]** async functuion that executed with WebDriver helper as argument
2170
-
2171
- ### wait
2172
-
2173
- Pauses execution for a number of seconds.
2174
-
2175
- ```js
2176
- I.wait(2); // wait 2 secs
2177
- ```
2178
-
2179
- #### Parameters
2180
-
2181
- - `sec` **[number][22]** number of second to wait.
2182
-
2183
- Returns **void** automatically synchronized promise through #recorder
2184
-
2185
- ### waitForClickable
2186
-
2187
- Waits for element to be clickable (by default waits for 1sec).
2188
- Element can be located by CSS or XPath.
2189
-
2190
- ```js
2191
- I.waitForClickable('.btn.continue');
2192
- I.waitForClickable('.btn.continue', 5); // wait for 5 secs
2193
- ```
2194
-
2195
- #### Parameters
2196
-
2197
- - `locator` **([string][17] | [object][16])** element located by CSS|XPath|strict locator.
2198
- - `waitTimeout`
2199
- - `sec` **[number][22]?** (optional, `1` by default) time in seconds to wait
2200
-
2201
- Returns **void** automatically synchronized promise through #recorder
2202
-
2203
- ### waitForDetached
2204
-
2205
- Waits for an element to become not attached to the DOM on a page (by default waits for 1sec).
2206
- Element can be located by CSS or XPath.
2207
-
2208
- ```js
2209
- I.waitForDetached('#popup');
2210
- ```
2211
-
2212
- #### Parameters
2213
-
2214
- - `locator` **([string][17] | [object][16])** element located by CSS|XPath|strict locator.
2215
- - `sec` **[number][22]** (optional, `1` by default) time in seconds to wait
2216
-
2217
- Returns **void** automatically synchronized promise through #recorder
2218
-
2219
- ### waitForElement
2220
-
2221
- Waits for element to be present on page (by default waits for 1sec).
2222
- Element can be located by CSS or XPath.
2223
-
2224
- ```js
2225
- I.waitForElement('.btn.continue');
2226
- I.waitForElement('.btn.continue', 5); // wait for 5 secs
2227
- ```
2228
-
2229
- #### Parameters
2230
-
2231
- - `locator` **([string][17] | [object][16])** element located by CSS|XPath|strict locator.
2232
- - `sec` **[number][22]?** (optional, `1` by default) time in seconds to wait
2233
-
2234
- Returns **void** automatically synchronized promise through #recorder
2235
-
2236
- ### waitForEnabled
2237
-
2238
- Waits for element to become enabled (by default waits for 1sec).
2239
- Element can be located by CSS or XPath.
2240
-
2241
- #### Parameters
2242
-
2243
- - `locator` **([string][17] | [object][16])** element located by CSS|XPath|strict locator.
2244
- - `sec` **[number][22]** (optional) time in seconds to wait, 1 by default.
2245
-
2246
- Returns **void** automatically synchronized promise through #recorder
2247
-
2248
- ### waitForFunction
2249
-
2250
- Waits for a function to return true (waits for 1 sec by default).
2251
- Running in browser context.
2252
-
2253
- ```js
2254
- I.waitForFunction(fn[, [args[, timeout]])
2255
- ```
2256
-
2257
- ```js
2258
- I.waitForFunction(() => window.requests == 0);
2259
- I.waitForFunction(() => window.requests == 0, 5); // waits for 5 sec
2260
- I.waitForFunction((count) => window.requests == count, [3], 5) // pass args and wait for 5 sec
2261
- ```
2262
-
2263
- #### Parameters
2264
-
2265
- - `fn` **([string][17] | [function][24])** to be executed in browser context.
2266
- - `argsOrSec` **([Array][28]&lt;any> | [number][22])?** (optional, `1` by default) arguments for function or seconds.
2267
- - `sec` **[number][22]?** (optional, `1` by default) time in seconds to wait
2268
-
2269
- Returns **void** automatically synchronized promise through #recorder
2270
-
2271
- ### waitForInvisible
2272
-
2273
- Waits for an element to be removed or become invisible on a page (by default waits for 1sec).
2274
- Element can be located by CSS or XPath.
2275
-
2276
- ```js
2277
- I.waitForInvisible('#popup');
2278
- ```
2279
-
2280
- #### Parameters
2281
-
2282
- - `locator` **([string][17] | [object][16])** element located by CSS|XPath|strict locator.
2283
- - `sec` **[number][22]** (optional, `1` by default) time in seconds to wait
2284
-
2285
- Returns **void** automatically synchronized promise through #recorder
2286
-
2287
- ### waitForText
2288
-
2289
- Waits for a text to appear (by default waits for 1sec).
2290
- Element can be located by CSS or XPath.
2291
- Narrow down search results by providing context.
2292
-
2293
- ```js
2294
- I.waitForText('Thank you, form has been submitted');
2295
- I.waitForText('Thank you, form has been submitted', 5, '#modal');
2296
- ```
2297
-
2298
- #### Parameters
2299
-
2300
- - `text` **[string][17]** to wait for.
2301
- - `sec` **[number][22]** (optional, `1` by default) time in seconds to wait
2302
- - `context` **([string][17] | [object][16])?** (optional) element located by CSS|XPath|strict locator.
2303
-
2304
- Returns **void** automatically synchronized promise through #recorder
2305
-
2306
- ### waitForValue
2307
-
2308
- Waits for the specified value to be in value attribute.
2309
-
2310
- ```js
2311
- I.waitForValue('//input', "GoodValue");
2312
- ```
2313
-
2314
- #### Parameters
2315
-
2316
- - `field` **([string][17] | [object][16])** input field.
2317
- - `value` **[string][17]** expected value.
2318
- - `sec` **[number][22]** (optional, `1` by default) time in seconds to wait
2319
-
2320
- Returns **void** automatically synchronized promise through #recorder
2321
-
2322
- ### waitForVisible
2323
-
2324
- Waits for an element to become visible on a page (by default waits for 1sec).
2325
- Element can be located by CSS or XPath.
2326
-
2327
- ```js
2328
- I.waitForVisible('#popup');
2329
- ```
2330
-
2331
- #### Parameters
2332
-
2333
- - `locator` **([string][17] | [object][16])** element located by CSS|XPath|strict locator.
2334
- - `sec` **[number][22]** (optional, `1` by default) time in seconds to wait
2335
-
2336
- Returns **void** automatically synchronized promise through #recorder
2337
-
2338
- ### waitInUrl
2339
-
2340
- Waiting for the part of the URL to match the expected. Useful for SPA to understand that page was changed.
2341
-
2342
- ```js
2343
- I.waitInUrl('/info', 2);
2344
- ```
2345
-
2346
- #### Parameters
2347
-
2348
- - `urlPart` **[string][17]** value to check.
2349
- - `sec` **[number][22]** (optional, `1` by default) time in seconds to wait
2350
-
2351
- Returns **void** automatically synchronized promise through #recorder
2352
-
2353
- ### waitNumberOfVisibleElements
2354
-
2355
- Waits for a specified number of elements on the page.
2356
-
2357
- ```js
2358
- I.waitNumberOfVisibleElements('a', 3);
2359
- ```
2360
-
2361
- #### Parameters
2362
-
2363
- - `locator` **([string][17] | [object][16])** element located by CSS|XPath|strict locator.
2364
- - `num` **[number][22]** number of elements.
2365
- - `sec` **[number][22]** (optional, `1` by default) time in seconds to wait
2366
-
2367
- Returns **void** automatically synchronized promise through #recorder
2368
-
2369
- ### waitToHide
2370
-
2371
- Waits for an element to hide (by default waits for 1sec).
2372
- Element can be located by CSS or XPath.
2373
-
2374
- ```js
2375
- I.waitToHide('#popup');
2376
- ```
2377
-
2378
- #### Parameters
2379
-
2380
- - `locator` **([string][17] | [object][16])** element located by CSS|XPath|strict locator.
2381
- - `sec` **[number][22]** (optional, `1` by default) time in seconds to wait
2382
-
2383
- Returns **void** automatically synchronized promise through #recorder
2384
-
2385
- ### waitUrlEquals
2386
-
2387
- Waits for the entire URL to match the expected
2388
-
2389
- ```js
2390
- I.waitUrlEquals('/info', 2);
2391
- I.waitUrlEquals('http://127.0.0.1:8000/info');
2392
- ```
2393
-
2394
- #### Parameters
2395
-
2396
- - `urlPart` **[string][17]** value to check.
2397
- - `sec` **[number][22]** (optional, `1` by default) time in seconds to wait
2398
-
2399
- Returns **void** automatically synchronized promise through #recorder
2400
-
2401
- [1]: http://webdriver.io/
2402
-
2403
- [2]: https://codecept.io/webdriver/#testing-with-webdriver
2404
-
2405
- [3]: http://webdriver.io/guide/getstarted/configuration.html
2406
-
2407
- [4]: https://seleniumhq.github.io/selenium/docs/api/rb/Selenium/WebDriver/IE/Options.html
2408
-
2409
- [5]: https://aerokube.com/selenoid/latest/
2410
-
2411
- [6]: https://github.com/SeleniumHQ/selenium/wiki/DesiredCapabilities
2412
-
2413
- [7]: http://webdriver.io/guide/usage/cloudservices.html
2414
-
2415
- [8]: https://webdriver.io/docs/sauce-service.html
2416
-
2417
- [9]: https://github.com/puneet0191/codeceptjs-saucehelper/
2418
-
2419
- [10]: https://webdriver.io/docs/browserstack-service.html
2420
-
2421
- [11]: https://github.com/PeterNgTr/codeceptjs-bshelper
2422
-
2423
- [12]: https://github.com/testingbot/codeceptjs-tbhelper
2424
-
2425
- [13]: https://webdriver.io/docs/testingbot-service.html
2426
-
2427
- [14]: https://github.com/PeterNgTr/codeceptjs-applitoolshelper
2428
-
2429
- [15]: http://webdriver.io/guide/usage/multiremote.html
2430
-
2431
- [16]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
2432
-
2433
- [17]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
2434
-
2435
- [18]: http://jster.net/category/windows-modals-popups
2436
-
2437
- [19]: https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus
2438
-
2439
- [20]: https://playwright.dev/docs/api/class-locator#locator-blur
2440
-
2441
- [21]: https://webdriver.io/docs/timeouts.html
2442
-
2443
- [22]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
2444
-
2445
- [23]: https://vuejs.org/v2/api/#Vue-nextTick
2446
-
2447
- [24]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function
2448
-
2449
- [25]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise
2450
-
2451
- [26]: http://webdriver.io/api/protocol/execute.html
2452
-
2453
- [27]: https://playwright.dev/docs/api/class-locator#locator-focus
2454
-
2455
- [28]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array
2456
-
2457
- [29]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined
2458
-
2459
- [30]: #fillfield
2460
-
2461
- [31]: #click
2462
-
2463
- [32]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
2464
-
2465
- [33]: https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView
2466
-
2467
- [34]: https://code.google.com/p/selenium/wiki/JsonWireProtocol#Cookie_JSON_Object
2468
-
2469
- [35]: https://webdriver.io/docs/api.html
2470
-
2471
- [36]: http://codecept.io/acceptance/#smartwait
2472
-
2473
- [37]: http://webdriver.io/docs/timeouts.html