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