codeceptjs 4.0.2-beta.9 → 4.0.2

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