codeceptjs 3.5.11 → 3.5.12-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.
@@ -517,8 +517,9 @@ class Playwright extends Helper {
517
517
  if (this.options.userAgent) contextOptions.userAgent = this.options.userAgent;
518
518
  if (this.options.locale) contextOptions.locale = this.options.locale;
519
519
  if (this.options.colorScheme) contextOptions.colorScheme = this.options.colorScheme;
520
+ this.contextOptions = contextOptions;
520
521
  if (!this.browserContext || !restartsSession()) {
521
- this.browserContext = await this.browser.newContext(contextOptions); // Adding the HTTPSError ignore in the context so that we can ignore those errors
522
+ this.browserContext = await this.browser.newContext(this.contextOptions); // Adding the HTTPSError ignore in the context so that we can ignore those errors
522
523
  }
523
524
  }
524
525
 
@@ -606,7 +607,7 @@ class Playwright extends Helper {
606
607
  page = await browser.firstWindow();
607
608
  } else {
608
609
  try {
609
- browserContext = await this.browser.newContext(Object.assign(this.options, config));
610
+ browserContext = await this.browser.newContext(Object.assign(this.contextOptions, config));
610
611
  page = await browserContext.newPage();
611
612
  } catch (e) {
612
613
  if (this.playwrightOptions.userDataDir) {
@@ -1022,7 +1023,7 @@ class Playwright extends Helper {
1022
1023
  * I.moveCursorTo('#submit', 5,5);
1023
1024
  * ```
1024
1025
  *
1025
- * @param {string | object} locator located by CSS|XPath|strict locator.
1026
+ * @param {CodeceptJS.LocatorOrString} locator located by CSS|XPath|strict locator.
1026
1027
  * @param {number} [offsetX=0] (optional, `0` by default) X-axis offset.
1027
1028
  * @param {number} [offsetY=0] (optional, `0` by default) Y-axis offset.
1028
1029
  * @returns {void} automatically synchronized promise through #recorder
@@ -1050,7 +1051,7 @@ class Playwright extends Helper {
1050
1051
  * I.see('#add-to-cart-bnt');
1051
1052
  * ```
1052
1053
  *
1053
- * @param {string | object} locator field located by label|name|CSS|XPath|strict locator.
1054
+ * @param {CodeceptJS.LocatorOrString} locator field located by label|name|CSS|XPath|strict locator.
1054
1055
  * @param {any} [options] Playwright only: [Additional options](https://playwright.dev/docs/api/class-locator#locator-focus) for available options object as 2nd argument.
1055
1056
  * @returns {void} automatically synchronized promise through #recorder
1056
1057
  *
@@ -1080,7 +1081,7 @@ class Playwright extends Helper {
1080
1081
  * I.dontSee('#add-to-cart-btn');
1081
1082
  * ```
1082
1083
  *
1083
- * @param {string | object} locator field located by label|name|CSS|XPath|strict locator.
1084
+ * @param {CodeceptJS.LocatorOrString} locator field located by label|name|CSS|XPath|strict locator.
1084
1085
  * @param {any} [options] Playwright only: [Additional options](https://playwright.dev/docs/api/class-locator#locator-blur) for available options object as 2nd argument.
1085
1086
  * @returns {void} automatically synchronized promise through #recorder
1086
1087
  *
@@ -1096,7 +1097,7 @@ class Playwright extends Helper {
1096
1097
  /**
1097
1098
  * Return the checked status of given element.
1098
1099
  *
1099
- * @param {string | object} locator element located by CSS|XPath|strict locator.
1100
+ * @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
1100
1101
  * @param {object} [options] See https://playwright.dev/docs/api/class-locator#locator-is-checked
1101
1102
  * @return {Promise<boolean>}
1102
1103
  *
@@ -1115,7 +1116,7 @@ class Playwright extends Helper {
1115
1116
  /**
1116
1117
  * Return the disabled status of given element.
1117
1118
  *
1118
- * @param {string | object} locator element located by CSS|XPath|strict locator.
1119
+ * @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
1119
1120
  * @param {object} [options] See https://playwright.dev/docs/api/class-locator#locator-is-disabled
1120
1121
  * @return {Promise<boolean>}
1121
1122
  *
@@ -1141,8 +1142,8 @@ class Playwright extends Helper {
1141
1142
  * I.dragAndDrop('#dragHandle', '#container');
1142
1143
  * ```
1143
1144
  *
1144
- * @param {string | object} srcElement located by CSS|XPath|strict locator.
1145
- * @param {string | object} destElement located by CSS|XPath|strict locator.
1145
+ * @param {LocatorOrString} srcElement located by CSS|XPath|strict locator.
1146
+ * @param {LocatorOrString} destElement located by CSS|XPath|strict locator.
1146
1147
  * @returns {void} automatically synchronized promise through #recorder
1147
1148
  *
1148
1149
  * @param {any} [options] [Additional options](https://playwright.dev/docs/api/class-page#page-drag-and-drop) can be passed as 3rd argument.
@@ -1276,7 +1277,7 @@ class Playwright extends Helper {
1276
1277
  * I.scrollTo('#submit', 5, 5);
1277
1278
  * ```
1278
1279
  *
1279
- * @param {string | object} locator located by CSS|XPath|strict locator.
1280
+ * @param {CodeceptJS.LocatorOrString} locator located by CSS|XPath|strict locator.
1280
1281
  * @param {number} [offsetX=0] (optional, `0` by default) X-axis offset.
1281
1282
  * @param {number} [offsetY=0] (optional, `0` by default) Y-axis offset.
1282
1283
  * @returns {void} automatically synchronized promise through #recorder
@@ -1461,7 +1462,7 @@ class Playwright extends Helper {
1461
1462
  * const webElements = await I.grabWebElements('#button');
1462
1463
  * ```
1463
1464
  *
1464
- * @param {string | object} locator element located by CSS|XPath|strict locator.
1465
+ * @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
1465
1466
  * @returns {Promise<*>} WebElement of being used Web helper
1466
1467
  *
1467
1468
  *
@@ -1478,7 +1479,7 @@ class Playwright extends Helper {
1478
1479
  * const webElement = await I.grabWebElement('#button');
1479
1480
  * ```
1480
1481
  *
1481
- * @param {string | object} locator element located by CSS|XPath|strict locator.
1482
+ * @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
1482
1483
  * @returns {Promise<*>} WebElement of being used Web helper
1483
1484
  *
1484
1485
  *
@@ -1622,7 +1623,7 @@ class Playwright extends Helper {
1622
1623
  * ```js
1623
1624
  * I.seeElement('#modal');
1624
1625
  * ```
1625
- * @param {string | object} locator located by CSS|XPath|strict locator.
1626
+ * @param {CodeceptJS.LocatorOrString} locator located by CSS|XPath|strict locator.
1626
1627
  * @returns {void} automatically synchronized promise through #recorder
1627
1628
  *
1628
1629
  *
@@ -1640,7 +1641,7 @@ class Playwright extends Helper {
1640
1641
  * I.dontSeeElement('.modal'); // modal is not shown
1641
1642
  * ```
1642
1643
  *
1643
- * @param {string | object} locator located by CSS|XPath|Strict locator.
1644
+ * @param {CodeceptJS.LocatorOrString} locator located by CSS|XPath|Strict locator.
1644
1645
  * @returns {void} automatically synchronized promise through #recorder
1645
1646
  *
1646
1647
  *
@@ -1658,7 +1659,7 @@ class Playwright extends Helper {
1658
1659
  * ```js
1659
1660
  * I.seeElementInDOM('#modal');
1660
1661
  * ```
1661
- * @param {string | object} locator element located by CSS|XPath|strict locator.
1662
+ * @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
1662
1663
  * @returns {void} automatically synchronized promise through #recorder
1663
1664
  *
1664
1665
  */
@@ -1674,7 +1675,7 @@ class Playwright extends Helper {
1674
1675
  * I.dontSeeElementInDOM('.nav'); // checks that element is not on page visible or not
1675
1676
  * ```
1676
1677
  *
1677
- * @param {string | object} locator located by CSS|XPath|Strict locator.
1678
+ * @param {CodeceptJS.LocatorOrString} locator located by CSS|XPath|Strict locator.
1678
1679
  * @returns {void} automatically synchronized promise through #recorder
1679
1680
  *
1680
1681
  */
@@ -1739,8 +1740,8 @@ class Playwright extends Helper {
1739
1740
  * I.click({css: 'nav a.login'});
1740
1741
  * ```
1741
1742
  *
1742
- * @param {string | object} locator clickable link or button located by text, or any element located by CSS|XPath|strict locator.
1743
- * @param {?string | object | null} [context=null] (optional, `null` by default) element to search in CSS|XPath|Strict locator.
1743
+ * @param {CodeceptJS.LocatorOrString} locator clickable link or button located by text, or any element located by CSS|XPath|strict locator.
1744
+ * @param {?CodeceptJS.LocatorOrString | null} [context=null] (optional, `null` by default) element to search in CSS|XPath|Strict locator.
1744
1745
  * @returns {void} automatically synchronized promise through #recorder
1745
1746
  *
1746
1747
  *
@@ -1796,8 +1797,8 @@ class Playwright extends Helper {
1796
1797
  * I.forceClick({css: 'nav a.login'});
1797
1798
  * ```
1798
1799
  *
1799
- * @param {string | object} locator clickable link or button located by text, or any element located by CSS|XPath|strict locator.
1800
- * @param {?string | object} [context=null] (optional, `null` by default) element to search in CSS|XPath|Strict locator.
1800
+ * @param {CodeceptJS.LocatorOrString} locator clickable link or button located by text, or any element located by CSS|XPath|strict locator.
1801
+ * @param {?CodeceptJS.LocatorOrString} [context=null] (optional, `null` by default) element to search in CSS|XPath|Strict locator.
1801
1802
  * @returns {void} automatically synchronized promise through #recorder
1802
1803
  *
1803
1804
  */
@@ -1816,8 +1817,8 @@ class Playwright extends Helper {
1816
1817
  * I.doubleClick('.btn.edit');
1817
1818
  * ```
1818
1819
  *
1819
- * @param {string | object} locator clickable link or button located by text, or any element located by CSS|XPath|strict locator.
1820
- * @param {?string | object} [context=null] (optional, `null` by default) element to search in CSS|XPath|Strict locator.
1820
+ * @param {CodeceptJS.LocatorOrString} locator clickable link or button located by text, or any element located by CSS|XPath|strict locator.
1821
+ * @param {?CodeceptJS.LocatorOrString} [context=null] (optional, `null` by default) element to search in CSS|XPath|Strict locator.
1821
1822
  * @returns {void} automatically synchronized promise through #recorder
1822
1823
  *
1823
1824
  */
@@ -1837,8 +1838,8 @@ class Playwright extends Helper {
1837
1838
  * I.rightClick('Click me', '.context');
1838
1839
  * ```
1839
1840
  *
1840
- * @param {string | object} locator clickable element located by CSS|XPath|strict locator.
1841
- * @param {?string | object} [context=null] (optional, `null` by default) element located by CSS|XPath|strict locator.
1841
+ * @param {CodeceptJS.LocatorOrString} locator clickable element located by CSS|XPath|strict locator.
1842
+ * @param {?CodeceptJS.LocatorOrString} [context=null] (optional, `null` by default) element located by CSS|XPath|strict locator.
1842
1843
  * @returns {void} automatically synchronized promise through #recorder
1843
1844
  *
1844
1845
  */
@@ -1868,8 +1869,8 @@ class Playwright extends Helper {
1868
1869
  * I.checkOption('I Agree to Terms and Conditions');
1869
1870
  * I.checkOption('agree', '//form');
1870
1871
  * ```
1871
- * @param {string | object} field checkbox located by label | name | CSS | XPath | strict locator.
1872
- * @param {?string | object} [context=null] (optional, `null` by default) element located by CSS | XPath | strict locator.
1872
+ * @param {CodeceptJS.LocatorOrString} field checkbox located by label | name | CSS | XPath | strict locator.
1873
+ * @param {?CodeceptJS.LocatorOrString} [context=null] (optional, `null` by default) element located by CSS | XPath | strict locator.
1873
1874
  * @returns {void} automatically synchronized promise through #recorder
1874
1875
  *
1875
1876
  *
@@ -1902,8 +1903,8 @@ class Playwright extends Helper {
1902
1903
  * I.uncheckOption('I Agree to Terms and Conditions');
1903
1904
  * I.uncheckOption('agree', '//form');
1904
1905
  * ```
1905
- * @param {string | object} field checkbox located by label | name | CSS | XPath | strict locator.
1906
- * @param {?string | object} [context=null] (optional, `null` by default) element located by CSS | XPath | strict locator.
1906
+ * @param {CodeceptJS.LocatorOrString} field checkbox located by label | name | CSS | XPath | strict locator.
1907
+ * @param {?CodeceptJS.LocatorOrString} [context=null] (optional, `null` by default) element located by CSS | XPath | strict locator.
1907
1908
  * @returns {void} automatically synchronized promise through #recorder
1908
1909
  *
1909
1910
  */
@@ -1922,7 +1923,7 @@ class Playwright extends Helper {
1922
1923
  * I.seeCheckboxIsChecked({css: '#signup_form input[type=checkbox]'});
1923
1924
  * ```
1924
1925
  *
1925
- * @param {string | object} field located by label|name|CSS|XPath|strict locator.
1926
+ * @param {CodeceptJS.LocatorOrString} field located by label|name|CSS|XPath|strict locator.
1926
1927
  * @returns {void} automatically synchronized promise through #recorder
1927
1928
  *
1928
1929
  */
@@ -1939,7 +1940,7 @@ class Playwright extends Helper {
1939
1940
  * I.dontSeeCheckboxIsChecked('agree'); // located by name
1940
1941
  * ```
1941
1942
  *
1942
- * @param {string | object} field located by label|name|CSS|XPath|strict locator.
1943
+ * @param {CodeceptJS.LocatorOrString} field located by label|name|CSS|XPath|strict locator.
1943
1944
  * @returns {void} automatically synchronized promise through #recorder
1944
1945
  *
1945
1946
  */
@@ -2130,8 +2131,8 @@ class Playwright extends Helper {
2130
2131
  * // or by strict locator
2131
2132
  * I.fillField({css: 'form#login input[name=username]'}, 'John');
2132
2133
  * ```
2133
- * @param {string | object} field located by label|name|CSS|XPath|strict locator.
2134
- * @param {string | object} value text value to fill.
2134
+ * @param {CodeceptJS.LocatorOrString} field located by label|name|CSS|XPath|strict locator.
2135
+ * @param {CodeceptJS.StringOrSecret} value text value to fill.
2135
2136
  * @returns {void} automatically synchronized promise through #recorder
2136
2137
  *
2137
2138
  *
@@ -2164,7 +2165,7 @@ class Playwright extends Helper {
2164
2165
  * ```
2165
2166
  * Use `force` to bypass the [actionability](https://playwright.dev/docs/actionability) checks.
2166
2167
  *
2167
- * @param {string | object} locator field located by label|name|CSS|XPath|strict locator.
2168
+ * @param {CodeceptJS.LocatorOrString} locator field located by label|name|CSS|XPath|strict locator.
2168
2169
  * @param {any} [options] [Additional options](https://playwright.dev/docs/api/class-locator#locator-clear) for available options object as 2nd argument.
2169
2170
  */
2170
2171
  async clearField(locator, options = {}) {
@@ -2189,7 +2190,7 @@ class Playwright extends Helper {
2189
2190
  * // typing secret
2190
2191
  * I.appendField('password', secret('123456'));
2191
2192
  * ```
2192
- * @param {string | object} field located by label|name|CSS|XPath|strict locator
2193
+ * @param {CodeceptJS.LocatorOrString} field located by label|name|CSS|XPath|strict locator
2193
2194
  * @param {string} value text value to append.
2194
2195
  * @returns {void} automatically synchronized promise through #recorder
2195
2196
  *
@@ -2213,8 +2214,8 @@ class Playwright extends Helper {
2213
2214
  * I.seeInField('form input[type=hidden]','hidden_value');
2214
2215
  * I.seeInField('#searchform input','Search');
2215
2216
  * ```
2216
- * @param {string | object} field located by label|name|CSS|XPath|strict locator.
2217
- * @param {string | object} value value to check.
2217
+ * @param {CodeceptJS.LocatorOrString} field located by label|name|CSS|XPath|strict locator.
2218
+ * @param {CodeceptJS.StringOrSecret} value value to check.
2218
2219
  * @returns {void} automatically synchronized promise through #recorder
2219
2220
  *
2220
2221
  */
@@ -2232,8 +2233,8 @@ class Playwright extends Helper {
2232
2233
  * I.dontSeeInField({ css: 'form input.email' }, 'user@user.com'); // field by CSS
2233
2234
  * ```
2234
2235
  *
2235
- * @param {string | object} field located by label|name|CSS|XPath|strict locator.
2236
- * @param {string | object} value value to check.
2236
+ * @param {CodeceptJS.LocatorOrString} field located by label|name|CSS|XPath|strict locator.
2237
+ * @param {CodeceptJS.StringOrSecret} value value to check.
2237
2238
  * @returns {void} automatically synchronized promise through #recorder
2238
2239
  *
2239
2240
  */
@@ -2252,7 +2253,7 @@ class Playwright extends Helper {
2252
2253
  * I.attachFile('form input[name=avatar]', 'data/avatar.jpg');
2253
2254
  * ```
2254
2255
  *
2255
- * @param {string | object} locator field located by label|name|CSS|XPath|strict locator.
2256
+ * @param {CodeceptJS.LocatorOrString} locator field located by label|name|CSS|XPath|strict locator.
2256
2257
  * @param {string} pathToFile local file path relative to codecept.conf.ts or codecept.conf.js config file.
2257
2258
  * @returns {void} automatically synchronized promise through #recorder
2258
2259
  *
@@ -2289,7 +2290,7 @@ class Playwright extends Helper {
2289
2290
  * ```js
2290
2291
  * I.selectOption('Which OS do you use?', ['Android', 'iOS']);
2291
2292
  * ```
2292
- * @param {string | object} select field located by label|name|CSS|XPath|strict locator.
2293
+ * @param {LocatorOrString} select field located by label|name|CSS|XPath|strict locator.
2293
2294
  * @param {string|Array<*>} option visible text or value of option.
2294
2295
  * @returns {void} automatically synchronized promise through #recorder
2295
2296
  *
@@ -2322,7 +2323,7 @@ class Playwright extends Helper {
2322
2323
  * let numOfElements = await I.grabNumberOfVisibleElements('p');
2323
2324
  * ```
2324
2325
  *
2325
- * @param {string | object} locator located by CSS|XPath|strict locator.
2326
+ * @param {CodeceptJS.LocatorOrString} locator located by CSS|XPath|strict locator.
2326
2327
  * @returns {Promise<number>} number of visible elements
2327
2328
  *
2328
2329
  */
@@ -2403,7 +2404,7 @@ class Playwright extends Helper {
2403
2404
  * I.see('Register', {css: 'form.register'}); // use strict locator
2404
2405
  * ```
2405
2406
  * @param {string} text expected on page.
2406
- * @param {?string | object} [context=null] (optional, `null` by default) element located by CSS|Xpath|strict locator in which to search for text.
2407
+ * @param {?CodeceptJS.LocatorOrString} [context=null] (optional, `null` by default) element located by CSS|Xpath|strict locator in which to search for text.
2407
2408
  * @returns {void} automatically synchronized promise through #recorder
2408
2409
  *
2409
2410
  *
@@ -2421,7 +2422,7 @@ class Playwright extends Helper {
2421
2422
  * ```
2422
2423
  *
2423
2424
  * @param {string} text element value to check.
2424
- * @param {(string | object)?} [context=null] element located by CSS|XPath|strict locator.
2425
+ * @param {CodeceptJS.LocatorOrString?} [context=null] element located by CSS|XPath|strict locator.
2425
2426
  * @returns {void} automatically synchronized promise through #recorder
2426
2427
  *
2427
2428
  */
@@ -2439,7 +2440,7 @@ class Playwright extends Helper {
2439
2440
  * ```
2440
2441
  *
2441
2442
  * @param {string} text which is not present.
2442
- * @param {string | object} [context] (optional) element located by CSS|XPath|strict locator in which to perfrom search.
2443
+ * @param {CodeceptJS.LocatorOrString} [context] (optional) element located by CSS|XPath|strict locator in which to perfrom search.
2443
2444
  * @returns {void} automatically synchronized promise through #recorder
2444
2445
  *
2445
2446
  *
@@ -2535,7 +2536,7 @@ class Playwright extends Helper {
2535
2536
  * I.seeNumberOfElements('#submitBtn', 1);
2536
2537
  * ```
2537
2538
  *
2538
- * @param {string | object} locator element located by CSS|XPath|strict locator.
2539
+ * @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
2539
2540
  * @param {number} num number of elements.
2540
2541
  * @returns {void} automatically synchronized promise through #recorder
2541
2542
  *
@@ -2555,7 +2556,7 @@ class Playwright extends Helper {
2555
2556
  * I.seeNumberOfVisibleElements('.buttons', 3);
2556
2557
  * ```
2557
2558
  *
2558
- * @param {string | object} locator element located by CSS|XPath|strict locator.
2559
+ * @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
2559
2560
  * @param {number} num number of elements.
2560
2561
  * @returns {void} automatically synchronized promise through #recorder
2561
2562
  *
@@ -2725,7 +2726,7 @@ class Playwright extends Helper {
2725
2726
  * ```
2726
2727
  * If multiple elements found returns first element.
2727
2728
  *
2728
- * @param {string | object} locator element located by CSS|XPath|strict locator.
2729
+ * @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
2729
2730
  * @returns {Promise<string>} attribute value
2730
2731
  *
2731
2732
  *
@@ -2746,7 +2747,7 @@ class Playwright extends Helper {
2746
2747
  * let pins = await I.grabTextFromAll('#pin li');
2747
2748
  * ```
2748
2749
  *
2749
- * @param {string | object} locator element located by CSS|XPath|strict locator.
2750
+ * @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
2750
2751
  * @returns {Promise<string[]>} attribute value
2751
2752
  *
2752
2753
  *
@@ -2769,7 +2770,7 @@ class Playwright extends Helper {
2769
2770
  * ```js
2770
2771
  * let email = await I.grabValueFrom('input[name=email]');
2771
2772
  * ```
2772
- * @param {string | object} locator field located by label|name|CSS|XPath|strict locator.
2773
+ * @param {CodeceptJS.LocatorOrString} locator field located by label|name|CSS|XPath|strict locator.
2773
2774
  * @returns {Promise<string>} attribute value
2774
2775
  *
2775
2776
  */
@@ -2787,7 +2788,7 @@ class Playwright extends Helper {
2787
2788
  * ```js
2788
2789
  * let inputs = await I.grabValueFromAll('//form/input');
2789
2790
  * ```
2790
- * @param {string | object} locator field located by label|name|CSS|XPath|strict locator.
2791
+ * @param {CodeceptJS.LocatorOrString} locator field located by label|name|CSS|XPath|strict locator.
2791
2792
  * @returns {Promise<string[]>} attribute value
2792
2793
  *
2793
2794
  */
@@ -2806,7 +2807,7 @@ class Playwright extends Helper {
2806
2807
  * let postHTML = await I.grabHTMLFrom('#post');
2807
2808
  * ```
2808
2809
  *
2809
- * @param {string | object} element located by CSS|XPath|strict locator.
2810
+ * @param {CodeceptJS.LocatorOrString} element located by CSS|XPath|strict locator.
2810
2811
  * @returns {Promise<string>} HTML code for an element
2811
2812
  *
2812
2813
  */
@@ -2825,7 +2826,7 @@ class Playwright extends Helper {
2825
2826
  * let postHTMLs = await I.grabHTMLFromAll('.post');
2826
2827
  * ```
2827
2828
  *
2828
- * @param {string | object} element located by CSS|XPath|strict locator.
2829
+ * @param {CodeceptJS.LocatorOrString} element located by CSS|XPath|strict locator.
2829
2830
  * @returns {Promise<string[]>} HTML code for an element
2830
2831
  *
2831
2832
  */
@@ -2844,7 +2845,7 @@ class Playwright extends Helper {
2844
2845
  * const value = await I.grabCssPropertyFrom('h3', 'font-weight');
2845
2846
  * ```
2846
2847
  *
2847
- * @param {string | object} locator element located by CSS|XPath|strict locator.
2848
+ * @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
2848
2849
  * @param {string} cssProperty CSS property name.
2849
2850
  * @returns {Promise<string>} CSS value
2850
2851
  *
@@ -2865,7 +2866,7 @@ class Playwright extends Helper {
2865
2866
  * const values = await I.grabCssPropertyFromAll('h3', 'font-weight');
2866
2867
  * ```
2867
2868
  *
2868
- * @param {string | object} locator element located by CSS|XPath|strict locator.
2869
+ * @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
2869
2870
  * @param {string} cssProperty CSS property name.
2870
2871
  * @returns {Promise<string[]>} CSS value
2871
2872
  *
@@ -2886,7 +2887,7 @@ class Playwright extends Helper {
2886
2887
  * I.seeCssPropertiesOnElements('h3', { 'font-weight': "bold"});
2887
2888
  * ```
2888
2889
  *
2889
- * @param {string | object} locator located by CSS|XPath|strict locator.
2890
+ * @param {CodeceptJS.LocatorOrString} locator located by CSS|XPath|strict locator.
2890
2891
  * @param {object} cssProperties object with CSS properties and their values to check.
2891
2892
  * @returns {void} automatically synchronized promise through #recorder
2892
2893
  *
@@ -2931,7 +2932,7 @@ class Playwright extends Helper {
2931
2932
  * I.seeAttributesOnElements('//form', { method: "post"});
2932
2933
  * ```
2933
2934
  *
2934
- * @param {string | object} locator located by CSS|XPath|strict locator.
2935
+ * @param {CodeceptJS.LocatorOrString} locator located by CSS|XPath|strict locator.
2935
2936
  * @param {object} attributes attributes and their values to check.
2936
2937
  * @returns {void} automatically synchronized promise through #recorder
2937
2938
  *
@@ -2972,7 +2973,7 @@ class Playwright extends Helper {
2972
2973
  * I.dragSlider('#slider', -70);
2973
2974
  * ```
2974
2975
  *
2975
- * @param {string | object} locator located by label|name|CSS|XPath|strict locator.
2976
+ * @param {CodeceptJS.LocatorOrString} locator located by label|name|CSS|XPath|strict locator.
2976
2977
  * @param {number} offsetX position to drag.
2977
2978
  * @returns {void} automatically synchronized promise through #recorder
2978
2979
  *
@@ -3004,7 +3005,7 @@ class Playwright extends Helper {
3004
3005
  * ```js
3005
3006
  * let hint = await I.grabAttributeFrom('#tooltip', 'title');
3006
3007
  * ```
3007
- * @param {string | object} locator element located by CSS|XPath|strict locator.
3008
+ * @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
3008
3009
  * @param {string} attr attribute name.
3009
3010
  * @returns {Promise<string>} attribute value
3010
3011
  *
@@ -3024,7 +3025,7 @@ class Playwright extends Helper {
3024
3025
  * ```js
3025
3026
  * let hints = await I.grabAttributeFromAll('.tooltip', 'title');
3026
3027
  * ```
3027
- * @param {string | object} locator element located by CSS|XPath|strict locator.
3028
+ * @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
3028
3029
  * @param {string} attr attribute name.
3029
3030
  * @returns {Promise<string[]>} attribute value
3030
3031
  *
@@ -3050,7 +3051,7 @@ class Playwright extends Helper {
3050
3051
  * I.saveElementScreenshot(`#submit`,'debug.png');
3051
3052
  * ```
3052
3053
  *
3053
- * @param {string | object} locator element located by CSS|XPath|strict locator.
3054
+ * @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
3054
3055
  * @param {string} fileName file name to save.
3055
3056
  * @returns {void} automatically synchronized promise through #recorder
3056
3057
  *
@@ -3237,7 +3238,7 @@ class Playwright extends Helper {
3237
3238
  * Waits for element to become enabled (by default waits for 1sec).
3238
3239
  * Element can be located by CSS or XPath.
3239
3240
  *
3240
- * @param {string | object} locator element located by CSS|XPath|strict locator.
3241
+ * @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
3241
3242
  * @param {number} [sec=1] (optional) time in seconds to wait, 1 by default.
3242
3243
  * @returns {void} automatically synchronized promise through #recorder
3243
3244
  *
@@ -3272,7 +3273,7 @@ class Playwright extends Helper {
3272
3273
  * I.waitForValue('//input', "GoodValue");
3273
3274
  * ```
3274
3275
  *
3275
- * @param {string | object} field input field.
3276
+ * @param {LocatorOrString} field input field.
3276
3277
  * @param {string }value expected value.
3277
3278
  * @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
3278
3279
  * @returns {void} automatically synchronized promise through #recorder
@@ -3309,7 +3310,7 @@ class Playwright extends Helper {
3309
3310
  * I.waitNumberOfVisibleElements('a', 3);
3310
3311
  * ```
3311
3312
  *
3312
- * @param {string | object} locator element located by CSS|XPath|strict locator.
3313
+ * @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
3313
3314
  * @param {number} num number of elements.
3314
3315
  * @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
3315
3316
  * @returns {void} automatically synchronized promise through #recorder
@@ -3352,7 +3353,7 @@ class Playwright extends Helper {
3352
3353
  * I.waitForClickable('.btn.continue', 5); // wait for 5 secs
3353
3354
  * ```
3354
3355
  *
3355
- * @param {string | object} locator element located by CSS|XPath|strict locator.
3356
+ * @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
3356
3357
  * @param {number} [sec] (optional, `1` by default) time in seconds to wait
3357
3358
  * @returns {void} automatically synchronized promise through #recorder
3358
3359
  *
@@ -3371,7 +3372,7 @@ class Playwright extends Helper {
3371
3372
  * I.waitForElement('.btn.continue', 5); // wait for 5 secs
3372
3373
  * ```
3373
3374
  *
3374
- * @param {string | object} locator element located by CSS|XPath|strict locator.
3375
+ * @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
3375
3376
  * @param {number} [sec] (optional, `1` by default) time in seconds to wait
3376
3377
  * @returns {void} automatically synchronized promise through #recorder
3377
3378
  *
@@ -3399,7 +3400,7 @@ class Playwright extends Helper {
3399
3400
  * I.waitForVisible('#popup');
3400
3401
  * ```
3401
3402
  *
3402
- * @param {string | object} locator element located by CSS|XPath|strict locator.
3403
+ * @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
3403
3404
  * @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
3404
3405
  * @returns {void} automatically synchronized promise through #recorder
3405
3406
  *
@@ -3438,7 +3439,7 @@ class Playwright extends Helper {
3438
3439
  * I.waitForInvisible('#popup');
3439
3440
  * ```
3440
3441
  *
3441
- * @param {string | object} locator element located by CSS|XPath|strict locator.
3442
+ * @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
3442
3443
  * @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
3443
3444
  * @returns {void} automatically synchronized promise through #recorder
3444
3445
  *
@@ -3478,7 +3479,7 @@ class Playwright extends Helper {
3478
3479
  * I.waitToHide('#popup');
3479
3480
  * ```
3480
3481
  *
3481
- * @param {string | object} locator element located by CSS|XPath|strict locator.
3482
+ * @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
3482
3483
  * @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
3483
3484
  * @returns {void} automatically synchronized promise through #recorder
3484
3485
  *
@@ -3508,6 +3509,33 @@ class Playwright extends Helper {
3508
3509
  });
3509
3510
  }
3510
3511
 
3512
+ /**
3513
+ * Waits for number of tabs.
3514
+ *
3515
+ * ```js
3516
+ * I.waitForNumberOfTabs(2);
3517
+ * ```
3518
+ *
3519
+ * @param {number} expectedTabs expecting the number of tabs.
3520
+ * @param {number} sec number of secs to wait.
3521
+ * @returns {void} automatically synchronized promise through #recorder
3522
+ *
3523
+ */
3524
+ async waitForNumberOfTabs(expectedTabs, sec) {
3525
+ const waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout;
3526
+ let currentTabs;
3527
+ let count = 0;
3528
+
3529
+ do {
3530
+ currentTabs = await this.grabNumberOfOpenTabs();
3531
+ await this.wait(1);
3532
+ count += 1000;
3533
+ if (currentTabs >= expectedTabs) return;
3534
+ } while (count <= waitTimeout);
3535
+
3536
+ throw new Error(`Expected ${expectedTabs} tabs are not met after ${waitTimeout / 1000} sec.`);
3537
+ }
3538
+
3511
3539
  async _getContext() {
3512
3540
  if (this.context && this.context.constructor.name === 'FrameLocator') {
3513
3541
  return this.context;
@@ -3589,7 +3617,7 @@ class Playwright extends Helper {
3589
3617
  *
3590
3618
  * @param {string }text to wait for.
3591
3619
  * @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
3592
- * @param {string | object} [context] (optional) element located by CSS|XPath|strict locator.
3620
+ * @param {CodeceptJS.LocatorOrString} [context] (optional) element located by CSS|XPath|strict locator.
3593
3621
  * @returns {void} automatically synchronized promise through #recorder
3594
3622
  *
3595
3623
  */
@@ -3674,7 +3702,7 @@ class Playwright extends Helper {
3674
3702
  * I.switchTo(); // switch back to main page
3675
3703
  * ```
3676
3704
  *
3677
- * @param {?string | object} [locator=null] (optional, `null` by default) element located by CSS|XPath|strict locator.
3705
+ * @param {?CodeceptJS.LocatorOrString} [locator=null] (optional, `null` by default) element located by CSS|XPath|strict locator.
3678
3706
  * @returns {void} automatically synchronized promise through #recorder
3679
3707
  *
3680
3708
  */
@@ -3814,7 +3842,7 @@ class Playwright extends Helper {
3814
3842
  * I.waitForDetached('#popup');
3815
3843
  * ```
3816
3844
  *
3817
- * @param {string | object} locator element located by CSS|XPath|strict locator.
3845
+ * @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
3818
3846
  * @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
3819
3847
  * @returns {void} automatically synchronized promise through #recorder
3820
3848
  *
@@ -3892,7 +3920,7 @@ class Playwright extends Helper {
3892
3920
  * const width = await I.grabElementBoundingRect('h3', 'width');
3893
3921
  * // width == 527
3894
3922
  * ```
3895
- * @param {string | object} locator element located by CSS|XPath|strict locator.
3923
+ * @param {LocatorOrString} locator element located by CSS|XPath|strict locator.
3896
3924
  * @param {string=} elementSize x, y, width or height of the given element.
3897
3925
  * @returns {Promise<DOMRect>|Promise<number>} Element bounding rectangle
3898
3926
  *