codeceptjs 4.0.1-beta.9 → 4.0.2-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -870,9 +870,13 @@ declare namespace CodeceptJS {
870
870
  * For buttons, the "value" attribute, "name" attribute, and inner text are searched. For links, the link text is searched.
871
871
  * For images, the "alt" attribute and inner text of any parent links are searched.
872
872
  *
873
+ * If no locator is provided, defaults to clicking the body element (`'//body'`).
874
+ *
873
875
  * The second parameter is a context (CSS or XPath locator) to narrow the search.
874
876
  *
875
877
  * ```js
878
+ * // click body element (default)
879
+ * I.click();
876
880
  * // simple link
877
881
  * I.click('Logout');
878
882
  * // button of form
@@ -886,10 +890,10 @@ declare namespace CodeceptJS {
886
890
  * // using strict locator
887
891
  * I.click({css: 'nav a.login'});
888
892
  * ```
889
- * @param locator - clickable link or button located by text, or any element located by CSS|XPath|strict locator.
893
+ * @param [locator = '//body'] - (optional, `'//body'` by default) clickable link or button located by text, or any element located by CSS|XPath|strict locator.
890
894
  * @param [context = null] - (optional, `null` by default) element to search in CSS|XPath|Strict locator.
891
895
  */
892
- click(locator: CodeceptJS.LocatorOrString, context?: CodeceptJS.LocatorOrString | null): Promise<any>;
896
+ click(locator?: CodeceptJS.LocatorOrString, context?: CodeceptJS.LocatorOrString | null): Promise<any>;
893
897
  /**
894
898
  * Verifies that the specified checkbox is not checked.
895
899
  *
@@ -1725,28 +1729,28 @@ declare namespace CodeceptJS {
1725
1729
  */
1726
1730
  seeResponseEquals(resp: any): Promise<any>;
1727
1731
  /**
1728
- * Validates JSON structure of response using [joi library](https://joi.dev).
1729
- * See [joi API](https://joi.dev/api/) for complete reference on usage.
1732
+ * Validates JSON structure of response using [Zod library](https://zod.dev).
1733
+ * See [Zod API](https://zod.dev/) for complete reference on usage.
1730
1734
  *
1731
- * Use pre-initialized joi instance by passing function callback:
1735
+ * Use pre-initialized Zod instance by passing function callback:
1732
1736
  *
1733
1737
  * ```js
1734
1738
  * // response.data is { name: 'jon', id: 1 }
1735
1739
  *
1736
- * I.seeResponseMatchesJsonSchema(joi => {
1737
- * return joi.object({
1738
- * name: joi.string(),
1739
- * id: joi.number()
1740
+ * I.seeResponseMatchesJsonSchema(z => {
1741
+ * return z.object({
1742
+ * name: z.string(),
1743
+ * id: z.number()
1740
1744
  * })
1741
1745
  * });
1742
1746
  *
1743
1747
  * // or pass a valid schema
1744
- * const joi = require('joi');
1748
+ * import { z } from 'zod';
1745
1749
  *
1746
- * I.seeResponseMatchesJsonSchema(joi.object({
1747
- * name: joi.string(),
1748
- * id: joi.number();
1749
- * });
1750
+ * I.seeResponseMatchesJsonSchema(z.object({
1751
+ * name: z.string(),
1752
+ * id: z.number()
1753
+ * }));
1750
1754
  * ```
1751
1755
  */
1752
1756
  seeResponseMatchesJsonSchema(fnOrSchema: any): Promise<any>;
@@ -2690,6 +2694,13 @@ declare namespace CodeceptJS {
2690
2694
  */
2691
2695
  grabPageScrollPosition(): Promise<PageScrollPosition>;
2692
2696
  }
2697
+ /**
2698
+ * Creates a Playwright selector engine factory for a custom locator strategy.
2699
+ * @param name - Strategy name for error messages
2700
+ * @param func - The locator function (selector, root) => Element|Element[]
2701
+ * @returns Selector engine factory
2702
+ */
2703
+ function createCustomSelectorEngine(name: string, func: (...params: any[]) => any): (...params: any[]) => any;
2693
2704
  /**
2694
2705
  * ## Configuration
2695
2706
  *
@@ -2699,7 +2710,6 @@ declare namespace CodeceptJS {
2699
2710
  * @property [show = true] - show browser window.
2700
2711
  * @property [restart = false] - restart strategy between tests. Possible values:
2701
2712
  * * 'context' or **false** - restarts [browser context](https://playwright.dev/docs/api/class-browsercontext) but keeps running browser. Recommended by Playwright team to keep tests isolated.
2702
- * * 'browser' or **true** - closes browser and opens it again between tests.
2703
2713
  * * '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
2704
2714
  * @property [timeout = 1000] - - [timeout](https://playwright.dev/docs/api/class-page#page-set-default-timeout) in ms of all Playwright actions .
2705
2715
  * @property [disableScreenshots = false] - don't save screenshot on failure.
@@ -2741,8 +2751,6 @@ declare namespace CodeceptJS {
2741
2751
  * May include session cookies, auth tokens, localStorage and (if captured with
2742
2752
  * `grabStorageState({ indexedDB: true })`) IndexedDB data; treat as sensitive and do not commit.
2743
2753
  */
2744
- // @ts-ignore
2745
- // @ts-ignore
2746
2754
  type PlaywrightConfig = {
2747
2755
  url?: string;
2748
2756
  browser?: 'chromium' | 'firefox' | 'webkit' | 'electron';
@@ -3206,20 +3214,6 @@ declare namespace CodeceptJS {
3206
3214
  * @param [options] - [Additional options](https://playwright.dev/docs/api/class-page#page-drag-and-drop) can be passed as 3rd argument.
3207
3215
  */
3208
3216
  dragAndDrop(srcElement: LocatorOrString, destElement: LocatorOrString, options?: any): Promise<any>;
3209
- /**
3210
- * Restart browser with a new context and a new page
3211
- *
3212
- * ```js
3213
- * // Restart browser and use a new timezone
3214
- * I.restartBrowser({ timezoneId: 'America/Phoenix' });
3215
- * // Open URL in a new page in changed timezone
3216
- * I.amOnPage('/');
3217
- * // Restart browser, allow reading/copying of text from/into clipboard in Chrome
3218
- * I.restartBrowser({ permissions: ['clipboard-read', 'clipboard-write'] });
3219
- * ```
3220
- * @param [contextOptions] - [Options for browser context](https://playwright.dev/docs/api/class-browser#browser-new-context) when starting new browser
3221
- */
3222
- restartBrowser(contextOptions?: any): Promise<any>;
3223
3217
  /**
3224
3218
  * Reload the current page.
3225
3219
  *
@@ -3503,9 +3497,13 @@ declare namespace CodeceptJS {
3503
3497
  * For buttons, the "value" attribute, "name" attribute, and inner text are searched. For links, the link text is searched.
3504
3498
  * For images, the "alt" attribute and inner text of any parent links are searched.
3505
3499
  *
3500
+ * If no locator is provided, defaults to clicking the body element (`'//body'`).
3501
+ *
3506
3502
  * The second parameter is a context (CSS or XPath locator) to narrow the search.
3507
3503
  *
3508
3504
  * ```js
3505
+ * // click body element (default)
3506
+ * I.click();
3509
3507
  * // simple link
3510
3508
  * I.click('Logout');
3511
3509
  * // button of form
@@ -3527,11 +3525,11 @@ declare namespace CodeceptJS {
3527
3525
  * // make ctrl-click
3528
3526
  * I.click('.edit', null, { modifiers: ['Ctrl'] } )
3529
3527
  * ```
3530
- * @param locator - clickable link or button located by text, or any element located by CSS|XPath|strict locator.
3528
+ * @param [locator = '//body'] - (optional, `'//body'` by default) clickable link or button located by text, or any element located by CSS|XPath|strict locator.
3531
3529
  * @param [context = null] - (optional, `null` by default) element to search in CSS|XPath|Strict locator.
3532
3530
  * @param [options] - [Additional options](https://playwright.dev/docs/api/class-page#page-click) for click available as 3rd argument.
3533
3531
  */
3534
- click(locator: CodeceptJS.LocatorOrString, context?: CodeceptJS.LocatorOrString | null, options?: any): Promise<any>;
3532
+ click(locator?: CodeceptJS.LocatorOrString, context?: CodeceptJS.LocatorOrString | null, options?: any): Promise<any>;
3535
3533
  /**
3536
3534
  * Clicks link and waits for navigation (deprecated)
3537
3535
  */
@@ -3594,6 +3592,23 @@ declare namespace CodeceptJS {
3594
3592
  * @param [context = null] - (optional, `null` by default) element located by CSS|XPath|strict locator.
3595
3593
  */
3596
3594
  rightClick(locator: CodeceptJS.LocatorOrString, context?: CodeceptJS.LocatorOrString): Promise<any>;
3595
+ /**
3596
+ * Performs click at specific coordinates.
3597
+ * If locator is provided, the coordinates are relative to the element.
3598
+ * If locator is not provided, the coordinates are global page coordinates.
3599
+ *
3600
+ * ```js
3601
+ * // Click at global coordinates (100, 200)
3602
+ * I.clickXY(100, 200);
3603
+ *
3604
+ * // Click at coordinates (50, 30) relative to element
3605
+ * I.clickXY('#someElement', 50, 30);
3606
+ * ```
3607
+ * @param locator - Element to click on or X coordinate if no element.
3608
+ * @param [x] - X coordinate relative to element, or Y coordinate if locator is a number.
3609
+ * @param [y] - Y coordinate relative to element.
3610
+ */
3611
+ clickXY(locator: CodeceptJS.LocatorOrString | number, x?: number, y?: number): Promise<void>;
3597
3612
  /**
3598
3613
  * [Additional options](https://playwright.dev/docs/api/class-elementhandle#element-handle-check) for check available as 3rd argument.
3599
3614
  *
@@ -4302,6 +4317,24 @@ declare namespace CodeceptJS {
4302
4317
  * @returns attribute value
4303
4318
  */
4304
4319
  grabAttributeFromAll(locator: CodeceptJS.LocatorOrString, attr: string): Promise<string[]>;
4320
+ /**
4321
+ * Retrieves the ARIA snapshot for an element using Playwright's [`locator.ariaSnapshot`](https://playwright.dev/docs/api/class-locator#locator-aria-snapshot).
4322
+ * This method returns a YAML representation of the accessibility tree that can be used for assertions.
4323
+ * If no locator is provided, it captures the snapshot of the entire page body.
4324
+ *
4325
+ * ```js
4326
+ * const snapshot = await I.grabAriaSnapshot();
4327
+ * expect(snapshot).toContain('heading "Sign up"');
4328
+ *
4329
+ * const formSnapshot = await I.grabAriaSnapshot('#login-form');
4330
+ * expect(formSnapshot).toContain('textbox "Email"');
4331
+ * ```
4332
+ *
4333
+ * [Learn more about ARIA snapshots](https://playwright.dev/docs/aria-snapshots)
4334
+ * @param [locator = '//body'] - element located by CSS|XPath|strict locator. Defaults to body element.
4335
+ * @returns YAML representation of the accessibility tree
4336
+ */
4337
+ grabAriaSnapshot(locator?: string | any): Promise<string>;
4305
4338
  /**
4306
4339
  * Saves screenshot of the specified locator to ouput folder (set in codecept.conf.ts or codecept.conf.js).
4307
4340
  * Filename is relative to output folder.
@@ -4863,6 +4896,15 @@ declare namespace CodeceptJS {
4863
4896
  */
4864
4897
  grabMetrics(): Promise<object[]>;
4865
4898
  }
4899
+ /**
4900
+ * Checks if a locator is a role locator object (e.g., {role: 'button', text: 'Submit', exact: true})
4901
+ */
4902
+ function isRoleLocatorObject(): void;
4903
+ /**
4904
+ * Handles role locator objects by converting them to Playwright's getByRole() API
4905
+ * Returns elements array if role locator, null otherwise
4906
+ */
4907
+ function handleRoleLocator(): void;
4866
4908
  /**
4867
4909
  * Protractor helper is based on [Protractor library](http://www.protractortest.org) and used for testing web applications.
4868
4910
  *
@@ -6115,6 +6157,11 @@ declare namespace CodeceptJS {
6115
6157
  */
6116
6158
  setCookie(cookie: Cookie | Cookie[]): Promise<any>;
6117
6159
  }
6160
+ /**
6161
+ * Wraps error objects that don't have a proper message property
6162
+ * This is needed for ESM compatibility with Puppeteer error handling
6163
+ */
6164
+ function wrapError(): void;
6118
6165
  /**
6119
6166
  * ## Configuration
6120
6167
  *
@@ -6142,8 +6189,6 @@ declare namespace CodeceptJS {
6142
6189
  * @property [chrome] - pass additional [Puppeteer run options](https://github.com/puppeteer/puppeteer/blob/main/docs/api/puppeteer.launchoptions.md).
6143
6190
  * @property [highlightElement] - highlight the interacting elements. Default: false. Note: only activate under verbose mode (--verbose).
6144
6191
  */
6145
- // @ts-ignore
6146
- // @ts-ignore
6147
6192
  type PuppeteerConfig = {
6148
6193
  url: string;
6149
6194
  basicAuth?: any;
@@ -6721,9 +6766,13 @@ declare namespace CodeceptJS {
6721
6766
  * For buttons, the "value" attribute, "name" attribute, and inner text are searched. For links, the link text is searched.
6722
6767
  * For images, the "alt" attribute and inner text of any parent links are searched.
6723
6768
  *
6769
+ * If no locator is provided, defaults to clicking the body element (`'//body'`).
6770
+ *
6724
6771
  * The second parameter is a context (CSS or XPath locator) to narrow the search.
6725
6772
  *
6726
6773
  * ```js
6774
+ * // click body element (default)
6775
+ * I.click();
6727
6776
  * // simple link
6728
6777
  * I.click('Logout');
6729
6778
  * // button of form
@@ -6737,10 +6786,10 @@ declare namespace CodeceptJS {
6737
6786
  * // using strict locator
6738
6787
  * I.click({css: 'nav a.login'});
6739
6788
  * ```
6740
- * @param locator - clickable link or button located by text, or any element located by CSS|XPath|strict locator.
6789
+ * @param [locator = '//body'] - (optional, `'//body'` by default) clickable link or button located by text, or any element located by CSS|XPath|strict locator.
6741
6790
  * @param [context = null] - (optional, `null` by default) element to search in CSS|XPath|Strict locator.
6742
6791
  */
6743
- click(locator: CodeceptJS.LocatorOrString, context?: CodeceptJS.LocatorOrString | null): Promise<any>;
6792
+ click(locator?: CodeceptJS.LocatorOrString, context?: CodeceptJS.LocatorOrString | null): Promise<any>;
6744
6793
  /**
6745
6794
  * Perform an emulated click on a link or a button, given by a locator.
6746
6795
  * Unlike normal click instead of sending native event, emulates a click with JavaScript.
@@ -6832,6 +6881,23 @@ declare namespace CodeceptJS {
6832
6881
  * @param [context = null] - (optional, `null` by default) element located by CSS|XPath|strict locator.
6833
6882
  */
6834
6883
  rightClick(locator: CodeceptJS.LocatorOrString, context?: CodeceptJS.LocatorOrString): Promise<any>;
6884
+ /**
6885
+ * Performs click at specific coordinates.
6886
+ * If locator is provided, the coordinates are relative to the element.
6887
+ * If locator is not provided, the coordinates are global page coordinates.
6888
+ *
6889
+ * ```js
6890
+ * // Click at global coordinates (100, 200)
6891
+ * I.clickXY(100, 200);
6892
+ *
6893
+ * // Click at coordinates (50, 30) relative to element
6894
+ * I.clickXY('#someElement', 50, 30);
6895
+ * ```
6896
+ * @param locator - Element to click on or X coordinate if no element.
6897
+ * @param [x] - X coordinate relative to element, or Y coordinate if locator is a number.
6898
+ * @param [y] - Y coordinate relative to element.
6899
+ */
6900
+ clickXY(locator: CodeceptJS.LocatorOrString | number, x?: number, y?: number): Promise<void>;
6835
6901
  /**
6836
6902
  * Selects a checkbox or radio button.
6837
6903
  * Element is located by label or name or CSS or XPath.
@@ -7988,8 +8054,6 @@ declare namespace CodeceptJS {
7988
8054
  * @property [onResponse] - an async function which can update response object.
7989
8055
  * @property [maxUploadFileSize] - set the max content file size in MB when performing api calls.
7990
8056
  */
7991
- // @ts-ignore
7992
- // @ts-ignore
7993
8057
  type RESTConfig = {
7994
8058
  endpoint?: string;
7995
8059
  prettyPrintJson?: boolean;
@@ -9118,6 +9182,11 @@ declare namespace CodeceptJS {
9118
9182
  */
9119
9183
  waitForText(text: string, sec?: number, context?: CodeceptJS.LocatorOrString): Promise<any>;
9120
9184
  }
9185
+ /**
9186
+ * Wraps error objects that don't have a proper message property
9187
+ * This is needed for ESM compatibility with Puppeteer error handling
9188
+ */
9189
+ function wrapError(): void;
9121
9190
  /**
9122
9191
  * ## Configuration
9123
9192
  *
@@ -9145,8 +9214,6 @@ declare namespace CodeceptJS {
9145
9214
  * @property [highlightElement] - highlight the interacting elements. Default: false. Note: only activate under verbose mode (--verbose).
9146
9215
  * @property [logLevel = silent] - level of logging verbosity. Default: silent. Options: trace | debug | info | warn | error | silent. More info: https://webdriver.io/docs/configuration/#loglevel
9147
9216
  */
9148
- // @ts-ignore
9149
- // @ts-ignore
9150
9217
  type WebDriverConfig = {
9151
9218
  url: string;
9152
9219
  browser: string;
@@ -9606,6 +9673,11 @@ declare namespace CodeceptJS {
9606
9673
  * @param locator - element located by CSS|XPath|strict locator.
9607
9674
  */
9608
9675
  _locateFields(locator: CodeceptJS.LocatorOrString): Promise<any>;
9676
+ /**
9677
+ * Locate elements by ARIA role using WebdriverIO accessibility selectors
9678
+ * @param locator - role locator object { role: string, text?: string, exact?: boolean }
9679
+ */
9680
+ _locateByRole(locator: any): Promise<any>;
9609
9681
  /**
9610
9682
  * Grab WebElements for given locator
9611
9683
  * Resumes test execution, so **should be used inside an async function with `await`** operator.
@@ -9658,9 +9730,13 @@ declare namespace CodeceptJS {
9658
9730
  * For buttons, the "value" attribute, "name" attribute, and inner text are searched. For links, the link text is searched.
9659
9731
  * For images, the "alt" attribute and inner text of any parent links are searched.
9660
9732
  *
9733
+ * If no locator is provided, defaults to clicking the body element (`'//body'`).
9734
+ *
9661
9735
  * The second parameter is a context (CSS or XPath locator) to narrow the search.
9662
9736
  *
9663
9737
  * ```js
9738
+ * // click body element (default)
9739
+ * I.click();
9664
9740
  * // simple link
9665
9741
  * I.click('Logout');
9666
9742
  * // button of form
@@ -9674,10 +9750,10 @@ declare namespace CodeceptJS {
9674
9750
  * // using strict locator
9675
9751
  * I.click({css: 'nav a.login'});
9676
9752
  * ```
9677
- * @param locator - clickable link or button located by text, or any element located by CSS|XPath|strict locator.
9753
+ * @param [locator = '//body'] - (optional, `'//body'` by default) clickable link or button located by text, or any element located by CSS|XPath|strict locator.
9678
9754
  * @param [context = null] - (optional, `null` by default) element to search in CSS|XPath|Strict locator.
9679
9755
  */
9680
- click(locator: CodeceptJS.LocatorOrString, context?: CodeceptJS.LocatorOrString | null): Promise<any>;
9756
+ click(locator?: CodeceptJS.LocatorOrString, context?: CodeceptJS.LocatorOrString | null): Promise<any>;
9681
9757
  /**
9682
9758
  * Perform an emulated click on a link or a button, given by a locator.
9683
9759
  * Unlike normal click instead of sending native event, emulates a click with JavaScript.
@@ -9736,6 +9812,23 @@ declare namespace CodeceptJS {
9736
9812
  * @param [context = null] - (optional, `null` by default) element located by CSS|XPath|strict locator.
9737
9813
  */
9738
9814
  rightClick(locator: CodeceptJS.LocatorOrString, context?: CodeceptJS.LocatorOrString): Promise<any>;
9815
+ /**
9816
+ * Performs click at specific coordinates.
9817
+ * If locator is provided, the coordinates are relative to the element's top-left corner.
9818
+ * If locator is not provided, the coordinates are relative to the body element.
9819
+ *
9820
+ * ```js
9821
+ * // Click at coordinates (100, 200) relative to body
9822
+ * I.clickXY(100, 200);
9823
+ *
9824
+ * // Click at coordinates (50, 30) relative to element's top-left corner
9825
+ * I.clickXY('#someElement', 50, 30);
9826
+ * ```
9827
+ * @param locator - Element to click on or X coordinate if no element.
9828
+ * @param [x] - X coordinate relative to element's top-left, or Y coordinate if locator is a number.
9829
+ * @param [y] - Y coordinate relative to element's top-left.
9830
+ */
9831
+ clickXY(locator: CodeceptJS.LocatorOrString | number, x?: number, y?: number): Promise<void>;
9739
9832
  /**
9740
9833
  * Emulates right click on an element.
9741
9834
  * Unlike normal click instead of sending native event, emulates a click with JavaScript.