codeceptjs 3.5.0 → 3.5.1-2.beta.7

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