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

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