codeceptjs 4.0.2-beta.9 → 4.0.2

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