codeceptjs 3.5.10 → 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.
- package/docs/build/Appium.js +36 -36
- package/docs/build/Expect.js +33 -33
- package/docs/build/Nightmare.js +50 -50
- package/docs/build/Playwright.js +126 -122
- package/docs/build/Protractor.js +59 -59
- package/docs/build/Puppeteer.js +93 -89
- package/docs/build/TestCafe.js +48 -48
- package/docs/build/WebDriver.js +90 -92
- package/docs/helpers/Appium.md +1 -1
- package/docs/helpers/Expect.md +33 -33
- package/docs/helpers/Playwright.md +73 -35
- package/docs/helpers/Puppeteer.md +35 -24
- package/docs/helpers/WebDriver.md +26 -13
- package/docs/parallel.md +2 -2
- package/docs/plugins.md +3 -3
- package/docs/react.md +2 -1
- package/docs/vue.md +22 -0
- package/docs/webapi/scrollIntoView.mustache +1 -1
- package/lib/command/workers/runTests.js +17 -1
- package/lib/helper/Expect.js +33 -33
- package/lib/helper/Playwright.js +28 -24
- package/lib/helper/Puppeteer.js +23 -19
- package/lib/helper/WebDriver.js +15 -17
- package/lib/helper/extras/PlaywrightReactVueLocator.js +38 -0
- package/lib/plugin/retryFailedStep.js +2 -2
- package/lib/plugin/tryTo.js +5 -4
- package/package.json +15 -15
- package/typings/index.d.ts +1 -1
- package/typings/promiseBasedTypes.d.ts +119 -74
- package/typings/types.d.ts +111 -143
- package/lib/helper/extras/PlaywrightReact.js +0 -9
package/docs/build/Puppeteer.js
CHANGED
|
@@ -259,6 +259,7 @@ class Puppeteer extends Helper {
|
|
|
259
259
|
headless: !this.options.show,
|
|
260
260
|
...this._getOptions(config),
|
|
261
261
|
};
|
|
262
|
+
if (this.puppeteerOptions.headless) this.puppeteerOptions.headless = 'new';
|
|
262
263
|
this.isRemoteBrowser = !!this.puppeteerOptions.browserWSEndpoint;
|
|
263
264
|
popupStore.defaultAction = this.options.defaultPopupAction;
|
|
264
265
|
}
|
|
@@ -703,6 +704,11 @@ class Puppeteer extends Helper {
|
|
|
703
704
|
}
|
|
704
705
|
|
|
705
706
|
/**
|
|
707
|
+
*
|
|
708
|
+
* Unlike other drivers Puppeteer changes the size of a viewport, not the window!
|
|
709
|
+
* Puppeteer does not control the window of a browser, so it can't adjust its real size.
|
|
710
|
+
* It also can't maximize a window.
|
|
711
|
+
*
|
|
706
712
|
* Resize the current window to provided width and height.
|
|
707
713
|
* First parameter can be set to `maximize`.
|
|
708
714
|
*
|
|
@@ -711,9 +717,6 @@ class Puppeteer extends Helper {
|
|
|
711
717
|
* @returns {void} automatically synchronized promise through #recorder
|
|
712
718
|
*
|
|
713
719
|
*
|
|
714
|
-
* Unlike other drivers Puppeteer changes the size of a viewport, not the window!
|
|
715
|
-
* Puppeteer does not control the window of a browser so it can't adjust its real size.
|
|
716
|
-
* It also can't maximize a window.
|
|
717
720
|
*/
|
|
718
721
|
async resizeWindow(width, height) {
|
|
719
722
|
if (width === 'maximize') {
|
|
@@ -751,7 +754,7 @@ class Puppeteer extends Helper {
|
|
|
751
754
|
* I.moveCursorTo('#submit', 5,5);
|
|
752
755
|
* ```
|
|
753
756
|
*
|
|
754
|
-
* @param {
|
|
757
|
+
* @param {string | object} locator located by CSS|XPath|strict locator.
|
|
755
758
|
* @param {number} [offsetX=0] (optional, `0` by default) X-axis offset.
|
|
756
759
|
* @param {number} [offsetY=0] (optional, `0` by default) Y-axis offset.
|
|
757
760
|
* @returns {void} automatically synchronized promise through #recorder
|
|
@@ -779,7 +782,7 @@ class Puppeteer extends Helper {
|
|
|
779
782
|
* I.see('#add-to-cart-bnt');
|
|
780
783
|
* ```
|
|
781
784
|
*
|
|
782
|
-
* @param {
|
|
785
|
+
* @param {string | object} locator field located by label|name|CSS|XPath|strict locator.
|
|
783
786
|
* @param {any} [options] Playwright only: [Additional options](https://playwright.dev/docs/api/class-locator#locator-focus) for available options object as 2nd argument.
|
|
784
787
|
* @returns {void} automatically synchronized promise through #recorder
|
|
785
788
|
*
|
|
@@ -790,7 +793,8 @@ class Puppeteer extends Helper {
|
|
|
790
793
|
assertElementExists(els, locator, 'Element to focus');
|
|
791
794
|
const el = els[0];
|
|
792
795
|
|
|
793
|
-
await
|
|
796
|
+
await el.click();
|
|
797
|
+
await el.focus();
|
|
794
798
|
return this._waitForAction();
|
|
795
799
|
}
|
|
796
800
|
|
|
@@ -810,7 +814,7 @@ class Puppeteer extends Helper {
|
|
|
810
814
|
* I.dontSee('#add-to-cart-btn');
|
|
811
815
|
* ```
|
|
812
816
|
*
|
|
813
|
-
* @param {
|
|
817
|
+
* @param {string | object} locator field located by label|name|CSS|XPath|strict locator.
|
|
814
818
|
* @param {any} [options] Playwright only: [Additional options](https://playwright.dev/docs/api/class-locator#locator-blur) for available options object as 2nd argument.
|
|
815
819
|
* @returns {void} automatically synchronized promise through #recorder
|
|
816
820
|
*
|
|
@@ -831,8 +835,8 @@ class Puppeteer extends Helper {
|
|
|
831
835
|
* I.dragAndDrop('#dragHandle', '#container');
|
|
832
836
|
* ```
|
|
833
837
|
*
|
|
834
|
-
* @param {
|
|
835
|
-
* @param {
|
|
838
|
+
* @param {string | object} srcElement located by CSS|XPath|strict locator.
|
|
839
|
+
* @param {string | object} destElement located by CSS|XPath|strict locator.
|
|
836
840
|
* @returns {void} automatically synchronized promise through #recorder
|
|
837
841
|
*
|
|
838
842
|
*/
|
|
@@ -900,7 +904,7 @@ class Puppeteer extends Helper {
|
|
|
900
904
|
* I.scrollTo('#submit', 5, 5);
|
|
901
905
|
* ```
|
|
902
906
|
*
|
|
903
|
-
* @param {
|
|
907
|
+
* @param {string | object} locator located by CSS|XPath|strict locator.
|
|
904
908
|
* @param {number} [offsetX=0] (optional, `0` by default) X-axis offset.
|
|
905
909
|
* @param {number} [offsetY=0] (optional, `0` by default) Y-axis offset.
|
|
906
910
|
* @returns {void} automatically synchronized promise through #recorder
|
|
@@ -1026,7 +1030,7 @@ class Puppeteer extends Helper {
|
|
|
1026
1030
|
}
|
|
1027
1031
|
|
|
1028
1032
|
/**
|
|
1029
|
-
* Find a checkbox by providing human
|
|
1033
|
+
* Find a checkbox by providing human-readable text:
|
|
1030
1034
|
* NOTE: Assumes the checkable element exists
|
|
1031
1035
|
*
|
|
1032
1036
|
* ```js
|
|
@@ -1041,7 +1045,7 @@ class Puppeteer extends Helper {
|
|
|
1041
1045
|
}
|
|
1042
1046
|
|
|
1043
1047
|
/**
|
|
1044
|
-
* Find a clickable element by providing human
|
|
1048
|
+
* Find a clickable element by providing human-readable text:
|
|
1045
1049
|
*
|
|
1046
1050
|
* ```js
|
|
1047
1051
|
* this.helpers['Puppeteer']._locateClickable('Next page').then // ...
|
|
@@ -1053,7 +1057,7 @@ class Puppeteer extends Helper {
|
|
|
1053
1057
|
}
|
|
1054
1058
|
|
|
1055
1059
|
/**
|
|
1056
|
-
* Find field elements by providing human
|
|
1060
|
+
* Find field elements by providing human-readable text:
|
|
1057
1061
|
*
|
|
1058
1062
|
* ```js
|
|
1059
1063
|
* this.helpers['Puppeteer']._locateFields('Your email').then // ...
|
|
@@ -1071,7 +1075,7 @@ class Puppeteer extends Helper {
|
|
|
1071
1075
|
* const webElements = await I.grabWebElements('#button');
|
|
1072
1076
|
* ```
|
|
1073
1077
|
*
|
|
1074
|
-
* @param {
|
|
1078
|
+
* @param {string | object} locator element located by CSS|XPath|strict locator.
|
|
1075
1079
|
* @returns {Promise<*>} WebElement of being used Web helper
|
|
1076
1080
|
*
|
|
1077
1081
|
*
|
|
@@ -1195,7 +1199,7 @@ class Puppeteer extends Helper {
|
|
|
1195
1199
|
* ```js
|
|
1196
1200
|
* I.seeElement('#modal');
|
|
1197
1201
|
* ```
|
|
1198
|
-
* @param {
|
|
1202
|
+
* @param {string | object} locator located by CSS|XPath|strict locator.
|
|
1199
1203
|
* @returns {void} automatically synchronized promise through #recorder
|
|
1200
1204
|
*
|
|
1201
1205
|
* {{ react }}
|
|
@@ -1216,7 +1220,7 @@ class Puppeteer extends Helper {
|
|
|
1216
1220
|
* I.dontSeeElement('.modal'); // modal is not shown
|
|
1217
1221
|
* ```
|
|
1218
1222
|
*
|
|
1219
|
-
* @param {
|
|
1223
|
+
* @param {string | object} locator located by CSS|XPath|Strict locator.
|
|
1220
1224
|
* @returns {void} automatically synchronized promise through #recorder
|
|
1221
1225
|
*
|
|
1222
1226
|
* {{ react }}
|
|
@@ -1237,7 +1241,7 @@ class Puppeteer extends Helper {
|
|
|
1237
1241
|
* ```js
|
|
1238
1242
|
* I.seeElementInDOM('#modal');
|
|
1239
1243
|
* ```
|
|
1240
|
-
* @param {
|
|
1244
|
+
* @param {string | object} locator element located by CSS|XPath|strict locator.
|
|
1241
1245
|
* @returns {void} automatically synchronized promise through #recorder
|
|
1242
1246
|
*
|
|
1243
1247
|
*/
|
|
@@ -1253,7 +1257,7 @@ class Puppeteer extends Helper {
|
|
|
1253
1257
|
* I.dontSeeElementInDOM('.nav'); // checks that element is not on page visible or not
|
|
1254
1258
|
* ```
|
|
1255
1259
|
*
|
|
1256
|
-
* @param {
|
|
1260
|
+
* @param {string | object} locator located by CSS|XPath|Strict locator.
|
|
1257
1261
|
* @returns {void} automatically synchronized promise through #recorder
|
|
1258
1262
|
*
|
|
1259
1263
|
*/
|
|
@@ -1285,8 +1289,8 @@ class Puppeteer extends Helper {
|
|
|
1285
1289
|
* I.click({css: 'nav a.login'});
|
|
1286
1290
|
* ```
|
|
1287
1291
|
*
|
|
1288
|
-
* @param {
|
|
1289
|
-
* @param {?
|
|
1292
|
+
* @param {string | object} locator clickable link or button located by text, or any element located by CSS|XPath|strict locator.
|
|
1293
|
+
* @param {?string | object | null} [context=null] (optional, `null` by default) element to search in CSS|XPath|Strict locator.
|
|
1290
1294
|
* @returns {void} automatically synchronized promise through #recorder
|
|
1291
1295
|
*
|
|
1292
1296
|
*
|
|
@@ -1322,8 +1326,8 @@ class Puppeteer extends Helper {
|
|
|
1322
1326
|
* I.forceClick({css: 'nav a.login'});
|
|
1323
1327
|
* ```
|
|
1324
1328
|
*
|
|
1325
|
-
* @param {
|
|
1326
|
-
* @param {?
|
|
1329
|
+
* @param {string | object} locator clickable link or button located by text, or any element located by CSS|XPath|strict locator.
|
|
1330
|
+
* @param {?string | object} [context=null] (optional, `null` by default) element to search in CSS|XPath|Strict locator.
|
|
1327
1331
|
* @returns {void} automatically synchronized promise through #recorder
|
|
1328
1332
|
*
|
|
1329
1333
|
*
|
|
@@ -1360,8 +1364,8 @@ class Puppeteer extends Helper {
|
|
|
1360
1364
|
* ```js
|
|
1361
1365
|
* I.clickLink('Logout', '#nav');
|
|
1362
1366
|
* ```
|
|
1363
|
-
* @param {
|
|
1364
|
-
* @param {?
|
|
1367
|
+
* @param {string | object} locator clickable link or button located by text, or any element located by CSS|XPath|strict locator
|
|
1368
|
+
* @param {?string | object} [context=null] (optional, `null` by default) element to search in CSS|XPath|Strict locator
|
|
1365
1369
|
* @returns {void} automatically synchronized promise through #recorder
|
|
1366
1370
|
*
|
|
1367
1371
|
*
|
|
@@ -1375,7 +1379,7 @@ class Puppeteer extends Helper {
|
|
|
1375
1379
|
* Sets a directory to where save files. Allows to test file downloads.
|
|
1376
1380
|
* Should be used with [FileSystem helper](https://codecept.io/helpers/FileSystem) to check that file were downloaded correctly.
|
|
1377
1381
|
*
|
|
1378
|
-
* By default files are saved to `output/downloads`.
|
|
1382
|
+
* By default, files are saved to `output/downloads`.
|
|
1379
1383
|
* This directory is cleaned on every `handleDownloads` call, to ensure no old files are kept.
|
|
1380
1384
|
*
|
|
1381
1385
|
* ```js
|
|
@@ -1479,8 +1483,8 @@ class Puppeteer extends Helper {
|
|
|
1479
1483
|
* I.doubleClick('.btn.edit');
|
|
1480
1484
|
* ```
|
|
1481
1485
|
*
|
|
1482
|
-
* @param {
|
|
1483
|
-
* @param {?
|
|
1486
|
+
* @param {string | object} locator clickable link or button located by text, or any element located by CSS|XPath|strict locator.
|
|
1487
|
+
* @param {?string | object} [context=null] (optional, `null` by default) element to search in CSS|XPath|Strict locator.
|
|
1484
1488
|
* @returns {void} automatically synchronized promise through #recorder
|
|
1485
1489
|
*
|
|
1486
1490
|
*
|
|
@@ -1502,8 +1506,8 @@ class Puppeteer extends Helper {
|
|
|
1502
1506
|
* I.rightClick('Click me', '.context');
|
|
1503
1507
|
* ```
|
|
1504
1508
|
*
|
|
1505
|
-
* @param {
|
|
1506
|
-
* @param {?
|
|
1509
|
+
* @param {string | object} locator clickable element located by CSS|XPath|strict locator.
|
|
1510
|
+
* @param {?string | object} [context=null] (optional, `null` by default) element located by CSS|XPath|strict locator.
|
|
1507
1511
|
* @returns {void} automatically synchronized promise through #recorder
|
|
1508
1512
|
*
|
|
1509
1513
|
*
|
|
@@ -1524,8 +1528,8 @@ class Puppeteer extends Helper {
|
|
|
1524
1528
|
* I.checkOption('I Agree to Terms and Conditions');
|
|
1525
1529
|
* I.checkOption('agree', '//form');
|
|
1526
1530
|
* ```
|
|
1527
|
-
* @param {
|
|
1528
|
-
* @param {?
|
|
1531
|
+
* @param {string | object} field checkbox located by label | name | CSS | XPath | strict locator.
|
|
1532
|
+
* @param {?string | object} [context=null] (optional, `null` by default) element located by CSS | XPath | strict locator.
|
|
1529
1533
|
* @returns {void} automatically synchronized promise through #recorder
|
|
1530
1534
|
*
|
|
1531
1535
|
*/
|
|
@@ -1551,8 +1555,8 @@ class Puppeteer extends Helper {
|
|
|
1551
1555
|
* I.uncheckOption('I Agree to Terms and Conditions');
|
|
1552
1556
|
* I.uncheckOption('agree', '//form');
|
|
1553
1557
|
* ```
|
|
1554
|
-
* @param {
|
|
1555
|
-
* @param {?
|
|
1558
|
+
* @param {string | object} field checkbox located by label | name | CSS | XPath | strict locator.
|
|
1559
|
+
* @param {?string | object} [context=null] (optional, `null` by default) element located by CSS | XPath | strict locator.
|
|
1556
1560
|
* @returns {void} automatically synchronized promise through #recorder
|
|
1557
1561
|
*
|
|
1558
1562
|
*/
|
|
@@ -1576,7 +1580,7 @@ class Puppeteer extends Helper {
|
|
|
1576
1580
|
* I.seeCheckboxIsChecked({css: '#signup_form input[type=checkbox]'});
|
|
1577
1581
|
* ```
|
|
1578
1582
|
*
|
|
1579
|
-
* @param {
|
|
1583
|
+
* @param {string | object} field located by label|name|CSS|XPath|strict locator.
|
|
1580
1584
|
* @returns {void} automatically synchronized promise through #recorder
|
|
1581
1585
|
*
|
|
1582
1586
|
*/
|
|
@@ -1593,7 +1597,7 @@ class Puppeteer extends Helper {
|
|
|
1593
1597
|
* I.dontSeeCheckboxIsChecked('agree'); // located by name
|
|
1594
1598
|
* ```
|
|
1595
1599
|
*
|
|
1596
|
-
* @param {
|
|
1600
|
+
* @param {string | object} field located by label|name|CSS|XPath|strict locator.
|
|
1597
1601
|
* @returns {void} automatically synchronized promise through #recorder
|
|
1598
1602
|
*
|
|
1599
1603
|
*/
|
|
@@ -1644,6 +1648,8 @@ class Puppeteer extends Helper {
|
|
|
1644
1648
|
}
|
|
1645
1649
|
|
|
1646
1650
|
/**
|
|
1651
|
+
* _Note:_ Shortcuts like `'Meta'` + `'A'` do not work on macOS ([GoogleChrome/puppeteer#1313](https://github.com/GoogleChrome/puppeteer/issues/1313)).
|
|
1652
|
+
*
|
|
1647
1653
|
* Presses a key in the browser (on a focused element).
|
|
1648
1654
|
*
|
|
1649
1655
|
* _Hint:_ For populating text field or textarea, it is recommended to use [`fillField`](#fillfield).
|
|
@@ -1705,8 +1711,6 @@ class Puppeteer extends Helper {
|
|
|
1705
1711
|
* @param {string|string[]} key key or array of keys to press.
|
|
1706
1712
|
* @returns {void} automatically synchronized promise through #recorder
|
|
1707
1713
|
*
|
|
1708
|
-
*
|
|
1709
|
-
* _Note:_ Shortcuts like `'Meta'` + `'A'` do not work on macOS ([GoogleChrome/puppeteer#1313](https://github.com/GoogleChrome/puppeteer/issues/1313)).
|
|
1710
1714
|
*/
|
|
1711
1715
|
async pressKey(key) {
|
|
1712
1716
|
const modifiers = [];
|
|
@@ -1783,8 +1787,8 @@ class Puppeteer extends Helper {
|
|
|
1783
1787
|
* // or by strict locator
|
|
1784
1788
|
* I.fillField({css: 'form#login input[name=username]'}, 'John');
|
|
1785
1789
|
* ```
|
|
1786
|
-
* @param {
|
|
1787
|
-
* @param {
|
|
1790
|
+
* @param {string | object} field located by label|name|CSS|XPath|strict locator.
|
|
1791
|
+
* @param {string | object} value text value to fill.
|
|
1788
1792
|
* @returns {void} automatically synchronized promise through #recorder
|
|
1789
1793
|
*
|
|
1790
1794
|
* {{ react }}
|
|
@@ -1815,7 +1819,7 @@ class Puppeteer extends Helper {
|
|
|
1815
1819
|
* I.clearField('user[email]');
|
|
1816
1820
|
* I.clearField('#email');
|
|
1817
1821
|
* ```
|
|
1818
|
-
* @param {
|
|
1822
|
+
* @param {string | object} editable field located by label|name|CSS|XPath|strict locator.
|
|
1819
1823
|
* @returns {void} automatically synchronized promise through #recorder.
|
|
1820
1824
|
*
|
|
1821
1825
|
*/
|
|
@@ -1832,7 +1836,7 @@ class Puppeteer extends Helper {
|
|
|
1832
1836
|
* // typing secret
|
|
1833
1837
|
* I.appendField('password', secret('123456'));
|
|
1834
1838
|
* ```
|
|
1835
|
-
* @param {
|
|
1839
|
+
* @param {string | object} field located by label|name|CSS|XPath|strict locator
|
|
1836
1840
|
* @param {string} value text value to append.
|
|
1837
1841
|
* @returns {void} automatically synchronized promise through #recorder
|
|
1838
1842
|
*
|
|
@@ -1858,8 +1862,8 @@ class Puppeteer extends Helper {
|
|
|
1858
1862
|
* I.seeInField('form input[type=hidden]','hidden_value');
|
|
1859
1863
|
* I.seeInField('#searchform input','Search');
|
|
1860
1864
|
* ```
|
|
1861
|
-
* @param {
|
|
1862
|
-
* @param {
|
|
1865
|
+
* @param {string | object} field located by label|name|CSS|XPath|strict locator.
|
|
1866
|
+
* @param {string | object} value value to check.
|
|
1863
1867
|
* @returns {void} automatically synchronized promise through #recorder
|
|
1864
1868
|
*
|
|
1865
1869
|
*/
|
|
@@ -1877,8 +1881,8 @@ class Puppeteer extends Helper {
|
|
|
1877
1881
|
* I.dontSeeInField({ css: 'form input.email' }, 'user@user.com'); // field by CSS
|
|
1878
1882
|
* ```
|
|
1879
1883
|
*
|
|
1880
|
-
* @param {
|
|
1881
|
-
* @param {
|
|
1884
|
+
* @param {string | object} field located by label|name|CSS|XPath|strict locator.
|
|
1885
|
+
* @param {string | object} value value to check.
|
|
1882
1886
|
* @returns {void} automatically synchronized promise through #recorder
|
|
1883
1887
|
*
|
|
1884
1888
|
*/
|
|
@@ -1888,6 +1892,8 @@ class Puppeteer extends Helper {
|
|
|
1888
1892
|
}
|
|
1889
1893
|
|
|
1890
1894
|
/**
|
|
1895
|
+
* > ⚠ 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.
|
|
1896
|
+
*
|
|
1891
1897
|
* Attaches a file to element located by label, name, CSS or XPath
|
|
1892
1898
|
* Path to file is relative current codecept directory (where codecept.conf.ts or codecept.conf.js is located).
|
|
1893
1899
|
* File will be uploaded to remote system (if tests are running remotely).
|
|
@@ -1897,12 +1903,10 @@ class Puppeteer extends Helper {
|
|
|
1897
1903
|
* I.attachFile('form input[name=avatar]', 'data/avatar.jpg');
|
|
1898
1904
|
* ```
|
|
1899
1905
|
*
|
|
1900
|
-
* @param {
|
|
1906
|
+
* @param {string | object} locator field located by label|name|CSS|XPath|strict locator.
|
|
1901
1907
|
* @param {string} pathToFile local file path relative to codecept.conf.ts or codecept.conf.js config file.
|
|
1902
1908
|
* @returns {void} automatically synchronized promise through #recorder
|
|
1903
1909
|
*
|
|
1904
|
-
*
|
|
1905
|
-
* > ⚠ 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.
|
|
1906
1910
|
*/
|
|
1907
1911
|
async attachFile(locator, pathToFile) {
|
|
1908
1912
|
const file = path.join(global.codecept_dir, pathToFile);
|
|
@@ -1935,7 +1939,7 @@ class Puppeteer extends Helper {
|
|
|
1935
1939
|
* ```js
|
|
1936
1940
|
* I.selectOption('Which OS do you use?', ['Android', 'iOS']);
|
|
1937
1941
|
* ```
|
|
1938
|
-
* @param {
|
|
1942
|
+
* @param {string | object} select field located by label|name|CSS|XPath|strict locator.
|
|
1939
1943
|
* @param {string|Array<*>} option visible text or value of option.
|
|
1940
1944
|
* @returns {void} automatically synchronized promise through #recorder
|
|
1941
1945
|
*
|
|
@@ -1978,7 +1982,7 @@ class Puppeteer extends Helper {
|
|
|
1978
1982
|
* let numOfElements = await I.grabNumberOfVisibleElements('p');
|
|
1979
1983
|
* ```
|
|
1980
1984
|
*
|
|
1981
|
-
* @param {
|
|
1985
|
+
* @param {string | object} locator located by CSS|XPath|strict locator.
|
|
1982
1986
|
* @returns {Promise<number>} number of visible elements
|
|
1983
1987
|
* {{ react }}
|
|
1984
1988
|
*/
|
|
@@ -2062,7 +2066,7 @@ class Puppeteer extends Helper {
|
|
|
2062
2066
|
* I.see('Register', {css: 'form.register'}); // use strict locator
|
|
2063
2067
|
* ```
|
|
2064
2068
|
* @param {string} text expected on page.
|
|
2065
|
-
* @param {?
|
|
2069
|
+
* @param {?string | object} [context=null] (optional, `null` by default) element located by CSS|Xpath|strict locator in which to search for text.
|
|
2066
2070
|
* @returns {void} automatically synchronized promise through #recorder
|
|
2067
2071
|
*
|
|
2068
2072
|
*
|
|
@@ -2080,7 +2084,7 @@ class Puppeteer extends Helper {
|
|
|
2080
2084
|
* ```
|
|
2081
2085
|
*
|
|
2082
2086
|
* @param {string} text element value to check.
|
|
2083
|
-
* @param {
|
|
2087
|
+
* @param {(string | object)?} [context=null] element located by CSS|XPath|strict locator.
|
|
2084
2088
|
* @returns {void} automatically synchronized promise through #recorder
|
|
2085
2089
|
*
|
|
2086
2090
|
*/
|
|
@@ -2098,7 +2102,7 @@ class Puppeteer extends Helper {
|
|
|
2098
2102
|
* ```
|
|
2099
2103
|
*
|
|
2100
2104
|
* @param {string} text which is not present.
|
|
2101
|
-
* @param {
|
|
2105
|
+
* @param {string | object} [context] (optional) element located by CSS|XPath|strict locator in which to perfrom search.
|
|
2102
2106
|
* @returns {void} automatically synchronized promise through #recorder
|
|
2103
2107
|
*
|
|
2104
2108
|
*
|
|
@@ -2192,7 +2196,7 @@ class Puppeteer extends Helper {
|
|
|
2192
2196
|
* I.seeNumberOfElements('#submitBtn', 1);
|
|
2193
2197
|
* ```
|
|
2194
2198
|
*
|
|
2195
|
-
* @param {
|
|
2199
|
+
* @param {string | object} locator element located by CSS|XPath|strict locator.
|
|
2196
2200
|
* @param {number} num number of elements.
|
|
2197
2201
|
* @returns {void} automatically synchronized promise through #recorder
|
|
2198
2202
|
*
|
|
@@ -2212,7 +2216,7 @@ class Puppeteer extends Helper {
|
|
|
2212
2216
|
* I.seeNumberOfVisibleElements('.buttons', 3);
|
|
2213
2217
|
* ```
|
|
2214
2218
|
*
|
|
2215
|
-
* @param {
|
|
2219
|
+
* @param {string | object} locator element located by CSS|XPath|strict locator.
|
|
2216
2220
|
* @param {number} num number of elements.
|
|
2217
2221
|
* @returns {void} automatically synchronized promise through #recorder
|
|
2218
2222
|
*
|
|
@@ -2329,6 +2333,8 @@ class Puppeteer extends Helper {
|
|
|
2329
2333
|
}
|
|
2330
2334
|
|
|
2331
2335
|
/**
|
|
2336
|
+
* If a function returns a Promise, tt will wait for its resolution.
|
|
2337
|
+
*
|
|
2332
2338
|
* Executes sync script on a page.
|
|
2333
2339
|
* Pass arguments to function as additional parameters.
|
|
2334
2340
|
* Will return execution result to a test.
|
|
@@ -2356,8 +2362,6 @@ class Puppeteer extends Helper {
|
|
|
2356
2362
|
* @param {...any} args to be passed to function.
|
|
2357
2363
|
* @returns {Promise<any>} script return value
|
|
2358
2364
|
*
|
|
2359
|
-
*
|
|
2360
|
-
* If a function returns a Promise It will wait for it resolution.
|
|
2361
2365
|
*/
|
|
2362
2366
|
async executeScript(...args) {
|
|
2363
2367
|
let context = this.page;
|
|
@@ -2368,6 +2372,7 @@ class Puppeteer extends Helper {
|
|
|
2368
2372
|
}
|
|
2369
2373
|
|
|
2370
2374
|
/**
|
|
2375
|
+
* Asynchronous scripts can also be executed with `executeScript` if a function returns a Promise.
|
|
2371
2376
|
* Executes async script on page.
|
|
2372
2377
|
* Provided function should execute a passed callback (as first argument) to signal it is finished.
|
|
2373
2378
|
*
|
|
@@ -2393,8 +2398,6 @@ class Puppeteer extends Helper {
|
|
|
2393
2398
|
* @param {...any} args to be passed to function.
|
|
2394
2399
|
* @returns {Promise<any>} script return value
|
|
2395
2400
|
*
|
|
2396
|
-
*
|
|
2397
|
-
* Asynchronous scripts can also be executed with `executeScript` if a function returns a Promise.
|
|
2398
2401
|
*/
|
|
2399
2402
|
async executeAsyncScript(...args) {
|
|
2400
2403
|
const asyncFn = function () {
|
|
@@ -2418,7 +2421,7 @@ class Puppeteer extends Helper {
|
|
|
2418
2421
|
* let pins = await I.grabTextFromAll('#pin li');
|
|
2419
2422
|
* ```
|
|
2420
2423
|
*
|
|
2421
|
-
* @param {
|
|
2424
|
+
* @param {string | object} locator element located by CSS|XPath|strict locator.
|
|
2422
2425
|
* @returns {Promise<string[]>} attribute value
|
|
2423
2426
|
*
|
|
2424
2427
|
* {{ react }}
|
|
@@ -2441,7 +2444,7 @@ class Puppeteer extends Helper {
|
|
|
2441
2444
|
* ```
|
|
2442
2445
|
* If multiple elements found returns first element.
|
|
2443
2446
|
*
|
|
2444
|
-
* @param {
|
|
2447
|
+
* @param {string | object} locator element located by CSS|XPath|strict locator.
|
|
2445
2448
|
* @returns {Promise<string>} attribute value
|
|
2446
2449
|
*
|
|
2447
2450
|
* {{ react }}
|
|
@@ -2463,7 +2466,7 @@ class Puppeteer extends Helper {
|
|
|
2463
2466
|
* ```js
|
|
2464
2467
|
* let inputs = await I.grabValueFromAll('//form/input');
|
|
2465
2468
|
* ```
|
|
2466
|
-
* @param {
|
|
2469
|
+
* @param {string | object} locator field located by label|name|CSS|XPath|strict locator.
|
|
2467
2470
|
* @returns {Promise<string[]>} attribute value
|
|
2468
2471
|
*
|
|
2469
2472
|
*/
|
|
@@ -2484,7 +2487,7 @@ class Puppeteer extends Helper {
|
|
|
2484
2487
|
* ```js
|
|
2485
2488
|
* let email = await I.grabValueFrom('input[name=email]');
|
|
2486
2489
|
* ```
|
|
2487
|
-
* @param {
|
|
2490
|
+
* @param {string | object} locator field located by label|name|CSS|XPath|strict locator.
|
|
2488
2491
|
* @returns {Promise<string>} attribute value
|
|
2489
2492
|
*
|
|
2490
2493
|
*/
|
|
@@ -2506,7 +2509,7 @@ class Puppeteer extends Helper {
|
|
|
2506
2509
|
* let postHTMLs = await I.grabHTMLFromAll('.post');
|
|
2507
2510
|
* ```
|
|
2508
2511
|
*
|
|
2509
|
-
* @param {
|
|
2512
|
+
* @param {string | object} element located by CSS|XPath|strict locator.
|
|
2510
2513
|
* @returns {Promise<string[]>} HTML code for an element
|
|
2511
2514
|
*
|
|
2512
2515
|
*/
|
|
@@ -2525,7 +2528,7 @@ class Puppeteer extends Helper {
|
|
|
2525
2528
|
* let postHTML = await I.grabHTMLFrom('#post');
|
|
2526
2529
|
* ```
|
|
2527
2530
|
*
|
|
2528
|
-
* @param {
|
|
2531
|
+
* @param {string | object} element located by CSS|XPath|strict locator.
|
|
2529
2532
|
* @returns {Promise<string>} HTML code for an element
|
|
2530
2533
|
*
|
|
2531
2534
|
*/
|
|
@@ -2547,7 +2550,7 @@ class Puppeteer extends Helper {
|
|
|
2547
2550
|
* const values = await I.grabCssPropertyFromAll('h3', 'font-weight');
|
|
2548
2551
|
* ```
|
|
2549
2552
|
*
|
|
2550
|
-
* @param {
|
|
2553
|
+
* @param {string | object} locator element located by CSS|XPath|strict locator.
|
|
2551
2554
|
* @param {string} cssProperty CSS property name.
|
|
2552
2555
|
* @returns {Promise<string[]>} CSS value
|
|
2553
2556
|
*
|
|
@@ -2570,7 +2573,7 @@ class Puppeteer extends Helper {
|
|
|
2570
2573
|
* const value = await I.grabCssPropertyFrom('h3', 'font-weight');
|
|
2571
2574
|
* ```
|
|
2572
2575
|
*
|
|
2573
|
-
* @param {
|
|
2576
|
+
* @param {string | object} locator element located by CSS|XPath|strict locator.
|
|
2574
2577
|
* @param {string} cssProperty CSS property name.
|
|
2575
2578
|
* @returns {Promise<string>} CSS value
|
|
2576
2579
|
*
|
|
@@ -2594,7 +2597,7 @@ class Puppeteer extends Helper {
|
|
|
2594
2597
|
* I.seeCssPropertiesOnElements('h3', { 'font-weight': "bold"});
|
|
2595
2598
|
* ```
|
|
2596
2599
|
*
|
|
2597
|
-
* @param {
|
|
2600
|
+
* @param {string | object} locator located by CSS|XPath|strict locator.
|
|
2598
2601
|
* @param {object} cssProperties object with CSS properties and their values to check.
|
|
2599
2602
|
* @returns {void} automatically synchronized promise through #recorder
|
|
2600
2603
|
*
|
|
@@ -2639,7 +2642,7 @@ class Puppeteer extends Helper {
|
|
|
2639
2642
|
* I.seeAttributesOnElements('//form', { method: "post"});
|
|
2640
2643
|
* ```
|
|
2641
2644
|
*
|
|
2642
|
-
* @param {
|
|
2645
|
+
* @param {string | object} locator located by CSS|XPath|strict locator.
|
|
2643
2646
|
* @param {object} attributes attributes and their values to check.
|
|
2644
2647
|
* @returns {void} automatically synchronized promise through #recorder
|
|
2645
2648
|
*
|
|
@@ -2667,7 +2670,8 @@ class Puppeteer extends Helper {
|
|
|
2667
2670
|
for (let i = 0; i < val.length; ++i) {
|
|
2668
2671
|
const _actual = Number.isNaN(val[i]) || (typeof values[i]) === 'string' ? val[i] : Number.parseInt(values[i], 10);
|
|
2669
2672
|
const _expected = Number.isNaN(values[i]) || (typeof values[i]) === 'string' ? values[i] : Number.parseInt(values[i], 10);
|
|
2670
|
-
if
|
|
2673
|
+
// if the attribute doesn't exist, returns false as well
|
|
2674
|
+
if (!_actual || !_actual.includes(_expected)) return false;
|
|
2671
2675
|
}
|
|
2672
2676
|
return true;
|
|
2673
2677
|
});
|
|
@@ -2683,7 +2687,7 @@ class Puppeteer extends Helper {
|
|
|
2683
2687
|
* I.dragSlider('#slider', -70);
|
|
2684
2688
|
* ```
|
|
2685
2689
|
*
|
|
2686
|
-
* @param {
|
|
2690
|
+
* @param {string | object} locator located by label|name|CSS|XPath|strict locator.
|
|
2687
2691
|
* @param {number} offsetX position to drag.
|
|
2688
2692
|
* @returns {void} automatically synchronized promise through #recorder
|
|
2689
2693
|
*
|
|
@@ -2714,7 +2718,7 @@ class Puppeteer extends Helper {
|
|
|
2714
2718
|
* ```js
|
|
2715
2719
|
* let hints = await I.grabAttributeFromAll('.tooltip', 'title');
|
|
2716
2720
|
* ```
|
|
2717
|
-
* @param {
|
|
2721
|
+
* @param {string | object} locator element located by CSS|XPath|strict locator.
|
|
2718
2722
|
* @param {string} attr attribute name.
|
|
2719
2723
|
* @returns {Promise<string[]>} attribute value
|
|
2720
2724
|
*
|
|
@@ -2738,7 +2742,7 @@ class Puppeteer extends Helper {
|
|
|
2738
2742
|
* ```js
|
|
2739
2743
|
* let hint = await I.grabAttributeFrom('#tooltip', 'title');
|
|
2740
2744
|
* ```
|
|
2741
|
-
* @param {
|
|
2745
|
+
* @param {string | object} locator element located by CSS|XPath|strict locator.
|
|
2742
2746
|
* @param {string} attr attribute name.
|
|
2743
2747
|
* @returns {Promise<string>} attribute value
|
|
2744
2748
|
*
|
|
@@ -2762,7 +2766,7 @@ class Puppeteer extends Helper {
|
|
|
2762
2766
|
* I.saveElementScreenshot(`#submit`,'debug.png');
|
|
2763
2767
|
* ```
|
|
2764
2768
|
*
|
|
2765
|
-
* @param {
|
|
2769
|
+
* @param {string | object} locator element located by CSS|XPath|strict locator.
|
|
2766
2770
|
* @param {string} fileName file name to save.
|
|
2767
2771
|
* @returns {void} automatically synchronized promise through #recorder
|
|
2768
2772
|
*
|
|
@@ -2870,7 +2874,7 @@ class Puppeteer extends Helper {
|
|
|
2870
2874
|
* Waits for element to become enabled (by default waits for 1sec).
|
|
2871
2875
|
* Element can be located by CSS or XPath.
|
|
2872
2876
|
*
|
|
2873
|
-
* @param {
|
|
2877
|
+
* @param {string | object} locator element located by CSS|XPath|strict locator.
|
|
2874
2878
|
* @param {number} [sec=1] (optional) time in seconds to wait, 1 by default.
|
|
2875
2879
|
* @returns {void} automatically synchronized promise through #recorder
|
|
2876
2880
|
*
|
|
@@ -2909,7 +2913,7 @@ class Puppeteer extends Helper {
|
|
|
2909
2913
|
* I.waitForValue('//input', "GoodValue");
|
|
2910
2914
|
* ```
|
|
2911
2915
|
*
|
|
2912
|
-
* @param {
|
|
2916
|
+
* @param {string | object} field input field.
|
|
2913
2917
|
* @param {string }value expected value.
|
|
2914
2918
|
* @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
|
|
2915
2919
|
* @returns {void} automatically synchronized promise through #recorder
|
|
@@ -2950,7 +2954,7 @@ class Puppeteer extends Helper {
|
|
|
2950
2954
|
* I.waitNumberOfVisibleElements('a', 3);
|
|
2951
2955
|
* ```
|
|
2952
2956
|
*
|
|
2953
|
-
* @param {
|
|
2957
|
+
* @param {string | object} locator element located by CSS|XPath|strict locator.
|
|
2954
2958
|
* @param {number} num number of elements.
|
|
2955
2959
|
* @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
|
|
2956
2960
|
* @returns {void} automatically synchronized promise through #recorder
|
|
@@ -2993,7 +2997,7 @@ class Puppeteer extends Helper {
|
|
|
2993
2997
|
* I.waitForClickable('.btn.continue', 5); // wait for 5 secs
|
|
2994
2998
|
* ```
|
|
2995
2999
|
*
|
|
2996
|
-
* @param {
|
|
3000
|
+
* @param {string | object} locator element located by CSS|XPath|strict locator.
|
|
2997
3001
|
* @param {number} [sec] (optional, `1` by default) time in seconds to wait
|
|
2998
3002
|
* @returns {void} automatically synchronized promise through #recorder
|
|
2999
3003
|
*
|
|
@@ -3020,7 +3024,7 @@ class Puppeteer extends Helper {
|
|
|
3020
3024
|
* I.waitForElement('.btn.continue', 5); // wait for 5 secs
|
|
3021
3025
|
* ```
|
|
3022
3026
|
*
|
|
3023
|
-
* @param {
|
|
3027
|
+
* @param {string | object} locator element located by CSS|XPath|strict locator.
|
|
3024
3028
|
* @param {number} [sec] (optional, `1` by default) time in seconds to wait
|
|
3025
3029
|
* @returns {void} automatically synchronized promise through #recorder
|
|
3026
3030
|
*
|
|
@@ -3050,12 +3054,12 @@ class Puppeteer extends Helper {
|
|
|
3050
3054
|
* I.waitForVisible('#popup');
|
|
3051
3055
|
* ```
|
|
3052
3056
|
*
|
|
3053
|
-
* @param {
|
|
3057
|
+
* @param {string | object} locator element located by CSS|XPath|strict locator.
|
|
3054
3058
|
* @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
|
|
3055
3059
|
* @returns {void} automatically synchronized promise through #recorder
|
|
3056
3060
|
*
|
|
3057
3061
|
*
|
|
3058
|
-
*
|
|
3062
|
+
* {{ react }}
|
|
3059
3063
|
*/
|
|
3060
3064
|
async waitForVisible(locator, sec) {
|
|
3061
3065
|
const waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout;
|
|
@@ -3081,7 +3085,7 @@ class Puppeteer extends Helper {
|
|
|
3081
3085
|
* I.waitForInvisible('#popup');
|
|
3082
3086
|
* ```
|
|
3083
3087
|
*
|
|
3084
|
-
* @param {
|
|
3088
|
+
* @param {string | object} locator element located by CSS|XPath|strict locator.
|
|
3085
3089
|
* @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
|
|
3086
3090
|
* @returns {void} automatically synchronized promise through #recorder
|
|
3087
3091
|
*
|
|
@@ -3110,7 +3114,7 @@ class Puppeteer extends Helper {
|
|
|
3110
3114
|
* I.waitToHide('#popup');
|
|
3111
3115
|
* ```
|
|
3112
3116
|
*
|
|
3113
|
-
* @param {
|
|
3117
|
+
* @param {string | object} locator element located by CSS|XPath|strict locator.
|
|
3114
3118
|
* @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
|
|
3115
3119
|
* @returns {void} automatically synchronized promise through #recorder
|
|
3116
3120
|
*
|
|
@@ -3211,7 +3215,7 @@ class Puppeteer extends Helper {
|
|
|
3211
3215
|
*
|
|
3212
3216
|
* @param {string }text to wait for.
|
|
3213
3217
|
* @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
|
|
3214
|
-
* @param {
|
|
3218
|
+
* @param {string | object} [context] (optional) element located by CSS|XPath|strict locator.
|
|
3215
3219
|
* @returns {void} automatically synchronized promise through #recorder
|
|
3216
3220
|
*
|
|
3217
3221
|
*/
|
|
@@ -3288,7 +3292,7 @@ class Puppeteer extends Helper {
|
|
|
3288
3292
|
* I.switchTo(); // switch back to main page
|
|
3289
3293
|
* ```
|
|
3290
3294
|
*
|
|
3291
|
-
* @param {?
|
|
3295
|
+
* @param {?string | object} [locator=null] (optional, `null` by default) element located by CSS|XPath|strict locator.
|
|
3292
3296
|
* @returns {void} automatically synchronized promise through #recorder
|
|
3293
3297
|
*
|
|
3294
3298
|
*/
|
|
@@ -3362,9 +3366,9 @@ class Puppeteer extends Helper {
|
|
|
3362
3366
|
}
|
|
3363
3367
|
|
|
3364
3368
|
/**
|
|
3365
|
-
* Waits for navigation to finish. By default takes configured `waitForNavigation` option.
|
|
3369
|
+
* Waits for navigation to finish. By default, takes configured `waitForNavigation` option.
|
|
3366
3370
|
*
|
|
3367
|
-
* See [
|
|
3371
|
+
* See [Puppeteer's reference](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#pagewaitfornavigationoptions)
|
|
3368
3372
|
*
|
|
3369
3373
|
* @param {*} opts
|
|
3370
3374
|
*/
|
|
@@ -3392,7 +3396,7 @@ class Puppeteer extends Helper {
|
|
|
3392
3396
|
* I.waitForDetached('#popup');
|
|
3393
3397
|
* ```
|
|
3394
3398
|
*
|
|
3395
|
-
* @param {
|
|
3399
|
+
* @param {string | object} locator element located by CSS|XPath|strict locator.
|
|
3396
3400
|
* @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
|
|
3397
3401
|
* @returns {void} automatically synchronized promise through #recorder
|
|
3398
3402
|
*
|
|
@@ -3469,7 +3473,7 @@ class Puppeteer extends Helper {
|
|
|
3469
3473
|
* const width = await I.grabElementBoundingRect('h3', 'width');
|
|
3470
3474
|
* // width == 527
|
|
3471
3475
|
* ```
|
|
3472
|
-
* @param {
|
|
3476
|
+
* @param {string | object} locator element located by CSS|XPath|strict locator.
|
|
3473
3477
|
* @param {string=} elementSize x, y, width or height of the given element.
|
|
3474
3478
|
* @returns {Promise<DOMRect>|Promise<number>} Element bounding rectangle
|
|
3475
3479
|
*
|