codeceptjs 3.2.0 → 3.3.0-beta.1
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/CHANGELOG.md +78 -2
- package/docs/advanced.md +3 -3
- package/docs/api.md +227 -188
- package/docs/basics.md +26 -1
- package/docs/bdd.md +2 -2
- package/docs/build/ApiDataFactory.js +13 -6
- package/docs/build/Appium.js +98 -36
- package/docs/build/FileSystem.js +11 -1
- package/docs/build/GraphQL.js +11 -0
- package/docs/build/JSONResponse.js +297 -0
- package/docs/build/Nightmare.js +48 -48
- package/docs/build/Playwright.js +277 -151
- package/docs/build/Puppeteer.js +77 -68
- package/docs/build/REST.js +36 -0
- package/docs/build/TestCafe.js +44 -44
- package/docs/build/WebDriver.js +70 -70
- package/docs/changelog.md +28 -2
- package/docs/configuration.md +8 -8
- package/docs/custom-helpers.md +1 -1
- package/docs/data.md +9 -9
- package/docs/helpers/ApiDataFactory.md +7 -0
- package/docs/helpers/Appium.md +240 -198
- package/docs/helpers/FileSystem.md +11 -1
- package/docs/helpers/JSONResponse.md +230 -0
- package/docs/helpers/Playwright.md +283 -216
- package/docs/helpers/Puppeteer.md +9 -1
- package/docs/helpers/REST.md +30 -9
- package/docs/installation.md +3 -1
- package/docs/internal-api.md +265 -0
- package/docs/mobile.md +11 -11
- package/docs/nightmare.md +3 -3
- package/docs/pageobjects.md +2 -0
- package/docs/playwright.md +73 -18
- package/docs/plugins.md +140 -40
- package/docs/puppeteer.md +28 -12
- package/docs/quickstart.md +2 -3
- package/docs/reports.md +44 -3
- package/docs/testcafe.md +1 -1
- package/docs/translation.md +2 -2
- package/docs/videos.md +2 -2
- package/docs/visual.md +2 -2
- package/docs/vue.md +1 -1
- package/docs/webdriver.md +92 -4
- package/lib/actor.js +2 -2
- package/lib/cli.js +25 -20
- package/lib/command/init.js +5 -15
- package/lib/command/workers/runTests.js +25 -7
- package/lib/config.js +17 -13
- package/lib/helper/ApiDataFactory.js +13 -6
- package/lib/helper/Appium.js +65 -3
- package/lib/helper/FileSystem.js +11 -1
- package/lib/helper/GraphQL.js +11 -0
- package/lib/helper/JSONResponse.js +297 -0
- package/lib/helper/Playwright.js +215 -89
- package/lib/helper/Puppeteer.js +13 -4
- package/lib/helper/REST.js +36 -0
- package/lib/helper/WebDriver.js +1 -1
- package/lib/helper/extras/Console.js +8 -0
- package/lib/helper/extras/PlaywrightRestartOpts.js +35 -0
- package/lib/interfaces/bdd.js +3 -1
- package/lib/listener/timeout.js +4 -3
- package/lib/plugin/allure.js +12 -0
- package/lib/plugin/autoLogin.js +1 -1
- package/lib/plugin/eachElement.js +127 -0
- package/lib/plugin/retryFailedStep.js +4 -3
- package/lib/plugin/stepTimeout.js +5 -4
- package/lib/plugin/tryTo.js +6 -0
- package/lib/recorder.js +2 -1
- package/lib/step.js +57 -2
- package/lib/utils.js +20 -0
- package/package.json +6 -4
- package/translations/pt-BR.js +8 -0
- package/typings/index.d.ts +4 -0
- package/typings/types.d.ts +345 -110
package/docs/build/Puppeteer.js
CHANGED
|
@@ -22,6 +22,7 @@ const {
|
|
|
22
22
|
screenshotOutputFolder,
|
|
23
23
|
getNormalizedKeyAttributeValue,
|
|
24
24
|
isModifierKey,
|
|
25
|
+
requireWithFallback,
|
|
25
26
|
} = require('../utils');
|
|
26
27
|
const {
|
|
27
28
|
isColorProperty,
|
|
@@ -43,7 +44,15 @@ const consoleLogStore = new Console();
|
|
|
43
44
|
* Browser control is executed via DevTools Protocol (instead of Selenium).
|
|
44
45
|
* This helper works with a browser out of the box with no additional tools required to install.
|
|
45
46
|
*
|
|
46
|
-
* Requires `puppeteer` package to be installed.
|
|
47
|
+
* Requires `puppeteer` or `puppeteer-core` package to be installed.
|
|
48
|
+
* ```
|
|
49
|
+
* npm i puppeteer --save
|
|
50
|
+
* ```
|
|
51
|
+
* or
|
|
52
|
+
* ```
|
|
53
|
+
* npm i puppeteer-core --save
|
|
54
|
+
* ```
|
|
55
|
+
* Using `puppeteer-core` package, will prevent the download of browser binaries and allow connecting to an existing browser installation or for connecting to a remote one.
|
|
47
56
|
*
|
|
48
57
|
* > Experimental Firefox support [can be activated](https://codecept.io/helpers/Puppeteer-firefox).
|
|
49
58
|
*
|
|
@@ -182,7 +191,7 @@ class Puppeteer extends Helper {
|
|
|
182
191
|
constructor(config) {
|
|
183
192
|
super(config);
|
|
184
193
|
|
|
185
|
-
puppeteer =
|
|
194
|
+
puppeteer = requireWithFallback('puppeteer', 'puppeteer-core');
|
|
186
195
|
|
|
187
196
|
// set defaults
|
|
188
197
|
this.isRemoteBrowser = false;
|
|
@@ -245,7 +254,7 @@ class Puppeteer extends Helper {
|
|
|
245
254
|
|
|
246
255
|
static _checkRequirements() {
|
|
247
256
|
try {
|
|
248
|
-
|
|
257
|
+
requireWithFallback('puppeteer', 'puppeteer-core');
|
|
249
258
|
} catch (e) {
|
|
250
259
|
return ['puppeteer'];
|
|
251
260
|
}
|
|
@@ -264,7 +273,7 @@ class Puppeteer extends Helper {
|
|
|
264
273
|
async _before() {
|
|
265
274
|
this.sessionPages = {};
|
|
266
275
|
recorder.retry({
|
|
267
|
-
retries:
|
|
276
|
+
retries: 3,
|
|
268
277
|
when: err => {
|
|
269
278
|
if (!err || typeof (err.message) !== 'string') {
|
|
270
279
|
return false;
|
|
@@ -705,7 +714,7 @@ class Puppeteer extends Helper {
|
|
|
705
714
|
* I.moveCursorTo('#submit', 5,5);
|
|
706
715
|
* ```
|
|
707
716
|
*
|
|
708
|
-
* @param {
|
|
717
|
+
* @param {string | object} locator located by CSS|XPath|strict locator.
|
|
709
718
|
* @param {number} [offsetX=0] (optional, `0` by default) X-axis offset.
|
|
710
719
|
* @param {number} [offsetY=0] (optional, `0` by default) Y-axis offset.
|
|
711
720
|
*
|
|
@@ -728,8 +737,8 @@ class Puppeteer extends Helper {
|
|
|
728
737
|
* I.dragAndDrop('#dragHandle', '#container');
|
|
729
738
|
* ```
|
|
730
739
|
*
|
|
731
|
-
* @param {
|
|
732
|
-
* @param {
|
|
740
|
+
* @param {string | object} srcElement located by CSS|XPath|strict locator.
|
|
741
|
+
* @param {string | object} destElement located by CSS|XPath|strict locator.
|
|
733
742
|
*
|
|
734
743
|
*/
|
|
735
744
|
async dragAndDrop(srcElement, destElement) {
|
|
@@ -790,7 +799,7 @@ class Puppeteer extends Helper {
|
|
|
790
799
|
* I.scrollTo('#submit', 5, 5);
|
|
791
800
|
* ```
|
|
792
801
|
*
|
|
793
|
-
* @param {
|
|
802
|
+
* @param {string | object} locator located by CSS|XPath|strict locator.
|
|
794
803
|
* @param {number} [offsetX=0] (optional, `0` by default) X-axis offset.
|
|
795
804
|
* @param {number} [offsetY=0] (optional, `0` by default) Y-axis offset.
|
|
796
805
|
*/
|
|
@@ -1060,7 +1069,7 @@ class Puppeteer extends Helper {
|
|
|
1060
1069
|
* ```js
|
|
1061
1070
|
* I.seeElement('#modal');
|
|
1062
1071
|
* ```
|
|
1063
|
-
* @param {
|
|
1072
|
+
* @param {string | object} locator located by CSS|XPath|strict locator.
|
|
1064
1073
|
* {{ react }}
|
|
1065
1074
|
*/
|
|
1066
1075
|
async seeElement(locator) {
|
|
@@ -1079,7 +1088,7 @@ class Puppeteer extends Helper {
|
|
|
1079
1088
|
* I.dontSeeElement('.modal'); // modal is not shown
|
|
1080
1089
|
* ```
|
|
1081
1090
|
*
|
|
1082
|
-
* @param {
|
|
1091
|
+
* @param {string | object} locator located by CSS|XPath|Strict locator.
|
|
1083
1092
|
* {{ react }}
|
|
1084
1093
|
*/
|
|
1085
1094
|
async dontSeeElement(locator) {
|
|
@@ -1098,7 +1107,7 @@ class Puppeteer extends Helper {
|
|
|
1098
1107
|
* ```js
|
|
1099
1108
|
* I.seeElementInDOM('#modal');
|
|
1100
1109
|
* ```
|
|
1101
|
-
* @param {
|
|
1110
|
+
* @param {string | object} locator element located by CSS|XPath|strict locator.
|
|
1102
1111
|
*
|
|
1103
1112
|
*/
|
|
1104
1113
|
async seeElementInDOM(locator) {
|
|
@@ -1113,7 +1122,7 @@ class Puppeteer extends Helper {
|
|
|
1113
1122
|
* I.dontSeeElementInDOM('.nav'); // checks that element is not on page visible or not
|
|
1114
1123
|
* ```
|
|
1115
1124
|
*
|
|
1116
|
-
* @param {
|
|
1125
|
+
* @param {string | object} locator located by CSS|XPath|Strict locator.
|
|
1117
1126
|
*/
|
|
1118
1127
|
async dontSeeElementInDOM(locator) {
|
|
1119
1128
|
const els = await this._locate(locator);
|
|
@@ -1143,8 +1152,8 @@ class Puppeteer extends Helper {
|
|
|
1143
1152
|
* I.click({css: 'nav a.login'});
|
|
1144
1153
|
* ```
|
|
1145
1154
|
*
|
|
1146
|
-
* @param {
|
|
1147
|
-
* @param {?
|
|
1155
|
+
* @param {string | object} locator clickable link or button located by text, or any element located by CSS|XPath|strict locator.
|
|
1156
|
+
* @param {?string | object} [context=null] (optional, `null` by default) element to search in CSS|XPath|Strict locator.
|
|
1148
1157
|
*
|
|
1149
1158
|
*
|
|
1150
1159
|
* {{ react }}
|
|
@@ -1179,8 +1188,8 @@ class Puppeteer extends Helper {
|
|
|
1179
1188
|
* I.forceClick({css: 'nav a.login'});
|
|
1180
1189
|
* ```
|
|
1181
1190
|
*
|
|
1182
|
-
* @param {
|
|
1183
|
-
* @param {?
|
|
1191
|
+
* @param {string | object} locator clickable link or button located by text, or any element located by CSS|XPath|strict locator.
|
|
1192
|
+
* @param {?string | object} [context=null] (optional, `null` by default) element to search in CSS|XPath|Strict locator.
|
|
1184
1193
|
*
|
|
1185
1194
|
*
|
|
1186
1195
|
* {{ react }}
|
|
@@ -1216,8 +1225,8 @@ class Puppeteer extends Helper {
|
|
|
1216
1225
|
* ```js
|
|
1217
1226
|
* I.clickLink('Logout', '#nav');
|
|
1218
1227
|
* ```
|
|
1219
|
-
* @param {
|
|
1220
|
-
* @param {?
|
|
1228
|
+
* @param {string | object} locator clickable link or button located by text, or any element located by CSS|XPath|strict locator
|
|
1229
|
+
* @param {?string | object} [context=null] (optional, `null` by default) element to search in CSS|XPath|Strict locator
|
|
1221
1230
|
*
|
|
1222
1231
|
* {{ react }}
|
|
1223
1232
|
*/
|
|
@@ -1328,8 +1337,8 @@ class Puppeteer extends Helper {
|
|
|
1328
1337
|
* I.doubleClick('.btn.edit');
|
|
1329
1338
|
* ```
|
|
1330
1339
|
*
|
|
1331
|
-
* @param {
|
|
1332
|
-
* @param {?
|
|
1340
|
+
* @param {string | object} locator clickable link or button located by text, or any element located by CSS|XPath|strict locator.
|
|
1341
|
+
* @param {?string | object} [context=null] (optional, `null` by default) element to search in CSS|XPath|Strict locator.
|
|
1333
1342
|
*
|
|
1334
1343
|
*
|
|
1335
1344
|
* {{ react }}
|
|
@@ -1350,8 +1359,8 @@ class Puppeteer extends Helper {
|
|
|
1350
1359
|
* I.rightClick('Click me', '.context');
|
|
1351
1360
|
* ```
|
|
1352
1361
|
*
|
|
1353
|
-
* @param {
|
|
1354
|
-
* @param {?
|
|
1362
|
+
* @param {string | object} locator clickable element located by CSS|XPath|strict locator.
|
|
1363
|
+
* @param {?string | object} [context=null] (optional, `null` by default) element located by CSS|XPath|strict locator.
|
|
1355
1364
|
*
|
|
1356
1365
|
*
|
|
1357
1366
|
* {{ react }}
|
|
@@ -1371,8 +1380,8 @@ class Puppeteer extends Helper {
|
|
|
1371
1380
|
* I.checkOption('I Agree to Terms and Conditions');
|
|
1372
1381
|
* I.checkOption('agree', '//form');
|
|
1373
1382
|
* ```
|
|
1374
|
-
* @param {
|
|
1375
|
-
* @param {?
|
|
1383
|
+
* @param {string | object} field checkbox located by label | name | CSS | XPath | strict locator.
|
|
1384
|
+
* @param {?string | object} [context=null] (optional, `null` by default) element located by CSS | XPath | strict locator.
|
|
1376
1385
|
*/
|
|
1377
1386
|
async checkOption(field, context = null) {
|
|
1378
1387
|
const elm = await this._locateCheckable(field, context);
|
|
@@ -1396,8 +1405,8 @@ class Puppeteer extends Helper {
|
|
|
1396
1405
|
* I.uncheckOption('I Agree to Terms and Conditions');
|
|
1397
1406
|
* I.uncheckOption('agree', '//form');
|
|
1398
1407
|
* ```
|
|
1399
|
-
* @param {
|
|
1400
|
-
* @param {?
|
|
1408
|
+
* @param {string | object} field checkbox located by label | name | CSS | XPath | strict locator.
|
|
1409
|
+
* @param {?string | object} [context=null] (optional, `null` by default) element located by CSS | XPath | strict locator.
|
|
1401
1410
|
*/
|
|
1402
1411
|
async uncheckOption(field, context = null) {
|
|
1403
1412
|
const elm = await this._locateCheckable(field, context);
|
|
@@ -1419,7 +1428,7 @@ class Puppeteer extends Helper {
|
|
|
1419
1428
|
* I.seeCheckboxIsChecked({css: '#signup_form input[type=checkbox]'});
|
|
1420
1429
|
* ```
|
|
1421
1430
|
*
|
|
1422
|
-
* @param {
|
|
1431
|
+
* @param {string | object} field located by label|name|CSS|XPath|strict locator.
|
|
1423
1432
|
*
|
|
1424
1433
|
*/
|
|
1425
1434
|
async seeCheckboxIsChecked(field) {
|
|
@@ -1435,7 +1444,7 @@ class Puppeteer extends Helper {
|
|
|
1435
1444
|
* I.dontSeeCheckboxIsChecked('agree'); // located by name
|
|
1436
1445
|
* ```
|
|
1437
1446
|
*
|
|
1438
|
-
* @param {
|
|
1447
|
+
* @param {string | object} field located by label|name|CSS|XPath|strict locator.
|
|
1439
1448
|
*
|
|
1440
1449
|
*/
|
|
1441
1450
|
async dontSeeCheckboxIsChecked(field) {
|
|
@@ -1616,8 +1625,8 @@ class Puppeteer extends Helper {
|
|
|
1616
1625
|
* // or by strict locator
|
|
1617
1626
|
* I.fillField({css: 'form#login input[name=username]'}, 'John');
|
|
1618
1627
|
* ```
|
|
1619
|
-
* @param {
|
|
1620
|
-
* @param {
|
|
1628
|
+
* @param {string | object} field located by label|name|CSS|XPath|strict locator.
|
|
1629
|
+
* @param {string | object} value text value to fill.
|
|
1621
1630
|
*
|
|
1622
1631
|
* {{ react }}
|
|
1623
1632
|
*/
|
|
@@ -1644,7 +1653,7 @@ class Puppeteer extends Helper {
|
|
|
1644
1653
|
* I.clearField('user[email]');
|
|
1645
1654
|
* I.clearField('#email');
|
|
1646
1655
|
* ```
|
|
1647
|
-
* @param {
|
|
1656
|
+
* @param {string | object} editable field located by label|name|CSS|XPath|strict locator.
|
|
1648
1657
|
*
|
|
1649
1658
|
*/
|
|
1650
1659
|
async clearField(field) {
|
|
@@ -1658,7 +1667,7 @@ class Puppeteer extends Helper {
|
|
|
1658
1667
|
* ```js
|
|
1659
1668
|
* I.appendField('#myTextField', 'appended');
|
|
1660
1669
|
* ```
|
|
1661
|
-
* @param {
|
|
1670
|
+
* @param {string | object} field located by label|name|CSS|XPath|strict locator
|
|
1662
1671
|
* @param {string} value text value to append.
|
|
1663
1672
|
*
|
|
1664
1673
|
* {{ react }}
|
|
@@ -1681,7 +1690,7 @@ class Puppeteer extends Helper {
|
|
|
1681
1690
|
* I.seeInField('form input[type=hidden]','hidden_value');
|
|
1682
1691
|
* I.seeInField('#searchform input','Search');
|
|
1683
1692
|
* ```
|
|
1684
|
-
* @param {
|
|
1693
|
+
* @param {string | object} field located by label|name|CSS|XPath|strict locator.
|
|
1685
1694
|
* @param {string} value value to check.
|
|
1686
1695
|
*
|
|
1687
1696
|
*/
|
|
@@ -1698,7 +1707,7 @@ class Puppeteer extends Helper {
|
|
|
1698
1707
|
* I.dontSeeInField({ css: 'form input.email' }, 'user@user.com'); // field by CSS
|
|
1699
1708
|
* ```
|
|
1700
1709
|
*
|
|
1701
|
-
* @param {
|
|
1710
|
+
* @param {string | object} field located by label|name|CSS|XPath|strict locator.
|
|
1702
1711
|
* @param {string} value value to check.
|
|
1703
1712
|
*/
|
|
1704
1713
|
async dontSeeInField(field, value) {
|
|
@@ -1715,7 +1724,7 @@ class Puppeteer extends Helper {
|
|
|
1715
1724
|
* I.attachFile('form input[name=avatar]', 'data/avatar.jpg');
|
|
1716
1725
|
* ```
|
|
1717
1726
|
*
|
|
1718
|
-
* @param {
|
|
1727
|
+
* @param {string | object} locator field located by label|name|CSS|XPath|strict locator.
|
|
1719
1728
|
* @param {string} pathToFile local file path relative to codecept.json config file.
|
|
1720
1729
|
*
|
|
1721
1730
|
* > ⚠ 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.
|
|
@@ -1751,7 +1760,7 @@ class Puppeteer extends Helper {
|
|
|
1751
1760
|
* ```js
|
|
1752
1761
|
* I.selectOption('Which OS do you use?', ['Android', 'iOS']);
|
|
1753
1762
|
* ```
|
|
1754
|
-
* @param {
|
|
1763
|
+
* @param {string | object} select field located by label|name|CSS|XPath|strict locator.
|
|
1755
1764
|
* @param {string|Array<*>} option visible text or value of option.
|
|
1756
1765
|
*
|
|
1757
1766
|
*/
|
|
@@ -1792,7 +1801,7 @@ class Puppeteer extends Helper {
|
|
|
1792
1801
|
* let numOfElements = await I.grabNumberOfVisibleElements('p');
|
|
1793
1802
|
* ```
|
|
1794
1803
|
*
|
|
1795
|
-
* @param {
|
|
1804
|
+
* @param {string | object} locator located by CSS|XPath|strict locator.
|
|
1796
1805
|
* @returns {Promise<number>} number of visible elements
|
|
1797
1806
|
* {{ react }}
|
|
1798
1807
|
*/
|
|
@@ -1868,7 +1877,7 @@ class Puppeteer extends Helper {
|
|
|
1868
1877
|
* I.see('Register', {css: 'form.register'}); // use strict locator
|
|
1869
1878
|
* ```
|
|
1870
1879
|
* @param {string} text expected on page.
|
|
1871
|
-
* @param {?
|
|
1880
|
+
* @param {?string | object} [context=null] (optional, `null` by default) element located by CSS|Xpath|strict locator in which to search for text.
|
|
1872
1881
|
*
|
|
1873
1882
|
* {{ react }}
|
|
1874
1883
|
*/
|
|
@@ -1884,7 +1893,7 @@ class Puppeteer extends Helper {
|
|
|
1884
1893
|
* ```
|
|
1885
1894
|
*
|
|
1886
1895
|
* @param {string} text element value to check.
|
|
1887
|
-
* @param {
|
|
1896
|
+
* @param {(string | object)?} [context=null] element located by CSS|XPath|strict locator.
|
|
1888
1897
|
*/
|
|
1889
1898
|
async seeTextEquals(text, context = null) {
|
|
1890
1899
|
return proceedSee.call(this, 'assert', text, context, true);
|
|
@@ -1900,7 +1909,7 @@ class Puppeteer extends Helper {
|
|
|
1900
1909
|
* ```
|
|
1901
1910
|
*
|
|
1902
1911
|
* @param {string} text which is not present.
|
|
1903
|
-
* @param {
|
|
1912
|
+
* @param {string | object} [context] (optional) element located by CSS|XPath|strict locator in which to perfrom search.
|
|
1904
1913
|
*
|
|
1905
1914
|
*
|
|
1906
1915
|
* {{ react }}
|
|
@@ -1990,7 +1999,7 @@ class Puppeteer extends Helper {
|
|
|
1990
1999
|
* I.seeNumberOfElements('#submitBtn', 1);
|
|
1991
2000
|
* ```
|
|
1992
2001
|
*
|
|
1993
|
-
* @param {
|
|
2002
|
+
* @param {string | object} locator element located by CSS|XPath|strict locator.
|
|
1994
2003
|
* @param {number} num number of elements.
|
|
1995
2004
|
*
|
|
1996
2005
|
*
|
|
@@ -2009,7 +2018,7 @@ class Puppeteer extends Helper {
|
|
|
2009
2018
|
* I.seeNumberOfVisibleElements('.buttons', 3);
|
|
2010
2019
|
* ```
|
|
2011
2020
|
*
|
|
2012
|
-
* @param {
|
|
2021
|
+
* @param {string | object} locator element located by CSS|XPath|strict locator.
|
|
2013
2022
|
* @param {number} num number of elements.
|
|
2014
2023
|
*
|
|
2015
2024
|
*
|
|
@@ -2209,7 +2218,7 @@ class Puppeteer extends Helper {
|
|
|
2209
2218
|
* let pins = await I.grabTextFromAll('#pin li');
|
|
2210
2219
|
* ```
|
|
2211
2220
|
*
|
|
2212
|
-
* @param {
|
|
2221
|
+
* @param {string | object} locator element located by CSS|XPath|strict locator.
|
|
2213
2222
|
* @returns {Promise<string[]>} attribute value
|
|
2214
2223
|
*
|
|
2215
2224
|
* {{ react }}
|
|
@@ -2232,7 +2241,7 @@ class Puppeteer extends Helper {
|
|
|
2232
2241
|
* ```
|
|
2233
2242
|
* If multiple elements found returns first element.
|
|
2234
2243
|
*
|
|
2235
|
-
* @param {
|
|
2244
|
+
* @param {string | object} locator element located by CSS|XPath|strict locator.
|
|
2236
2245
|
* @returns {Promise<string>} attribute value
|
|
2237
2246
|
*
|
|
2238
2247
|
* {{ react }}
|
|
@@ -2254,7 +2263,7 @@ class Puppeteer extends Helper {
|
|
|
2254
2263
|
* ```js
|
|
2255
2264
|
* let inputs = await I.grabValueFromAll('//form/input');
|
|
2256
2265
|
* ```
|
|
2257
|
-
* @param {
|
|
2266
|
+
* @param {string | object} locator field located by label|name|CSS|XPath|strict locator.
|
|
2258
2267
|
* @returns {Promise<string[]>} attribute value
|
|
2259
2268
|
*
|
|
2260
2269
|
*/
|
|
@@ -2275,7 +2284,7 @@ class Puppeteer extends Helper {
|
|
|
2275
2284
|
* ```js
|
|
2276
2285
|
* let email = await I.grabValueFrom('input[name=email]');
|
|
2277
2286
|
* ```
|
|
2278
|
-
* @param {
|
|
2287
|
+
* @param {string | object} locator field located by label|name|CSS|XPath|strict locator.
|
|
2279
2288
|
* @returns {Promise<string>} attribute value
|
|
2280
2289
|
*
|
|
2281
2290
|
*/
|
|
@@ -2297,7 +2306,7 @@ class Puppeteer extends Helper {
|
|
|
2297
2306
|
* let postHTMLs = await I.grabHTMLFromAll('.post');
|
|
2298
2307
|
* ```
|
|
2299
2308
|
*
|
|
2300
|
-
* @param {
|
|
2309
|
+
* @param {string | object} element located by CSS|XPath|strict locator.
|
|
2301
2310
|
* @returns {Promise<string[]>} HTML code for an element
|
|
2302
2311
|
*
|
|
2303
2312
|
*/
|
|
@@ -2316,7 +2325,7 @@ class Puppeteer extends Helper {
|
|
|
2316
2325
|
* let postHTML = await I.grabHTMLFrom('#post');
|
|
2317
2326
|
* ```
|
|
2318
2327
|
*
|
|
2319
|
-
* @param {
|
|
2328
|
+
* @param {string | object} element located by CSS|XPath|strict locator.
|
|
2320
2329
|
* @returns {Promise<string>} HTML code for an element
|
|
2321
2330
|
*
|
|
2322
2331
|
*/
|
|
@@ -2338,7 +2347,7 @@ class Puppeteer extends Helper {
|
|
|
2338
2347
|
* const values = await I.grabCssPropertyFromAll('h3', 'font-weight');
|
|
2339
2348
|
* ```
|
|
2340
2349
|
*
|
|
2341
|
-
* @param {
|
|
2350
|
+
* @param {string | object} locator element located by CSS|XPath|strict locator.
|
|
2342
2351
|
* @param {string} cssProperty CSS property name.
|
|
2343
2352
|
* @returns {Promise<string[]>} CSS value
|
|
2344
2353
|
*
|
|
@@ -2361,7 +2370,7 @@ class Puppeteer extends Helper {
|
|
|
2361
2370
|
* const value = await I.grabCssPropertyFrom('h3', 'font-weight');
|
|
2362
2371
|
* ```
|
|
2363
2372
|
*
|
|
2364
|
-
* @param {
|
|
2373
|
+
* @param {string | object} locator element located by CSS|XPath|strict locator.
|
|
2365
2374
|
* @param {string} cssProperty CSS property name.
|
|
2366
2375
|
* @returns {Promise<string>} CSS value
|
|
2367
2376
|
*
|
|
@@ -2385,7 +2394,7 @@ class Puppeteer extends Helper {
|
|
|
2385
2394
|
* I.seeCssPropertiesOnElements('h3', { 'font-weight': "bold"});
|
|
2386
2395
|
* ```
|
|
2387
2396
|
*
|
|
2388
|
-
* @param {
|
|
2397
|
+
* @param {string | object} locator located by CSS|XPath|strict locator.
|
|
2389
2398
|
* @param {object} cssProperties object with CSS properties and their values to check.
|
|
2390
2399
|
* {{ react }}
|
|
2391
2400
|
*/
|
|
@@ -2431,7 +2440,7 @@ class Puppeteer extends Helper {
|
|
|
2431
2440
|
* I.seeAttributesOnElements('//form', { method: "post"});
|
|
2432
2441
|
* ```
|
|
2433
2442
|
*
|
|
2434
|
-
* @param {
|
|
2443
|
+
* @param {string | object} locator located by CSS|XPath|strict locator.
|
|
2435
2444
|
* @param {object} attributes attributes and their values to check.
|
|
2436
2445
|
* {{ react }}
|
|
2437
2446
|
*/
|
|
@@ -2471,7 +2480,7 @@ class Puppeteer extends Helper {
|
|
|
2471
2480
|
* I.dragSlider('#slider', -70);
|
|
2472
2481
|
* ```
|
|
2473
2482
|
*
|
|
2474
|
-
* @param {
|
|
2483
|
+
* @param {string | object} locator located by label|name|CSS|XPath|strict locator.
|
|
2475
2484
|
* @param {number} offsetX position to drag.
|
|
2476
2485
|
* {{ react }}
|
|
2477
2486
|
*/
|
|
@@ -2500,7 +2509,7 @@ class Puppeteer extends Helper {
|
|
|
2500
2509
|
* ```js
|
|
2501
2510
|
* let hints = await I.grabAttributeFromAll('.tooltip', 'title');
|
|
2502
2511
|
* ```
|
|
2503
|
-
* @param {
|
|
2512
|
+
* @param {string | object} locator element located by CSS|XPath|strict locator.
|
|
2504
2513
|
* @param {string} attr attribute name.
|
|
2505
2514
|
* @returns {Promise<string[]>} attribute value
|
|
2506
2515
|
*
|
|
@@ -2524,7 +2533,7 @@ class Puppeteer extends Helper {
|
|
|
2524
2533
|
* ```js
|
|
2525
2534
|
* let hint = await I.grabAttributeFrom('#tooltip', 'title');
|
|
2526
2535
|
* ```
|
|
2527
|
-
* @param {
|
|
2536
|
+
* @param {string | object} locator element located by CSS|XPath|strict locator.
|
|
2528
2537
|
* @param {string} attr attribute name.
|
|
2529
2538
|
* @returns {Promise<string>} attribute value
|
|
2530
2539
|
*
|
|
@@ -2548,7 +2557,7 @@ class Puppeteer extends Helper {
|
|
|
2548
2557
|
* I.saveElementScreenshot(`#submit`,'debug.png');
|
|
2549
2558
|
* ```
|
|
2550
2559
|
*
|
|
2551
|
-
* @param {
|
|
2560
|
+
* @param {string | object} locator element located by CSS|XPath|strict locator.
|
|
2552
2561
|
* @param {string} fileName file name to save.
|
|
2553
2562
|
*
|
|
2554
2563
|
*/
|
|
@@ -2620,7 +2629,7 @@ class Puppeteer extends Helper {
|
|
|
2620
2629
|
* Waits for element to become enabled (by default waits for 1sec).
|
|
2621
2630
|
* Element can be located by CSS or XPath.
|
|
2622
2631
|
*
|
|
2623
|
-
* @param {
|
|
2632
|
+
* @param {string | object} locator element located by CSS|XPath|strict locator.
|
|
2624
2633
|
* @param {number} [sec=1] (optional) time in seconds to wait, 1 by default.
|
|
2625
2634
|
*/
|
|
2626
2635
|
async waitForEnabled(locator, sec) {
|
|
@@ -2657,7 +2666,7 @@ class Puppeteer extends Helper {
|
|
|
2657
2666
|
* I.waitForValue('//input', "GoodValue");
|
|
2658
2667
|
* ```
|
|
2659
2668
|
*
|
|
2660
|
-
* @param {
|
|
2669
|
+
* @param {string | object} field input field.
|
|
2661
2670
|
* @param {string }value expected value.
|
|
2662
2671
|
* @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
|
|
2663
2672
|
*
|
|
@@ -2697,7 +2706,7 @@ class Puppeteer extends Helper {
|
|
|
2697
2706
|
* I.waitNumberOfVisibleElements('a', 3);
|
|
2698
2707
|
* ```
|
|
2699
2708
|
*
|
|
2700
|
-
* @param {
|
|
2709
|
+
* @param {string | object} locator element located by CSS|XPath|strict locator.
|
|
2701
2710
|
* @param {number} num number of elements.
|
|
2702
2711
|
* @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
|
|
2703
2712
|
* {{ react }}
|
|
@@ -2738,7 +2747,7 @@ class Puppeteer extends Helper {
|
|
|
2738
2747
|
* I.waitForClickable('.btn.continue', 5); // wait for 5 secs
|
|
2739
2748
|
* ```
|
|
2740
2749
|
*
|
|
2741
|
-
* @param {
|
|
2750
|
+
* @param {string | object} locator element located by CSS|XPath|strict locator.
|
|
2742
2751
|
* @param {number} [sec] (optional, `1` by default) time in seconds to wait
|
|
2743
2752
|
*/
|
|
2744
2753
|
async waitForClickable(locator, waitTimeout) {
|
|
@@ -2763,7 +2772,7 @@ class Puppeteer extends Helper {
|
|
|
2763
2772
|
* I.waitForElement('.btn.continue', 5); // wait for 5 secs
|
|
2764
2773
|
* ```
|
|
2765
2774
|
*
|
|
2766
|
-
* @param {
|
|
2775
|
+
* @param {string | object} locator element located by CSS|XPath|strict locator.
|
|
2767
2776
|
* @param {number} [sec] (optional, `1` by default) time in seconds to wait
|
|
2768
2777
|
* {{ react }}
|
|
2769
2778
|
*/
|
|
@@ -2791,7 +2800,7 @@ class Puppeteer extends Helper {
|
|
|
2791
2800
|
* I.waitForVisible('#popup');
|
|
2792
2801
|
* ```
|
|
2793
2802
|
*
|
|
2794
|
-
* @param {
|
|
2803
|
+
* @param {string | object} locator element located by CSS|XPath|strict locator.
|
|
2795
2804
|
* @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
|
|
2796
2805
|
*
|
|
2797
2806
|
*
|
|
@@ -2821,7 +2830,7 @@ class Puppeteer extends Helper {
|
|
|
2821
2830
|
* I.waitForInvisible('#popup');
|
|
2822
2831
|
* ```
|
|
2823
2832
|
*
|
|
2824
|
-
* @param {
|
|
2833
|
+
* @param {string | object} locator element located by CSS|XPath|strict locator.
|
|
2825
2834
|
* @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
|
|
2826
2835
|
*/
|
|
2827
2836
|
async waitForInvisible(locator, sec) {
|
|
@@ -2848,7 +2857,7 @@ class Puppeteer extends Helper {
|
|
|
2848
2857
|
* I.waitToHide('#popup');
|
|
2849
2858
|
* ```
|
|
2850
2859
|
*
|
|
2851
|
-
* @param {
|
|
2860
|
+
* @param {string | object} locator element located by CSS|XPath|strict locator.
|
|
2852
2861
|
* @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
|
|
2853
2862
|
*/
|
|
2854
2863
|
async waitToHide(locator, sec) {
|
|
@@ -2943,7 +2952,7 @@ class Puppeteer extends Helper {
|
|
|
2943
2952
|
*
|
|
2944
2953
|
* @param {string }text to wait for.
|
|
2945
2954
|
* @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
|
|
2946
|
-
* @param {
|
|
2955
|
+
* @param {string | object} [context] (optional) element located by CSS|XPath|strict locator.
|
|
2947
2956
|
*/
|
|
2948
2957
|
async waitForText(text, sec = null, context = null) {
|
|
2949
2958
|
const waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout;
|
|
@@ -3018,7 +3027,7 @@ class Puppeteer extends Helper {
|
|
|
3018
3027
|
* I.switchTo(); // switch back to main page
|
|
3019
3028
|
* ```
|
|
3020
3029
|
*
|
|
3021
|
-
* @param {?
|
|
3030
|
+
* @param {?string | object} [locator=null] (optional, `null` by default) element located by CSS|XPath|strict locator.
|
|
3022
3031
|
*/
|
|
3023
3032
|
async switchTo(locator) {
|
|
3024
3033
|
if (Number.isInteger(locator)) {
|
|
@@ -3119,7 +3128,7 @@ class Puppeteer extends Helper {
|
|
|
3119
3128
|
* I.waitForDetached('#popup');
|
|
3120
3129
|
* ```
|
|
3121
3130
|
*
|
|
3122
|
-
* @param {
|
|
3131
|
+
* @param {string | object} locator element located by CSS|XPath|strict locator.
|
|
3123
3132
|
* @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
|
|
3124
3133
|
*/
|
|
3125
3134
|
async waitForDetached(locator, sec) {
|
|
@@ -3192,7 +3201,7 @@ class Puppeteer extends Helper {
|
|
|
3192
3201
|
* const width = await I.grabElementBoundingRect('h3', 'width');
|
|
3193
3202
|
* // width == 527
|
|
3194
3203
|
* ```
|
|
3195
|
-
* @param {
|
|
3204
|
+
* @param {string | object} locator element located by CSS|XPath|strict locator.
|
|
3196
3205
|
* @param {string=} elementSize x, y, width or height of the given element.
|
|
3197
3206
|
* @returns {Promise<DOMRect>|Promise<number>} Element bounding rectangle
|
|
3198
3207
|
*
|
package/docs/build/REST.js
CHANGED
|
@@ -63,6 +63,12 @@ class REST extends Helper {
|
|
|
63
63
|
this.axios.defaults.headers = this.options.defaultHeaders;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
+
static _config() {
|
|
67
|
+
return [
|
|
68
|
+
{ name: 'endpoint', message: 'Endpoint of API you are going to test', default: 'http://localhost:3000/api' },
|
|
69
|
+
];
|
|
70
|
+
}
|
|
71
|
+
|
|
66
72
|
static _checkRequirements() {
|
|
67
73
|
try {
|
|
68
74
|
require('axios');
|
|
@@ -71,6 +77,33 @@ class REST extends Helper {
|
|
|
71
77
|
}
|
|
72
78
|
}
|
|
73
79
|
|
|
80
|
+
_before() {
|
|
81
|
+
this.headers = { ...this.options.defaultHeaders };
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Sets request headers for all requests of this test
|
|
86
|
+
*
|
|
87
|
+
* @param {object} headers headers list
|
|
88
|
+
*/
|
|
89
|
+
haveRequestHeaders(headers) {
|
|
90
|
+
this.headers = { ...headers, ...this.headers };
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Adds a header for Bearer authentication
|
|
95
|
+
*
|
|
96
|
+
* ```js
|
|
97
|
+
* // we use secret function to hide token from logs
|
|
98
|
+
* I.amBearerAuthenticated(secret('heregoestoken'))
|
|
99
|
+
* ```
|
|
100
|
+
*
|
|
101
|
+
* @param {string} accessToken Bearer access token
|
|
102
|
+
*/
|
|
103
|
+
amBearerAuthenticated(accessToken) {
|
|
104
|
+
this.haveRequestHeaders({ Authorization: `Bearer ${accessToken}` });
|
|
105
|
+
}
|
|
106
|
+
|
|
74
107
|
/**
|
|
75
108
|
* Executes axios request
|
|
76
109
|
*
|
|
@@ -111,6 +144,9 @@ class REST extends Helper {
|
|
|
111
144
|
this.debugSection('Response', `Response error. Status code: ${err.response.status}`);
|
|
112
145
|
response = err.response;
|
|
113
146
|
}
|
|
147
|
+
if (this.config.onResponse) {
|
|
148
|
+
await this.config.onResponse(response);
|
|
149
|
+
}
|
|
114
150
|
this.debugSection('Response', JSON.stringify(response.data));
|
|
115
151
|
return response;
|
|
116
152
|
}
|