codeceptjs 4.0.0-rc.2 → 4.0.0-rc.20

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