codeceptjs 3.4.1 → 3.5.1-2.beta.7

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