codeceptjs 4.0.0-rc.17 → 4.0.0-rc.19

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