codeceptjs 3.5.9 → 3.5.11

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 (52) hide show
  1. package/README.md +14 -16
  2. package/docs/build/Appium.js +49 -49
  3. package/docs/build/Expect.js +33 -33
  4. package/docs/build/Nightmare.js +50 -50
  5. package/docs/build/Playwright.js +239 -133
  6. package/docs/build/Protractor.js +59 -59
  7. package/docs/build/Puppeteer.js +127 -107
  8. package/docs/build/TestCafe.js +48 -48
  9. package/docs/build/WebDriver.js +112 -93
  10. package/docs/helpers/Appium.md +3 -3
  11. package/docs/helpers/Expect.md +33 -33
  12. package/docs/helpers/Playwright.md +431 -325
  13. package/docs/helpers/Puppeteer.md +50 -24
  14. package/docs/helpers/WebDriver.md +41 -13
  15. package/docs/internal-api.md +1 -0
  16. package/docs/parallel.md +114 -2
  17. package/docs/plugins.md +7 -5
  18. package/docs/react.md +2 -1
  19. package/docs/vue.md +22 -0
  20. package/docs/webapi/grabWebElement.mustache +9 -0
  21. package/docs/webapi/grabWebElements.mustache +9 -0
  22. package/docs/webapi/scrollIntoView.mustache +1 -1
  23. package/lib/ai.js +12 -3
  24. package/lib/colorUtils.js +10 -0
  25. package/lib/command/run-multiple.js +1 -1
  26. package/lib/command/run-workers.js +30 -4
  27. package/lib/command/workers/runTests.js +39 -0
  28. package/lib/event.js +2 -0
  29. package/lib/helper/Appium.js +13 -13
  30. package/lib/helper/Expect.js +33 -33
  31. package/lib/helper/Playwright.js +125 -37
  32. package/lib/helper/Puppeteer.js +49 -38
  33. package/lib/helper/WebDriver.js +29 -19
  34. package/lib/helper/extras/PlaywrightReactVueLocator.js +38 -0
  35. package/lib/html.js +3 -3
  36. package/lib/interfaces/gherkin.js +8 -1
  37. package/lib/interfaces/scenarioConfig.js +1 -0
  38. package/lib/locator.js +2 -2
  39. package/lib/pause.js +6 -3
  40. package/lib/plugin/autoLogin.js +4 -2
  41. package/lib/plugin/heal.js +40 -7
  42. package/lib/plugin/retryFailedStep.js +6 -1
  43. package/lib/plugin/stepByStepReport.js +2 -2
  44. package/lib/plugin/tryTo.js +5 -4
  45. package/lib/recorder.js +12 -5
  46. package/lib/ui.js +1 -0
  47. package/lib/workers.js +2 -0
  48. package/package.json +28 -25
  49. package/typings/index.d.ts +1 -1
  50. package/typings/promiseBasedTypes.d.ts +195 -76
  51. package/typings/types.d.ts +191 -145
  52. package/lib/helper/extras/PlaywrightReact.js +0 -9
@@ -458,7 +458,7 @@ declare namespace CodeceptJS {
458
458
  * Switch to the specified context.
459
459
  * @param context - the context to switch to
460
460
  */
461
- _switchToContext(context: any): void;
461
+ switchToContext(context: any): void;
462
462
  /**
463
463
  * Switches to web context.
464
464
  * If no context is provided switches to the first detected web context
@@ -749,7 +749,7 @@ declare namespace CodeceptJS {
749
749
  * ```js
750
750
  * I.closeApp();
751
751
  * ```
752
- * @returns Appium: support only iOS
752
+ * @returns Appium: support both Android and iOS
753
753
  */
754
754
  closeApp(): Promise<void>;
755
755
  /**
@@ -980,13 +980,13 @@ declare namespace CodeceptJS {
980
980
  * I.scrollIntoView('#submit', { behavior: "smooth", block: "center", inline: "center" });
981
981
  * ```
982
982
  * @param locator - located by CSS|XPath|strict locator.
983
- * @param scrollIntoViewOptions - see https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView.
983
+ * @param scrollIntoViewOptions - either alignToTop=true|false or scrollIntoViewOptions. See https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView.
984
984
  * @returns automatically synchronized promise through #recorder
985
985
  *
986
986
  *
987
987
  * Supported only for web testing
988
988
  */
989
- scrollIntoView(locator: LocatorOrString, scrollIntoViewOptions: ScrollIntoViewOptions): void;
989
+ scrollIntoView(locator: LocatorOrString, scrollIntoViewOptions: ScrollIntoViewOptions | boolean): void;
990
990
  /**
991
991
  * Verifies that the specified checkbox is checked.
992
992
  *
@@ -1131,7 +1131,7 @@ declare namespace CodeceptJS {
1131
1131
  * {
1132
1132
  * helpers: {
1133
1133
  * Playwright: {...},
1134
- * ExpectHelper: {},
1134
+ * Expect: {},
1135
1135
  * }
1136
1136
  * }
1137
1137
  * ```
@@ -1139,57 +1139,51 @@ declare namespace CodeceptJS {
1139
1139
  * ## Methods
1140
1140
  */
1141
1141
  class ExpectHelper {
1142
- expectEqual(actualValue: any, expectedValue: any, customErrorMsg: any): void;
1143
- expectNotEqual(actualValue: any, expectedValue: any, customErrorMsg: any): void;
1144
- expectDeepEqual(actualValue: any, expectedValue: any, customErrorMsg: any): void;
1145
- expectNotDeepEqual(actualValue: any, expectedValue: any, customErrorMsg: any): void;
1146
- expectContain(actualValue: any, expectedValueToContain: any, customErrorMsg: any): void;
1147
- expectNotContain(actualValue: any, expectedValueToNotContain: any, customErrorMsg: any): void;
1148
- expectStartsWith(actualValue: any, expectedValueToStartWith: any, customErrorMsg: any): void;
1149
- expectNotStartsWith(actualValue: any, expectedValueToNotStartWith: any, customErrorMsg: any): void;
1150
- expectEndsWith(actualValue: any, expectedValueToEndWith: any, customErrorMsg: any): void;
1151
- expectNotEndsWith(actualValue: any, expectedValueToNotEndWith: any, customErrorMsg: any): void;
1152
- expectJsonSchema(targetData: any, jsonSchema: any, customErrorMsg: any): void;
1142
+ expectEqual(actualValue: any, expectedValue: any, customErrorMsg?: any): void;
1143
+ expectNotEqual(actualValue: any, expectedValue: any, customErrorMsg?: any): void;
1144
+ expectDeepEqual(actualValue: any, expectedValue: any, customErrorMsg?: any): void;
1145
+ expectNotDeepEqual(actualValue: any, expectedValue: any, customErrorMsg?: any): void;
1146
+ expectContain(actualValue: any, expectedValueToContain: any, customErrorMsg?: any): void;
1147
+ expectNotContain(actualValue: any, expectedValueToNotContain: any, customErrorMsg?: any): void;
1148
+ expectStartsWith(actualValue: any, expectedValueToStartWith: any, customErrorMsg?: any): void;
1149
+ expectNotStartsWith(actualValue: any, expectedValueToNotStartWith: any, customErrorMsg?: any): void;
1150
+ expectEndsWith(actualValue: any, expectedValueToEndWith: any, customErrorMsg?: any): void;
1151
+ expectNotEndsWith(actualValue: any, expectedValueToNotEndWith: any, customErrorMsg?: any): void;
1152
+ expectJsonSchema(targetData: any, jsonSchema: any, customErrorMsg?: any): void;
1153
1153
  /**
1154
1154
  * @param ajvOptions - Pass AJV options
1155
1155
  */
1156
- expectJsonSchemaUsingAJV(targetData: any, jsonSchema: any, customErrorMsg: any, ajvOptions: any): void;
1157
- expectHasProperty(targetData: any, propertyName: any, customErrorMsg: any): void;
1158
- expectHasAProperty(targetData: any, propertyName: any, customErrorMsg: any): void;
1159
- expectToBeA(targetData: any, type: any, customErrorMsg: any): void;
1160
- expectToBeAn(targetData: any, type: any, customErrorMsg: any): void;
1161
- expectMatchRegex(targetData: any, regex: any, customErrorMsg: any): void;
1162
- expectLengthOf(targetData: any, length: any, customErrorMsg: any): void;
1163
- expectEmpty(targetData: any, customErrorMsg: any): void;
1164
- expectTrue(targetData: any, customErrorMsg: any): void;
1165
- expectFalse(targetData: any, customErrorMsg: any): void;
1166
- /**
1167
- * @param aboveThan - number | Date
1168
- */
1169
- expectAbove(targetData: any, aboveThan: any, customErrorMsg: any): void;
1170
- /**
1171
- * @param belowThan - number | Date
1172
- */
1173
- expectBelow(targetData: any, belowThan: any, customErrorMsg: any): void;
1174
- expectLengthAboveThan(targetData: any, lengthAboveThan: any, customErrorMsg: any): void;
1175
- expectLengthBelowThan(targetData: any, lengthBelowThan: any, customErrorMsg: any): void;
1176
- expectEqualIgnoreCase(actualValue: any, expectedValue: any, customErrorMsg: any): void;
1156
+ expectJsonSchemaUsingAJV(targetData: any, jsonSchema: any, customErrorMsg?: any, ajvOptions: any): void;
1157
+ expectHasProperty(targetData: any, propertyName: any, customErrorMsg?: any): void;
1158
+ expectHasAProperty(targetData: any, propertyName: any, customErrorMsg?: any): void;
1159
+ expectToBeA(targetData: any, type: any, customErrorMsg?: any): void;
1160
+ expectToBeAn(targetData: any, type: any, customErrorMsg?: any): void;
1161
+ expectMatchRegex(targetData: any, regex: any, customErrorMsg?: any): void;
1162
+ expectLengthOf(targetData: any, length: any, customErrorMsg?: any): void;
1163
+ expectEmpty(targetData: any, customErrorMsg?: any): void;
1164
+ expectTrue(targetData: any, customErrorMsg?: any): void;
1165
+ expectFalse(targetData: any, customErrorMsg?: any): void;
1166
+ expectAbove(targetData: any, aboveThan: any, customErrorMsg?: any): void;
1167
+ expectBelow(targetData: any, belowThan: any, customErrorMsg?: any): void;
1168
+ expectLengthAboveThan(targetData: any, lengthAboveThan: any, customErrorMsg?: any): void;
1169
+ expectLengthBelowThan(targetData: any, lengthBelowThan: any, customErrorMsg?: any): void;
1170
+ expectEqualIgnoreCase(actualValue: any, expectedValue: any, customErrorMsg?: any): void;
1177
1171
  /**
1178
1172
  * expects members of two arrays are deeply equal
1179
1173
  */
1180
- expectDeepMembers(actualValue: any, expectedValue: any, customErrorMsg: any): void;
1174
+ expectDeepMembers(actualValue: any, expectedValue: any, customErrorMsg?: any): void;
1181
1175
  /**
1182
1176
  * expects an array to be a superset of another array
1183
1177
  */
1184
- expectDeepIncludeMembers(superset: any, set: any, customErrorMsg: any): void;
1178
+ expectDeepIncludeMembers(superset: any, set: any, customErrorMsg?: any): void;
1185
1179
  /**
1186
1180
  * expects members of two JSON objects are deeply equal excluding some properties
1187
1181
  */
1188
- expectDeepEqualExcluding(actualValue: any, expectedValue: any, fieldsToExclude: any, customErrorMsg: any): void;
1182
+ expectDeepEqualExcluding(actualValue: any, expectedValue: any, fieldsToExclude: any, customErrorMsg?: any): void;
1189
1183
  /**
1190
1184
  * expects a JSON object matches a provided pattern
1191
1185
  */
1192
- expectMatchesPattern(actualValue: any, expectedPattern: any, customErrorMsg: any): void;
1186
+ expectMatchesPattern(actualValue: any, expectedPattern: any, customErrorMsg?: any): void;
1193
1187
  }
1194
1188
  /**
1195
1189
  * Helper for testing filesystem.
@@ -2848,6 +2842,7 @@ declare namespace CodeceptJS {
2848
2842
  * @property [ignoreHTTPSErrors] - Allows access to untrustworthy pages, e.g. to a page with an expired certificate. Default value is `false`
2849
2843
  * @property [bypassCSP] - bypass Content Security Policy or CSP
2850
2844
  * @property [highlightElement] - highlight the interacting elements. Default: false. Note: only activate under verbose mode (--verbose).
2845
+ * @property [recordHar] - record HAR and will be saved to `output/har`. See more of [HAR options](https://playwright.dev/docs/api/class-browser#browser-new-context-option-record-har).
2851
2846
  */
2852
2847
  type PlaywrightConfig = {
2853
2848
  url?: string;
@@ -2884,6 +2879,7 @@ declare namespace CodeceptJS {
2884
2879
  ignoreHTTPSErrors?: boolean;
2885
2880
  bypassCSP?: boolean;
2886
2881
  highlightElement?: boolean;
2882
+ recordHar?: any;
2887
2883
  };
2888
2884
  /**
2889
2885
  * Uses [Playwright](https://github.com/microsoft/playwright) library to run tests inside:
@@ -2929,6 +2925,21 @@ declare namespace CodeceptJS {
2929
2925
  * * `trace`: enables trace recording for failed tests; trace are saved into `output/trace` folder
2930
2926
  * * `keepTraceForPassedTests`: - save trace for passed tests
2931
2927
  *
2928
+ * #### HAR Recording Customization
2929
+ *
2930
+ * 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.
2931
+ * 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.
2932
+ * 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.
2933
+ *
2934
+ * ```
2935
+ * ...
2936
+ * recordHar: {
2937
+ * mode: 'minimal', // possible values: 'minimal'|'full'.
2938
+ * content: 'embed' // possible values: "omit"|"embed"|"attach".
2939
+ * }
2940
+ * ...
2941
+ * ```
2942
+ *
2932
2943
  * #### Example #1: Wait for 0 network connections.
2933
2944
  *
2934
2945
  * ```js
@@ -3103,7 +3114,7 @@ declare namespace CodeceptJS {
3103
3114
  * });
3104
3115
  * ```
3105
3116
  * @param description - used to show in logs.
3106
- * @param fn - async function that executed with Playwright helper as argumen
3117
+ * @param fn - async function that executed with Playwright helper as arguments
3107
3118
  */
3108
3119
  usePlaywrightTo(description: string, fn: (...params: any[]) => any): void;
3109
3120
  /**
@@ -3190,15 +3201,8 @@ declare namespace CodeceptJS {
3190
3201
  */
3191
3202
  amOnPage(url: string): void;
3192
3203
  /**
3193
- * Resize the current window to provided width and height.
3194
- * First parameter can be set to `maximize`.
3195
- * @param width - width in pixels or `maximize`.
3196
- * @param height - height in pixels.
3197
- * @returns automatically synchronized promise through #recorder
3198
- *
3199
- *
3200
3204
  * Unlike other drivers Playwright changes the size of a viewport, not the window!
3201
- * Playwright does not control the window of a browser so it can't adjust its real size.
3205
+ * Playwright does not control the window of a browser, so it can't adjust its real size.
3202
3206
  * It also can't maximize a window.
3203
3207
  *
3204
3208
  * Update configuration to change real window size on start:
@@ -3208,6 +3212,12 @@ declare namespace CodeceptJS {
3208
3212
  * // @codeceptjs/configure package must be installed
3209
3213
  * { setWindowSize } = require('@codeceptjs/configure');
3210
3214
  * ````
3215
+ *
3216
+ * Resize the current window to provided width and height.
3217
+ * First parameter can be set to `maximize`.
3218
+ * @param width - width in pixels or `maximize`.
3219
+ * @param height - height in pixels.
3220
+ * @returns automatically synchronized promise through #recorder
3211
3221
  */
3212
3222
  resizeWindow(width: number, height: number): void;
3213
3223
  /**
@@ -3283,6 +3293,13 @@ declare namespace CodeceptJS {
3283
3293
  */
3284
3294
  grabDisabledElementStatus(locator: CodeceptJS.LocatorOrString, options?: any): Promise<boolean>;
3285
3295
  /**
3296
+ * ```js
3297
+ * // specify coordinates for source position
3298
+ * I.dragAndDrop('img.src', 'img.dst', { sourcePosition: {x: 10, y: 10} })
3299
+ * ```
3300
+ *
3301
+ * > 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`
3302
+ *
3286
3303
  * Drag an item to a destination element.
3287
3304
  *
3288
3305
  * ```js
@@ -3291,13 +3308,6 @@ declare namespace CodeceptJS {
3291
3308
  * @param srcElement - located by CSS|XPath|strict locator.
3292
3309
  * @param destElement - located by CSS|XPath|strict locator.
3293
3310
  * @param [options] - [Additional options](https://playwright.dev/docs/api/class-page#page-drag-and-drop) can be passed as 3rd argument.
3294
- *
3295
- * ```js
3296
- * // specify coordinates for source position
3297
- * I.dragAndDrop('img.src', 'img.dst', { sourcePosition: {x: 10, y: 10} })
3298
- * ```
3299
- *
3300
- * > 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`
3301
3311
  * @returns automatically synchronized promise through #recorder
3302
3312
  */
3303
3313
  dragAndDrop(srcElement: LocatorOrString, destElement: LocatorOrString, options?: any): void;
@@ -3324,6 +3334,22 @@ declare namespace CodeceptJS {
3324
3334
  * @returns automatically synchronized promise through #recorder
3325
3335
  */
3326
3336
  refreshPage(): void;
3337
+ /**
3338
+ * Replaying from HAR
3339
+ *
3340
+ * ```js
3341
+ * // Replay API requests from HAR.
3342
+ * // Either use a matching response from the HAR,
3343
+ * // or abort the request if nothing matches.
3344
+ * I.replayFromHar('./output/har/something.har', { url: "*\/**\/api/v1/fruits" });
3345
+ * I.amOnPage('https://demo.playwright.dev/api-mocking');
3346
+ * I.see('CodeceptJS');
3347
+ * ```
3348
+ * @param harFilePath - Path to recorded HAR file
3349
+ * @param [opts] - [Options for replaying from HAR](https://playwright.dev/docs/api/class-page#page-route-from-har)
3350
+ * @returns Promise<void>
3351
+ */
3352
+ replayFromHar(harFilePath: string, opts?: any): any;
3327
3353
  /**
3328
3354
  * Scroll page to the top.
3329
3355
  *
@@ -3449,6 +3475,28 @@ declare namespace CodeceptJS {
3449
3475
  * ```
3450
3476
  */
3451
3477
  _locateFields(): void;
3478
+ /**
3479
+ * Grab WebElements for given locator
3480
+ * Resumes test execution, so **should be used inside an async function with `await`** operator.
3481
+ *
3482
+ * ```js
3483
+ * const webElements = await I.grabWebElements('#button');
3484
+ * ```
3485
+ * @param locator - element located by CSS|XPath|strict locator.
3486
+ * @returns WebElement of being used Web helper
3487
+ */
3488
+ grabWebElements(locator: CodeceptJS.LocatorOrString): Promise<any>;
3489
+ /**
3490
+ * Grab WebElement for given locator
3491
+ * Resumes test execution, so **should be used inside an async function with `await`** operator.
3492
+ *
3493
+ * ```js
3494
+ * const webElement = await I.grabWebElement('#button');
3495
+ * ```
3496
+ * @param locator - element located by CSS|XPath|strict locator.
3497
+ * @returns WebElement of being used Web helper
3498
+ */
3499
+ grabWebElement(locator: CodeceptJS.LocatorOrString): Promise<any>;
3452
3500
  /**
3453
3501
  * Switch focus to a particular tab by its number. It waits tabs loading and then switch tab
3454
3502
  *
@@ -3588,12 +3636,7 @@ declare namespace CodeceptJS {
3588
3636
  * // using strict locator
3589
3637
  * I.click({css: 'nav a.login'});
3590
3638
  * ```
3591
- * @param locator - clickable link or button located by text, or any element located by CSS|XPath|strict locator.
3592
- * @param [context = null] - (optional, `null` by default) element to search in CSS|XPath|Strict locator.
3593
- * @param [options] - [Additional options](https://playwright.dev/docs/api/class-page#page-click) for click available as 3rd argument.
3594
- *
3595
- * Examples:
3596
- *
3639
+ * @example
3597
3640
  * ```js
3598
3641
  * // click on element at position
3599
3642
  * I.click('canvas', '.model', { position: { x: 20, y: 40 } })
@@ -3601,6 +3644,9 @@ declare namespace CodeceptJS {
3601
3644
  * // make ctrl-click
3602
3645
  * I.click('.edit', null, { modifiers: ['Ctrl'] } )
3603
3646
  * ```
3647
+ * @param locator - clickable link or button located by text, or any element located by CSS|XPath|strict locator.
3648
+ * @param [context = null] - (optional, `null` by default) element to search in CSS|XPath|Strict locator.
3649
+ * @param [options] - [Additional options](https://playwright.dev/docs/api/class-page#page-click) for click available as 3rd argument.
3604
3650
  * @returns automatically synchronized promise through #recorder
3605
3651
  */
3606
3652
  click(locator: CodeceptJS.LocatorOrString, context?: CodeceptJS.LocatorOrString | null, options?: any): void;
@@ -3670,6 +3716,16 @@ declare namespace CodeceptJS {
3670
3716
  */
3671
3717
  rightClick(locator: CodeceptJS.LocatorOrString, context?: CodeceptJS.LocatorOrString): void;
3672
3718
  /**
3719
+ * [Additional options](https://playwright.dev/docs/api/class-elementhandle#element-handle-check) for check available as 3rd argument.
3720
+ *
3721
+ * Examples:
3722
+ *
3723
+ * ```js
3724
+ * // click on element at position
3725
+ * I.checkOption('Agree', '.signup', { position: { x: 5, y: 5 } })
3726
+ * ```
3727
+ * > ⚠️ To avoid flakiness, option `force: true` is set by default
3728
+ *
3673
3729
  * Selects a checkbox or radio button.
3674
3730
  * Element is located by label or name or CSS or XPath.
3675
3731
  *
@@ -3683,20 +3739,19 @@ declare namespace CodeceptJS {
3683
3739
  * @param field - checkbox located by label | name | CSS | XPath | strict locator.
3684
3740
  * @param [context = null] - (optional, `null` by default) element located by CSS | XPath | strict locator.
3685
3741
  * @returns automatically synchronized promise through #recorder
3686
- *
3687
- *
3688
- * [Additional options](https://playwright.dev/docs/api/class-elementhandle#element-handle-check) for check available as 3rd argument.
3742
+ */
3743
+ checkOption(field: CodeceptJS.LocatorOrString, context?: CodeceptJS.LocatorOrString): void;
3744
+ /**
3745
+ * [Additional options](https://playwright.dev/docs/api/class-elementhandle#element-handle-uncheck) for uncheck available as 3rd argument.
3689
3746
  *
3690
3747
  * Examples:
3691
3748
  *
3692
3749
  * ```js
3693
3750
  * // click on element at position
3694
- * I.checkOption('Agree', '.signup', { position: { x: 5, y: 5 } })
3751
+ * I.uncheckOption('Agree', '.signup', { position: { x: 5, y: 5 } })
3695
3752
  * ```
3696
3753
  * > ⚠️ To avoid flakiness, option `force: true` is set by default
3697
- */
3698
- checkOption(field: CodeceptJS.LocatorOrString, context?: CodeceptJS.LocatorOrString): void;
3699
- /**
3754
+ *
3700
3755
  * Unselects a checkbox or radio button.
3701
3756
  * Element is located by label or name or CSS or XPath.
3702
3757
  *
@@ -3710,17 +3765,6 @@ declare namespace CodeceptJS {
3710
3765
  * @param field - checkbox located by label | name | CSS | XPath | strict locator.
3711
3766
  * @param [context = null] - (optional, `null` by default) element located by CSS | XPath | strict locator.
3712
3767
  * @returns automatically synchronized promise through #recorder
3713
- *
3714
- *
3715
- * [Additional options](https://playwright.dev/docs/api/class-elementhandle#element-handle-uncheck) for uncheck available as 3rd argument.
3716
- *
3717
- * Examples:
3718
- *
3719
- * ```js
3720
- * // click on element at position
3721
- * I.uncheckOption('Agree', '.signup', { position: { x: 5, y: 5 } })
3722
- * ```
3723
- * > ⚠️ To avoid flakiness, option `force: true` is set by default
3724
3768
  */
3725
3769
  uncheckOption(field: CodeceptJS.LocatorOrString, context?: CodeceptJS.LocatorOrString): void;
3726
3770
  /**
@@ -3776,6 +3820,8 @@ declare namespace CodeceptJS {
3776
3820
  */
3777
3821
  pressKeyUp(key: string): void;
3778
3822
  /**
3823
+ * _Note:_ Shortcuts like `'Meta'` + `'A'` do not work on macOS ([GoogleChrome/Puppeteer#1313](https://github.com/GoogleChrome/puppeteer/issues/1313)).
3824
+ *
3779
3825
  * Presses a key in the browser (on a focused element).
3780
3826
  *
3781
3827
  * _Hint:_ For populating text field or textarea, it is recommended to use [`fillField`](#fillfield).
@@ -3835,9 +3881,6 @@ declare namespace CodeceptJS {
3835
3881
  * - `'Tab'`
3836
3882
  * @param key - key or array of keys to press.
3837
3883
  * @returns automatically synchronized promise through #recorder
3838
- *
3839
- *
3840
- * _Note:_ Shortcuts like `'Meta'` + `'A'` do not work on macOS ([GoogleChrome/Puppeteer#1313](https://github.com/GoogleChrome/puppeteer/issues/1313)).
3841
3884
  */
3842
3885
  pressKey(key: string | string[]): void;
3843
3886
  /**
@@ -4185,6 +4228,8 @@ declare namespace CodeceptJS {
4185
4228
  */
4186
4229
  dontSeeCookie(name: string): void;
4187
4230
  /**
4231
+ * Returns cookie in JSON format. If name not passed returns all cookies for this domain.
4232
+ *
4188
4233
  * Gets a cookie object by name.
4189
4234
  * If none provided gets all cookies.
4190
4235
  * Resumes test execution, so **should be used inside async function with `await`** operator.
@@ -4195,9 +4240,6 @@ declare namespace CodeceptJS {
4195
4240
  * ```
4196
4241
  * @param [name = null] - cookie name.
4197
4242
  * @returns attribute value
4198
- *
4199
- *
4200
- * Returns cookie in JSON format. If name not passed returns all cookies for this domain.
4201
4243
  */
4202
4244
  grabCookie(name?: string): any;
4203
4245
  /**
@@ -4223,8 +4265,8 @@ declare namespace CodeceptJS {
4223
4265
  * ```js
4224
4266
  * I.executeScript(({x, y}) => x + y, {x, y});
4225
4267
  * ```
4226
- * You can pass only one parameter into a function
4227
- * but you can pass in array or object.
4268
+ * You can pass only one parameter into a function,
4269
+ * or you can pass in array or object.
4228
4270
  *
4229
4271
  * ```js
4230
4272
  * I.executeScript(([x, y]) => x + y, [x, y]);
@@ -4504,6 +4546,8 @@ declare namespace CodeceptJS {
4504
4546
  */
4505
4547
  waitForElement(locator: CodeceptJS.LocatorOrString, sec?: number): void;
4506
4548
  /**
4549
+ * This method accepts [React selectors](https://codecept.io/react).
4550
+ *
4507
4551
  * Waits for an element to become visible on a page (by default waits for 1sec).
4508
4552
  * Element can be located by CSS or XPath.
4509
4553
  *
@@ -4513,9 +4557,6 @@ declare namespace CodeceptJS {
4513
4557
  * @param locator - element located by CSS|XPath|strict locator.
4514
4558
  * @param [sec = 1] - (optional, `1` by default) time in seconds to wait
4515
4559
  * @returns automatically synchronized promise through #recorder
4516
- *
4517
- *
4518
- * This method accepts [React selectors](https://codecept.io/react).
4519
4560
  */
4520
4561
  waitForVisible(locator: CodeceptJS.LocatorOrString, sec?: number): void;
4521
4562
  /**
@@ -6542,16 +6583,15 @@ declare namespace CodeceptJS {
6542
6583
  */
6543
6584
  amOnPage(url: string): void;
6544
6585
  /**
6586
+ * Unlike other drivers Puppeteer changes the size of a viewport, not the window!
6587
+ * Puppeteer does not control the window of a browser, so it can't adjust its real size.
6588
+ * It also can't maximize a window.
6589
+ *
6545
6590
  * Resize the current window to provided width and height.
6546
6591
  * First parameter can be set to `maximize`.
6547
6592
  * @param width - width in pixels or `maximize`.
6548
6593
  * @param height - height in pixels.
6549
6594
  * @returns automatically synchronized promise through #recorder
6550
- *
6551
- *
6552
- * Unlike other drivers Puppeteer changes the size of a viewport, not the window!
6553
- * Puppeteer does not control the window of a browser so it can't adjust its real size.
6554
- * It also can't maximize a window.
6555
6595
  */
6556
6596
  resizeWindow(width: number, height: number): void;
6557
6597
  /**
@@ -6730,7 +6770,7 @@ declare namespace CodeceptJS {
6730
6770
  */
6731
6771
  _locate(): void;
6732
6772
  /**
6733
- * Find a checkbox by providing human readable text:
6773
+ * Find a checkbox by providing human-readable text:
6734
6774
  * NOTE: Assumes the checkable element exists
6735
6775
  *
6736
6776
  * ```js
@@ -6739,7 +6779,7 @@ declare namespace CodeceptJS {
6739
6779
  */
6740
6780
  _locateCheckable(): void;
6741
6781
  /**
6742
- * Find a clickable element by providing human readable text:
6782
+ * Find a clickable element by providing human-readable text:
6743
6783
  *
6744
6784
  * ```js
6745
6785
  * this.helpers['Puppeteer']._locateClickable('Next page').then // ...
@@ -6747,13 +6787,24 @@ declare namespace CodeceptJS {
6747
6787
  */
6748
6788
  _locateClickable(): void;
6749
6789
  /**
6750
- * Find field elements by providing human readable text:
6790
+ * Find field elements by providing human-readable text:
6751
6791
  *
6752
6792
  * ```js
6753
6793
  * this.helpers['Puppeteer']._locateFields('Your email').then // ...
6754
6794
  * ```
6755
6795
  */
6756
6796
  _locateFields(): void;
6797
+ /**
6798
+ * Grab WebElements for given locator
6799
+ * Resumes test execution, so **should be used inside an async function with `await`** operator.
6800
+ *
6801
+ * ```js
6802
+ * const webElements = await I.grabWebElements('#button');
6803
+ * ```
6804
+ * @param locator - element located by CSS|XPath|strict locator.
6805
+ * @returns WebElement of being used Web helper
6806
+ */
6807
+ grabWebElements(locator: CodeceptJS.LocatorOrString): Promise<any>;
6757
6808
  /**
6758
6809
  * Switch focus to a particular tab by its number. It waits tabs loading and then switch tab
6759
6810
  *
@@ -6933,7 +6984,7 @@ declare namespace CodeceptJS {
6933
6984
  * Sets a directory to where save files. Allows to test file downloads.
6934
6985
  * Should be used with [FileSystem helper](https://codecept.io/helpers/FileSystem) to check that file were downloaded correctly.
6935
6986
  *
6936
- * By default files are saved to `output/downloads`.
6987
+ * By default, files are saved to `output/downloads`.
6937
6988
  * This directory is cleaned on every `handleDownloads` call, to ensure no old files are kept.
6938
6989
  *
6939
6990
  * ```js
@@ -7074,6 +7125,8 @@ declare namespace CodeceptJS {
7074
7125
  */
7075
7126
  pressKeyUp(key: string): void;
7076
7127
  /**
7128
+ * _Note:_ Shortcuts like `'Meta'` + `'A'` do not work on macOS ([GoogleChrome/puppeteer#1313](https://github.com/GoogleChrome/puppeteer/issues/1313)).
7129
+ *
7077
7130
  * Presses a key in the browser (on a focused element).
7078
7131
  *
7079
7132
  * _Hint:_ For populating text field or textarea, it is recommended to use [`fillField`](#fillfield).
@@ -7133,9 +7186,6 @@ declare namespace CodeceptJS {
7133
7186
  * - `'Tab'`
7134
7187
  * @param key - key or array of keys to press.
7135
7188
  * @returns automatically synchronized promise through #recorder
7136
- *
7137
- *
7138
- * _Note:_ Shortcuts like `'Meta'` + `'A'` do not work on macOS ([GoogleChrome/puppeteer#1313](https://github.com/GoogleChrome/puppeteer/issues/1313)).
7139
7189
  */
7140
7190
  pressKey(key: string | string[]): void;
7141
7191
  /**
@@ -7240,6 +7290,8 @@ declare namespace CodeceptJS {
7240
7290
  */
7241
7291
  dontSeeInField(field: CodeceptJS.LocatorOrString, value: CodeceptJS.StringOrSecret): void;
7242
7292
  /**
7293
+ * > ⚠ There is an [issue with file upload in Puppeteer 2.1.0 & 2.1.1](https://github.com/puppeteer/puppeteer/issues/5420), downgrade to 2.0.0 if you face it.
7294
+ *
7243
7295
  * Attaches a file to element located by label, name, CSS or XPath
7244
7296
  * Path to file is relative current codecept directory (where codecept.conf.ts or codecept.conf.js is located).
7245
7297
  * File will be uploaded to remote system (if tests are running remotely).
@@ -7251,9 +7303,6 @@ declare namespace CodeceptJS {
7251
7303
  * @param locator - field located by label|name|CSS|XPath|strict locator.
7252
7304
  * @param pathToFile - local file path relative to codecept.conf.ts or codecept.conf.js config file.
7253
7305
  * @returns automatically synchronized promise through #recorder
7254
- *
7255
- *
7256
- * > ⚠ There is an [issue with file upload in Puppeteer 2.1.0 & 2.1.1](https://github.com/puppeteer/puppeteer/issues/5420), downgrade to 2.0.0 if you face it.
7257
7306
  */
7258
7307
  attachFile(locator: CodeceptJS.LocatorOrString, pathToFile: string): void;
7259
7308
  /**
@@ -7524,6 +7573,8 @@ declare namespace CodeceptJS {
7524
7573
  */
7525
7574
  clearCookie(cookie?: string): void;
7526
7575
  /**
7576
+ * If a function returns a Promise, tt will wait for its resolution.
7577
+ *
7527
7578
  * Executes sync script on a page.
7528
7579
  * Pass arguments to function as additional parameters.
7529
7580
  * Will return execution result to a test.
@@ -7549,12 +7600,10 @@ declare namespace CodeceptJS {
7549
7600
  * @param fn - function to be executed in browser context.
7550
7601
  * @param args - to be passed to function.
7551
7602
  * @returns script return value
7552
- *
7553
- *
7554
- * If a function returns a Promise It will wait for it resolution.
7555
7603
  */
7556
7604
  executeScript(fn: string | ((...params: any[]) => any), ...args: any[]): Promise<any>;
7557
7605
  /**
7606
+ * Asynchronous scripts can also be executed with `executeScript` if a function returns a Promise.
7558
7607
  * Executes async script on page.
7559
7608
  * Provided function should execute a passed callback (as first argument) to signal it is finished.
7560
7609
  *
@@ -7578,9 +7627,6 @@ declare namespace CodeceptJS {
7578
7627
  * @param fn - function to be executed in browser context.
7579
7628
  * @param args - to be passed to function.
7580
7629
  * @returns script return value
7581
- *
7582
- *
7583
- * Asynchronous scripts can also be executed with `executeScript` if a function returns a Promise.
7584
7630
  */
7585
7631
  executeAsyncScript(fn: string | ((...params: any[]) => any), ...args: any[]): Promise<any>;
7586
7632
  /**
@@ -7865,7 +7911,7 @@ declare namespace CodeceptJS {
7865
7911
  * @returns automatically synchronized promise through #recorder
7866
7912
  *
7867
7913
  *
7868
- * This method accepts [React selectors](https://codecept.io/react).
7914
+ * {{ react }}
7869
7915
  */
7870
7916
  waitForVisible(locator: CodeceptJS.LocatorOrString, sec?: number): void;
7871
7917
  /**
@@ -7981,9 +8027,9 @@ declare namespace CodeceptJS {
7981
8027
  */
7982
8028
  waitForFunction(fn: string | ((...params: any[]) => any), argsOrSec?: any[] | number, sec?: number): void;
7983
8029
  /**
7984
- * Waits for navigation to finish. By default takes configured `waitForNavigation` option.
8030
+ * Waits for navigation to finish. By default, takes configured `waitForNavigation` option.
7985
8031
  *
7986
- * See [Pupeteer's reference](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#pagewaitfornavigationoptions)
8032
+ * See [Puppeteer's reference](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#pagewaitfornavigationoptions)
7987
8033
  */
7988
8034
  waitForNavigation(opts: any): void;
7989
8035
  /**
@@ -9620,6 +9666,17 @@ declare namespace CodeceptJS {
9620
9666
  * @param locator - element located by CSS|XPath|strict locator.
9621
9667
  */
9622
9668
  _locateFields(locator: CodeceptJS.LocatorOrString): void;
9669
+ /**
9670
+ * Grab WebElements for given locator
9671
+ * Resumes test execution, so **should be used inside an async function with `await`** operator.
9672
+ *
9673
+ * ```js
9674
+ * const webElements = await I.grabWebElements('#button');
9675
+ * ```
9676
+ * @param locator - element located by CSS|XPath|strict locator.
9677
+ * @returns WebElement of being used Web helper
9678
+ */
9679
+ grabWebElements(locator: CodeceptJS.LocatorOrString): Promise<any>;
9623
9680
  /**
9624
9681
  * Set [WebDriver timeouts](https://webdriver.io/docs/timeouts.html) in realtime.
9625
9682
  *
@@ -9843,6 +9900,8 @@ declare namespace CodeceptJS {
9843
9900
  */
9844
9901
  selectOption(select: LocatorOrString, option: string | any[]): void;
9845
9902
  /**
9903
+ * Appium: not tested
9904
+ *
9846
9905
  * Attaches a file to element located by label, name, CSS or XPath
9847
9906
  * Path to file is relative current codecept directory (where codecept.conf.ts or codecept.conf.js is located).
9848
9907
  * File will be uploaded to remote system (if tests are running remotely).
@@ -9854,11 +9913,10 @@ declare namespace CodeceptJS {
9854
9913
  * @param locator - field located by label|name|CSS|XPath|strict locator.
9855
9914
  * @param pathToFile - local file path relative to codecept.conf.ts or codecept.conf.js config file.
9856
9915
  * @returns automatically synchronized promise through #recorder
9857
- *
9858
- * Appium: not tested
9859
9916
  */
9860
9917
  attachFile(locator: CodeceptJS.LocatorOrString, pathToFile: string): void;
9861
9918
  /**
9919
+ * Appium: not tested
9862
9920
  * Selects a checkbox or radio button.
9863
9921
  * Element is located by label or name or CSS or XPath.
9864
9922
  *
@@ -9872,11 +9930,10 @@ declare namespace CodeceptJS {
9872
9930
  * @param field - checkbox located by label | name | CSS | XPath | strict locator.
9873
9931
  * @param [context = null] - (optional, `null` by default) element located by CSS | XPath | strict locator.
9874
9932
  * @returns automatically synchronized promise through #recorder
9875
- *
9876
- * Appium: not tested
9877
9933
  */
9878
9934
  checkOption(field: CodeceptJS.LocatorOrString, context?: CodeceptJS.LocatorOrString): void;
9879
9935
  /**
9936
+ * Appium: not tested
9880
9937
  * Unselects a checkbox or radio button.
9881
9938
  * Element is located by label or name or CSS or XPath.
9882
9939
  *
@@ -9890,8 +9947,6 @@ declare namespace CodeceptJS {
9890
9947
  * @param field - checkbox located by label | name | CSS | XPath | strict locator.
9891
9948
  * @param [context = null] - (optional, `null` by default) element located by CSS | XPath | strict locator.
9892
9949
  * @returns automatically synchronized promise through #recorder
9893
- *
9894
- * Appium: not tested
9895
9950
  */
9896
9951
  uncheckOption(field: CodeceptJS.LocatorOrString, context?: CodeceptJS.LocatorOrString): void;
9897
9952
  /**
@@ -10126,6 +10181,7 @@ declare namespace CodeceptJS {
10126
10181
  */
10127
10182
  dontSeeInField(field: CodeceptJS.LocatorOrString, value: CodeceptJS.StringOrSecret): void;
10128
10183
  /**
10184
+ * Appium: not tested
10129
10185
  * Verifies that the specified checkbox is checked.
10130
10186
  *
10131
10187
  * ```js
@@ -10135,11 +10191,10 @@ declare namespace CodeceptJS {
10135
10191
  * ```
10136
10192
  * @param field - located by label|name|CSS|XPath|strict locator.
10137
10193
  * @returns automatically synchronized promise through #recorder
10138
- *
10139
- * Appium: not tested
10140
10194
  */
10141
10195
  seeCheckboxIsChecked(field: CodeceptJS.LocatorOrString): void;
10142
10196
  /**
10197
+ * Appium: not tested
10143
10198
  * Verifies that the specified checkbox is not checked.
10144
10199
  *
10145
10200
  * ```js
@@ -10149,8 +10204,6 @@ declare namespace CodeceptJS {
10149
10204
  * ```
10150
10205
  * @param field - located by label|name|CSS|XPath|strict locator.
10151
10206
  * @returns automatically synchronized promise through #recorder
10152
- *
10153
- * Appium: not tested
10154
10207
  */
10155
10208
  dontSeeCheckboxIsChecked(field: CodeceptJS.LocatorOrString): void;
10156
10209
  /**
@@ -10355,6 +10408,8 @@ declare namespace CodeceptJS {
10355
10408
  */
10356
10409
  dontSeeCurrentUrlEquals(url: string): void;
10357
10410
  /**
10411
+ * Wraps [execute](http://webdriver.io/api/protocol/execute.html) command.
10412
+ *
10358
10413
  * Executes sync script on a page.
10359
10414
  * Pass arguments to function as additional parameters.
10360
10415
  * Will return execution result to a test.
@@ -10380,10 +10435,6 @@ declare namespace CodeceptJS {
10380
10435
  * @param fn - function to be executed in browser context.
10381
10436
  * @param args - to be passed to function.
10382
10437
  * @returns script return value
10383
- *
10384
- *
10385
- *
10386
- * Wraps [execute](http://webdriver.io/api/protocol/execute.html) command.
10387
10438
  */
10388
10439
  executeScript(fn: string | ((...params: any[]) => any), ...args: any[]): Promise<any>;
10389
10440
  /**
@@ -10421,10 +10472,10 @@ declare namespace CodeceptJS {
10421
10472
  * I.scrollIntoView('#submit', { behavior: "smooth", block: "center", inline: "center" });
10422
10473
  * ```
10423
10474
  * @param locator - located by CSS|XPath|strict locator.
10424
- * @param scrollIntoViewOptions - see https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView.
10475
+ * @param scrollIntoViewOptions - either alignToTop=true|false or scrollIntoViewOptions. See https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView.
10425
10476
  * @returns automatically synchronized promise through #recorder
10426
10477
  */
10427
- scrollIntoView(locator: LocatorOrString, scrollIntoViewOptions: ScrollIntoViewOptions): void;
10478
+ scrollIntoView(locator: LocatorOrString, scrollIntoViewOptions: ScrollIntoViewOptions | boolean): void;
10428
10479
  /**
10429
10480
  * Scrolls to element matched by locator.
10430
10481
  * Extra shift can be set with offsetX and offsetY options.
@@ -10480,6 +10531,7 @@ declare namespace CodeceptJS {
10480
10531
  */
10481
10532
  saveScreenshot(fileName: string, fullPage?: boolean): void;
10482
10533
  /**
10534
+ * Uses Selenium's JSON [cookie format](https://code.google.com/p/selenium/wiki/JsonWireProtocol#Cookie_JSON_Object).
10483
10535
  * Sets cookie(s).
10484
10536
  *
10485
10537
  * Can be a single cookie object or an array of cookies:
@@ -10495,11 +10547,6 @@ declare namespace CodeceptJS {
10495
10547
  * ```
10496
10548
  * @param cookie - a cookie object or array of cookie objects.
10497
10549
  * @returns automatically synchronized promise through #recorder
10498
- *
10499
- *
10500
- *
10501
- * Uses Selenium's JSON [cookie
10502
- * format](https://code.google.com/p/selenium/wiki/JsonWireProtocol#Cookie_JSON_Object).
10503
10550
  */
10504
10551
  setCookie(cookie: Cookie | Cookie[]): void;
10505
10552
  /**
@@ -10553,7 +10600,7 @@ declare namespace CodeceptJS {
10553
10600
  */
10554
10601
  acceptPopup(): void;
10555
10602
  /**
10556
- * Dismisses the active JavaScript popup, as created by window.alert|window.confirm|window.prompt.
10603
+ * Dismisses the active JavaScript popup, as created by `window.alert|window.confirm|window.prompt`.
10557
10604
  */
10558
10605
  cancelPopup(): void;
10559
10606
  /**
@@ -10598,6 +10645,8 @@ declare namespace CodeceptJS {
10598
10645
  */
10599
10646
  pressKeyUp(key: string): void;
10600
10647
  /**
10648
+ * _Note:_ In case a text field or textarea is focused be aware that some browsers do not respect active modifier when combining modifier keys with other keys.
10649
+ *
10601
10650
  * Presses a key in the browser (on a focused element).
10602
10651
  *
10603
10652
  * _Hint:_ For populating text field or textarea, it is recommended to use [`fillField`](#fillfield).
@@ -10657,9 +10706,6 @@ declare namespace CodeceptJS {
10657
10706
  * - `'Tab'`
10658
10707
  * @param key - key or array of keys to press.
10659
10708
  * @returns automatically synchronized promise through #recorder
10660
- *
10661
- *
10662
- * _Note:_ In case a text field or textarea is focused be aware that some browsers do not respect active modifier when combining modifier keys with other keys.
10663
10709
  */
10664
10710
  pressKey(key: string | string[]): void;
10665
10711
  /**
@@ -10686,13 +10732,13 @@ declare namespace CodeceptJS {
10686
10732
  */
10687
10733
  type(key: string | string[], delay?: number): void;
10688
10734
  /**
10735
+ * Appium: not tested in web, in apps doesn't work
10736
+ *
10689
10737
  * Resize the current window to provided width and height.
10690
10738
  * First parameter can be set to `maximize`.
10691
10739
  * @param width - width in pixels or `maximize`.
10692
10740
  * @param height - height in pixels.
10693
10741
  * @returns automatically synchronized promise through #recorder
10694
- *
10695
- * Appium: not tested in web, in apps doesn't work
10696
10742
  */
10697
10743
  resizeWindow(width: number, height: number): void;
10698
10744
  /**
@@ -10731,6 +10777,7 @@ declare namespace CodeceptJS {
10731
10777
  */
10732
10778
  blur(locator: CodeceptJS.LocatorOrString, options?: any): void;
10733
10779
  /**
10780
+ * Appium: not tested
10734
10781
  * Drag an item to a destination element.
10735
10782
  *
10736
10783
  * ```js
@@ -10739,8 +10786,6 @@ declare namespace CodeceptJS {
10739
10786
  * @param srcElement - located by CSS|XPath|strict locator.
10740
10787
  * @param destElement - located by CSS|XPath|strict locator.
10741
10788
  * @returns automatically synchronized promise through #recorder
10742
- *
10743
- * Appium: not tested
10744
10789
  */
10745
10790
  dragAndDrop(srcElement: LocatorOrString, destElement: LocatorOrString): void;
10746
10791
  /**
@@ -11354,6 +11399,7 @@ declare namespace CodeceptJS {
11354
11399
  const workers: {
11355
11400
  before: 'workers.before';
11356
11401
  after: 'workers.after';
11402
+ result: 'workers.result';
11357
11403
  };
11358
11404
  function emit(event: string, param?: any): void;
11359
11405
  /**