codeceptjs 3.1.0 → 3.2.0
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 +129 -3
- package/README.md +2 -3
- package/bin/codecept.js +1 -0
- package/docs/advanced.md +94 -60
- package/docs/basics.md +1 -1
- package/docs/bdd.md +55 -1
- package/docs/build/Appium.js +106 -34
- package/docs/build/FileSystem.js +1 -0
- package/docs/build/Nightmare.js +48 -48
- package/docs/build/Playwright.js +97 -94
- package/docs/build/Protractor.js +68 -81
- package/docs/build/Puppeteer.js +91 -93
- package/docs/build/REST.js +1 -0
- package/docs/build/TestCafe.js +44 -44
- package/docs/build/WebDriver.js +71 -95
- package/docs/changelog.md +144 -2
- package/docs/commands.md +21 -7
- package/docs/configuration.md +15 -2
- package/docs/custom-helpers.md +1 -36
- package/docs/helpers/Appium.md +97 -95
- package/docs/helpers/FileSystem.md +1 -1
- package/docs/helpers/Playwright.md +16 -18
- package/docs/helpers/Puppeteer.md +18 -18
- package/docs/helpers/REST.md +3 -1
- package/docs/helpers/WebDriver.md +3 -19
- package/docs/mobile-react-native-locators.md +3 -0
- package/docs/playwright.md +40 -0
- package/docs/plugins.md +185 -68
- package/docs/reports.md +23 -5
- package/lib/actor.js +20 -2
- package/lib/codecept.js +15 -2
- package/lib/command/info.js +1 -1
- package/lib/config.js +13 -1
- package/lib/container.js +3 -1
- package/lib/data/dataTableArgument.js +35 -0
- package/lib/helper/Appium.js +49 -4
- package/lib/helper/FileSystem.js +1 -0
- package/lib/helper/Playwright.js +35 -22
- package/lib/helper/Protractor.js +2 -14
- package/lib/helper/Puppeteer.js +20 -19
- package/lib/helper/REST.js +1 -0
- package/lib/helper/WebDriver.js +2 -16
- package/lib/index.js +2 -0
- package/lib/interfaces/featureConfig.js +3 -0
- package/lib/interfaces/gherkin.js +7 -1
- package/lib/interfaces/scenarioConfig.js +4 -0
- package/lib/listener/helpers.js +1 -0
- package/lib/listener/steps.js +21 -3
- package/lib/listener/timeout.js +71 -0
- package/lib/locator.js +3 -0
- package/lib/mochaFactory.js +13 -9
- package/lib/plugin/allure.js +6 -1
- package/lib/plugin/{puppeteerCoverage.js → coverage.js} +10 -22
- package/lib/plugin/customLocator.js +2 -2
- package/lib/plugin/retryTo.js +130 -0
- package/lib/plugin/screenshotOnFail.js +1 -0
- package/lib/plugin/stepByStepReport.js +7 -0
- package/lib/plugin/stepTimeout.js +90 -0
- package/lib/plugin/subtitles.js +88 -0
- package/lib/plugin/tryTo.js +1 -1
- package/lib/recorder.js +21 -8
- package/lib/step.js +7 -2
- package/lib/store.js +2 -0
- package/lib/ui.js +2 -2
- package/package.json +6 -7
- package/typings/index.d.ts +8 -1
- package/typings/types.d.ts +198 -82
- package/docs/angular.md +0 -325
- package/docs/helpers/Protractor.md +0 -1658
- package/docs/webapi/waitUntil.mustache +0 -11
- package/typings/Protractor.d.ts +0 -16
package/docs/build/Playwright.js
CHANGED
|
@@ -80,6 +80,7 @@ const { createValueEngine, createDisabledEngine } = require('./extras/Playwright
|
|
|
80
80
|
* * `basicAuth`: (optional) the basic authentication to pass to base url. Example: {username: 'username', password: 'password'}
|
|
81
81
|
* * `windowSize`: (optional) default window size. Set a dimension like `640x480`.
|
|
82
82
|
* * `userAgent`: (optional) user-agent string.
|
|
83
|
+
* * `locale`: (optional) locale string. Example: 'en-GB', 'de-DE', 'fr-FR', ...
|
|
83
84
|
* * `manualStart`: (optional, default: false) - do not start browser before a test, start it manually inside a helper with `this.helpers["Playwright"]._startBrowser()`.
|
|
84
85
|
* * `chromium`: (optional) pass additional chromium options
|
|
85
86
|
* * `electron`: (optional) pass additional electron options
|
|
@@ -197,6 +198,19 @@ const { createValueEngine, createDisabledEngine } = require('./extras/Playwright
|
|
|
197
198
|
* }
|
|
198
199
|
* ```
|
|
199
200
|
*
|
|
201
|
+
* #### Example #7: Launch test with a specifc user locale
|
|
202
|
+
*
|
|
203
|
+
* ```js
|
|
204
|
+
* {
|
|
205
|
+
* helpers: {
|
|
206
|
+
* Playwright : {
|
|
207
|
+
* url: "http://localhost",
|
|
208
|
+
* locale: "fr-FR",
|
|
209
|
+
* }
|
|
210
|
+
* }
|
|
211
|
+
* }
|
|
212
|
+
* ```
|
|
213
|
+
*
|
|
200
214
|
* Note: When connecting to remote browser `show` and specific `chrome` options (e.g. `headless` or `devtools`) are ignored.
|
|
201
215
|
*
|
|
202
216
|
* ## Access From Helpers
|
|
@@ -354,6 +368,7 @@ class Playwright extends Helper {
|
|
|
354
368
|
if (this.options.restart && !this.options.manualStart) await this._startBrowser();
|
|
355
369
|
if (!this.isRunning && !this.options.manualStart) await this._startBrowser();
|
|
356
370
|
|
|
371
|
+
this.isAuthenticated = false;
|
|
357
372
|
if (this.isElectron) {
|
|
358
373
|
this.browserContext = this.browser.context();
|
|
359
374
|
} else if (this.userDataDir) {
|
|
@@ -364,8 +379,14 @@ class Playwright extends Helper {
|
|
|
364
379
|
acceptDownloads: true,
|
|
365
380
|
...this.options.emulate,
|
|
366
381
|
};
|
|
382
|
+
if (this.options.basicAuth) {
|
|
383
|
+
contextOptions.httpCredentials = this.options.basicAuth;
|
|
384
|
+
this.isAuthenticated = true;
|
|
385
|
+
}
|
|
367
386
|
if (this.options.recordVideo) contextOptions.recordVideo = this.options.recordVideo;
|
|
368
387
|
if (this.storageState) contextOptions.storageState = this.storageState;
|
|
388
|
+
if (this.options.userAgent) contextOptions.userAgent = this.options.userAgent;
|
|
389
|
+
if (this.options.locale) contextOptions.locale = this.options.locale;
|
|
369
390
|
this.browserContext = await this.browser.newContext(contextOptions); // Adding the HTTPSError ignore in the context so that we can ignore those errors
|
|
370
391
|
}
|
|
371
392
|
|
|
@@ -566,7 +587,7 @@ class Playwright extends Helper {
|
|
|
566
587
|
page.setDefaultNavigationTimeout(this.options.getPageTimeout);
|
|
567
588
|
this.context = await this.page;
|
|
568
589
|
this.contextLocator = null;
|
|
569
|
-
if (this.
|
|
590
|
+
if (this.options.browser === 'chrome') {
|
|
570
591
|
await page.bringToFront();
|
|
571
592
|
}
|
|
572
593
|
}
|
|
@@ -730,9 +751,9 @@ class Playwright extends Helper {
|
|
|
730
751
|
url = this.options.url + url;
|
|
731
752
|
}
|
|
732
753
|
|
|
733
|
-
if (this.
|
|
754
|
+
if (this.options.basicAuth && (this.isAuthenticated !== true)) {
|
|
734
755
|
if (url.includes(this.options.url)) {
|
|
735
|
-
await this.browserContext.setHTTPCredentials(this.
|
|
756
|
+
await this.browserContext.setHTTPCredentials(this.options.basicAuth);
|
|
736
757
|
this.isAuthenticated = true;
|
|
737
758
|
}
|
|
738
759
|
}
|
|
@@ -795,7 +816,7 @@ class Playwright extends Helper {
|
|
|
795
816
|
if (!customHeaders) {
|
|
796
817
|
throw new Error('Cannot send empty headers.');
|
|
797
818
|
}
|
|
798
|
-
return this.
|
|
819
|
+
return this.browserContext.setExtraHTTPHeaders(customHeaders);
|
|
799
820
|
}
|
|
800
821
|
|
|
801
822
|
/**
|
|
@@ -807,7 +828,7 @@ class Playwright extends Helper {
|
|
|
807
828
|
* I.moveCursorTo('#submit', 5,5);
|
|
808
829
|
* ```
|
|
809
830
|
*
|
|
810
|
-
* @param {
|
|
831
|
+
* @param {CodeceptJS.LocatorOrString} locator located by CSS|XPath|strict locator.
|
|
811
832
|
* @param {number} [offsetX=0] (optional, `0` by default) X-axis offset.
|
|
812
833
|
* @param {number} [offsetY=0] (optional, `0` by default) Y-axis offset.
|
|
813
834
|
*
|
|
@@ -830,8 +851,8 @@ class Playwright extends Helper {
|
|
|
830
851
|
* I.dragAndDrop('#dragHandle', '#container');
|
|
831
852
|
* ```
|
|
832
853
|
*
|
|
833
|
-
* @param {
|
|
834
|
-
* @param {
|
|
854
|
+
* @param {LocatorOrString} srcElement located by CSS|XPath|strict locator.
|
|
855
|
+
* @param {LocatorOrString} destElement located by CSS|XPath|strict locator.
|
|
835
856
|
*
|
|
836
857
|
*/
|
|
837
858
|
async dragAndDrop(srcElement, destElement) {
|
|
@@ -892,7 +913,7 @@ class Playwright extends Helper {
|
|
|
892
913
|
* I.scrollTo('#submit', 5, 5);
|
|
893
914
|
* ```
|
|
894
915
|
*
|
|
895
|
-
* @param {
|
|
916
|
+
* @param {CodeceptJS.LocatorOrString} locator located by CSS|XPath|strict locator.
|
|
896
917
|
* @param {number} [offsetX=0] (optional, `0` by default) X-axis offset.
|
|
897
918
|
* @param {number} [offsetY=0] (optional, `0` by default) Y-axis offset.
|
|
898
919
|
*/
|
|
@@ -1180,7 +1201,7 @@ class Playwright extends Helper {
|
|
|
1180
1201
|
* ```js
|
|
1181
1202
|
* I.seeElement('#modal');
|
|
1182
1203
|
* ```
|
|
1183
|
-
* @param {
|
|
1204
|
+
* @param {CodeceptJS.LocatorOrString} locator located by CSS|XPath|strict locator.
|
|
1184
1205
|
*
|
|
1185
1206
|
*/
|
|
1186
1207
|
async seeElement(locator) {
|
|
@@ -1196,7 +1217,7 @@ class Playwright extends Helper {
|
|
|
1196
1217
|
* I.dontSeeElement('.modal'); // modal is not shown
|
|
1197
1218
|
* ```
|
|
1198
1219
|
*
|
|
1199
|
-
* @param {
|
|
1220
|
+
* @param {CodeceptJS.LocatorOrString} locator located by CSS|XPath|Strict locator.
|
|
1200
1221
|
*
|
|
1201
1222
|
*/
|
|
1202
1223
|
async dontSeeElement(locator) {
|
|
@@ -1212,7 +1233,7 @@ class Playwright extends Helper {
|
|
|
1212
1233
|
* ```js
|
|
1213
1234
|
* I.seeElementInDOM('#modal');
|
|
1214
1235
|
* ```
|
|
1215
|
-
* @param {
|
|
1236
|
+
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
1216
1237
|
*
|
|
1217
1238
|
*/
|
|
1218
1239
|
async seeElementInDOM(locator) {
|
|
@@ -1227,7 +1248,7 @@ class Playwright extends Helper {
|
|
|
1227
1248
|
* I.dontSeeElementInDOM('.nav'); // checks that element is not on page visible or not
|
|
1228
1249
|
* ```
|
|
1229
1250
|
*
|
|
1230
|
-
* @param {
|
|
1251
|
+
* @param {CodeceptJS.LocatorOrString} locator located by CSS|XPath|Strict locator.
|
|
1231
1252
|
*/
|
|
1232
1253
|
async dontSeeElementInDOM(locator) {
|
|
1233
1254
|
const els = await this._locate(locator);
|
|
@@ -1287,8 +1308,8 @@ class Playwright extends Helper {
|
|
|
1287
1308
|
* I.click({css: 'nav a.login'});
|
|
1288
1309
|
* ```
|
|
1289
1310
|
*
|
|
1290
|
-
* @param {
|
|
1291
|
-
* @param {?
|
|
1311
|
+
* @param {CodeceptJS.LocatorOrString} locator clickable link or button located by text, or any element located by CSS|XPath|strict locator.
|
|
1312
|
+
* @param {?CodeceptJS.LocatorOrString} [context=null] (optional, `null` by default) element to search in CSS|XPath|Strict locator.
|
|
1292
1313
|
*
|
|
1293
1314
|
*
|
|
1294
1315
|
*
|
|
@@ -1332,8 +1353,8 @@ class Playwright extends Helper {
|
|
|
1332
1353
|
* I.forceClick({css: 'nav a.login'});
|
|
1333
1354
|
* ```
|
|
1334
1355
|
*
|
|
1335
|
-
* @param {
|
|
1336
|
-
* @param {?
|
|
1356
|
+
* @param {CodeceptJS.LocatorOrString} locator clickable link or button located by text, or any element located by CSS|XPath|strict locator.
|
|
1357
|
+
* @param {?CodeceptJS.LocatorOrString} [context=null] (optional, `null` by default) element to search in CSS|XPath|Strict locator.
|
|
1337
1358
|
*
|
|
1338
1359
|
*/
|
|
1339
1360
|
async forceClick(locator, context = null) {
|
|
@@ -1351,8 +1372,8 @@ class Playwright extends Helper {
|
|
|
1351
1372
|
* I.doubleClick('.btn.edit');
|
|
1352
1373
|
* ```
|
|
1353
1374
|
*
|
|
1354
|
-
* @param {
|
|
1355
|
-
* @param {?
|
|
1375
|
+
* @param {CodeceptJS.LocatorOrString} locator clickable link or button located by text, or any element located by CSS|XPath|strict locator.
|
|
1376
|
+
* @param {?CodeceptJS.LocatorOrString} [context=null] (optional, `null` by default) element to search in CSS|XPath|Strict locator.
|
|
1356
1377
|
*
|
|
1357
1378
|
*
|
|
1358
1379
|
*
|
|
@@ -1373,8 +1394,8 @@ class Playwright extends Helper {
|
|
|
1373
1394
|
* I.rightClick('Click me', '.context');
|
|
1374
1395
|
* ```
|
|
1375
1396
|
*
|
|
1376
|
-
* @param {
|
|
1377
|
-
* @param {?
|
|
1397
|
+
* @param {CodeceptJS.LocatorOrString} locator clickable element located by CSS|XPath|strict locator.
|
|
1398
|
+
* @param {?CodeceptJS.LocatorOrString} [context=null] (optional, `null` by default) element located by CSS|XPath|strict locator.
|
|
1378
1399
|
*
|
|
1379
1400
|
*
|
|
1380
1401
|
*
|
|
@@ -1394,8 +1415,8 @@ class Playwright extends Helper {
|
|
|
1394
1415
|
* I.checkOption('I Agree to Terms and Conditions');
|
|
1395
1416
|
* I.checkOption('agree', '//form');
|
|
1396
1417
|
* ```
|
|
1397
|
-
* @param {
|
|
1398
|
-
* @param {?
|
|
1418
|
+
* @param {CodeceptJS.LocatorOrString} field checkbox located by label | name | CSS | XPath | strict locator.
|
|
1419
|
+
* @param {?CodeceptJS.LocatorOrString} [context=null] (optional, `null` by default) element located by CSS | XPath | strict locator.
|
|
1399
1420
|
*/
|
|
1400
1421
|
async checkOption(field, context = null) {
|
|
1401
1422
|
const elm = await this._locateCheckable(field, context);
|
|
@@ -1419,8 +1440,8 @@ class Playwright extends Helper {
|
|
|
1419
1440
|
* I.uncheckOption('I Agree to Terms and Conditions');
|
|
1420
1441
|
* I.uncheckOption('agree', '//form');
|
|
1421
1442
|
* ```
|
|
1422
|
-
* @param {
|
|
1423
|
-
* @param {?
|
|
1443
|
+
* @param {CodeceptJS.LocatorOrString} field checkbox located by label | name | CSS | XPath | strict locator.
|
|
1444
|
+
* @param {?CodeceptJS.LocatorOrString} [context=null] (optional, `null` by default) element located by CSS | XPath | strict locator.
|
|
1424
1445
|
*/
|
|
1425
1446
|
async uncheckOption(field, context = null) {
|
|
1426
1447
|
const elm = await this._locateCheckable(field, context);
|
|
@@ -1442,7 +1463,7 @@ class Playwright extends Helper {
|
|
|
1442
1463
|
* I.seeCheckboxIsChecked({css: '#signup_form input[type=checkbox]'});
|
|
1443
1464
|
* ```
|
|
1444
1465
|
*
|
|
1445
|
-
* @param {
|
|
1466
|
+
* @param {CodeceptJS.LocatorOrString} field located by label|name|CSS|XPath|strict locator.
|
|
1446
1467
|
*
|
|
1447
1468
|
*/
|
|
1448
1469
|
async seeCheckboxIsChecked(field) {
|
|
@@ -1458,7 +1479,7 @@ class Playwright extends Helper {
|
|
|
1458
1479
|
* I.dontSeeCheckboxIsChecked('agree'); // located by name
|
|
1459
1480
|
* ```
|
|
1460
1481
|
*
|
|
1461
|
-
* @param {
|
|
1482
|
+
* @param {CodeceptJS.LocatorOrString} field located by label|name|CSS|XPath|strict locator.
|
|
1462
1483
|
*
|
|
1463
1484
|
*/
|
|
1464
1485
|
async dontSeeCheckboxIsChecked(field) {
|
|
@@ -1639,8 +1660,8 @@ class Playwright extends Helper {
|
|
|
1639
1660
|
* // or by strict locator
|
|
1640
1661
|
* I.fillField({css: 'form#login input[name=username]'}, 'John');
|
|
1641
1662
|
* ```
|
|
1642
|
-
* @param {
|
|
1643
|
-
* @param {
|
|
1663
|
+
* @param {CodeceptJS.LocatorOrString} field located by label|name|CSS|XPath|strict locator.
|
|
1664
|
+
* @param {CodeceptJS.StringOrSecret} value text value to fill.
|
|
1644
1665
|
*
|
|
1645
1666
|
*
|
|
1646
1667
|
*/
|
|
@@ -1667,7 +1688,7 @@ class Playwright extends Helper {
|
|
|
1667
1688
|
* I.clearField('user[email]');
|
|
1668
1689
|
* I.clearField('#email');
|
|
1669
1690
|
* ```
|
|
1670
|
-
* @param {
|
|
1691
|
+
* @param {LocatorOrString} editable field located by label|name|CSS|XPath|strict locator.
|
|
1671
1692
|
*
|
|
1672
1693
|
*/
|
|
1673
1694
|
async clearField(field) {
|
|
@@ -1681,7 +1702,7 @@ class Playwright extends Helper {
|
|
|
1681
1702
|
* ```js
|
|
1682
1703
|
* I.appendField('#myTextField', 'appended');
|
|
1683
1704
|
* ```
|
|
1684
|
-
* @param {
|
|
1705
|
+
* @param {CodeceptJS.LocatorOrString} field located by label|name|CSS|XPath|strict locator
|
|
1685
1706
|
* @param {string} value text value to append.
|
|
1686
1707
|
*
|
|
1687
1708
|
*
|
|
@@ -1704,7 +1725,7 @@ class Playwright extends Helper {
|
|
|
1704
1725
|
* I.seeInField('form input[type=hidden]','hidden_value');
|
|
1705
1726
|
* I.seeInField('#searchform input','Search');
|
|
1706
1727
|
* ```
|
|
1707
|
-
* @param {
|
|
1728
|
+
* @param {CodeceptJS.LocatorOrString} field located by label|name|CSS|XPath|strict locator.
|
|
1708
1729
|
* @param {string} value value to check.
|
|
1709
1730
|
*
|
|
1710
1731
|
*/
|
|
@@ -1721,7 +1742,7 @@ class Playwright extends Helper {
|
|
|
1721
1742
|
* I.dontSeeInField({ css: 'form input.email' }, 'user@user.com'); // field by CSS
|
|
1722
1743
|
* ```
|
|
1723
1744
|
*
|
|
1724
|
-
* @param {
|
|
1745
|
+
* @param {CodeceptJS.LocatorOrString} field located by label|name|CSS|XPath|strict locator.
|
|
1725
1746
|
* @param {string} value value to check.
|
|
1726
1747
|
*/
|
|
1727
1748
|
async dontSeeInField(field, value) {
|
|
@@ -1738,7 +1759,7 @@ class Playwright extends Helper {
|
|
|
1738
1759
|
* I.attachFile('form input[name=avatar]', 'data/avatar.jpg');
|
|
1739
1760
|
* ```
|
|
1740
1761
|
*
|
|
1741
|
-
* @param {
|
|
1762
|
+
* @param {CodeceptJS.LocatorOrString} locator field located by label|name|CSS|XPath|strict locator.
|
|
1742
1763
|
* @param {string} pathToFile local file path relative to codecept.json config file.
|
|
1743
1764
|
*
|
|
1744
1765
|
*/
|
|
@@ -1773,7 +1794,7 @@ class Playwright extends Helper {
|
|
|
1773
1794
|
* ```js
|
|
1774
1795
|
* I.selectOption('Which OS do you use?', ['Android', 'iOS']);
|
|
1775
1796
|
* ```
|
|
1776
|
-
* @param {
|
|
1797
|
+
* @param {LocatorOrString} select field located by label|name|CSS|XPath|strict locator.
|
|
1777
1798
|
* @param {string|Array<*>} option visible text or value of option.
|
|
1778
1799
|
*
|
|
1779
1800
|
*/
|
|
@@ -1814,7 +1835,7 @@ class Playwright extends Helper {
|
|
|
1814
1835
|
* let numOfElements = await I.grabNumberOfVisibleElements('p');
|
|
1815
1836
|
* ```
|
|
1816
1837
|
*
|
|
1817
|
-
* @param {
|
|
1838
|
+
* @param {CodeceptJS.LocatorOrString} locator located by CSS|XPath|strict locator.
|
|
1818
1839
|
* @returns {Promise<number>} number of visible elements
|
|
1819
1840
|
*
|
|
1820
1841
|
*/
|
|
@@ -1887,7 +1908,7 @@ class Playwright extends Helper {
|
|
|
1887
1908
|
* I.see('Register', {css: 'form.register'}); // use strict locator
|
|
1888
1909
|
* ```
|
|
1889
1910
|
* @param {string} text expected on page.
|
|
1890
|
-
* @param {?
|
|
1911
|
+
* @param {?CodeceptJS.LocatorOrString} [context=null] (optional, `null` by default) element located by CSS|Xpath|strict locator in which to search for text.
|
|
1891
1912
|
*
|
|
1892
1913
|
*
|
|
1893
1914
|
*/
|
|
@@ -1903,7 +1924,7 @@ class Playwright extends Helper {
|
|
|
1903
1924
|
* ```
|
|
1904
1925
|
*
|
|
1905
1926
|
* @param {string} text element value to check.
|
|
1906
|
-
* @param {
|
|
1927
|
+
* @param {CodeceptJS.LocatorOrString?} [context=null] element located by CSS|XPath|strict locator.
|
|
1907
1928
|
*/
|
|
1908
1929
|
async seeTextEquals(text, context = null) {
|
|
1909
1930
|
return proceedSee.call(this, 'assert', text, context, true);
|
|
@@ -1919,7 +1940,7 @@ class Playwright extends Helper {
|
|
|
1919
1940
|
* ```
|
|
1920
1941
|
*
|
|
1921
1942
|
* @param {string} text which is not present.
|
|
1922
|
-
* @param {
|
|
1943
|
+
* @param {CodeceptJS.LocatorOrString} [context] (optional) element located by CSS|XPath|strict locator in which to perfrom search.
|
|
1923
1944
|
*
|
|
1924
1945
|
*
|
|
1925
1946
|
*
|
|
@@ -2009,7 +2030,7 @@ class Playwright extends Helper {
|
|
|
2009
2030
|
* I.seeNumberOfElements('#submitBtn', 1);
|
|
2010
2031
|
* ```
|
|
2011
2032
|
*
|
|
2012
|
-
* @param {
|
|
2033
|
+
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
2013
2034
|
* @param {number} num number of elements.
|
|
2014
2035
|
*
|
|
2015
2036
|
*
|
|
@@ -2028,7 +2049,7 @@ class Playwright extends Helper {
|
|
|
2028
2049
|
* I.seeNumberOfVisibleElements('.buttons', 3);
|
|
2029
2050
|
* ```
|
|
2030
2051
|
*
|
|
2031
|
-
* @param {
|
|
2052
|
+
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
2032
2053
|
* @param {number} num number of elements.
|
|
2033
2054
|
*
|
|
2034
2055
|
*
|
|
@@ -2192,7 +2213,7 @@ class Playwright extends Helper {
|
|
|
2192
2213
|
* ```
|
|
2193
2214
|
* If multiple elements found returns first element.
|
|
2194
2215
|
*
|
|
2195
|
-
* @param {
|
|
2216
|
+
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
2196
2217
|
* @returns {Promise<string>} attribute value
|
|
2197
2218
|
*
|
|
2198
2219
|
*
|
|
@@ -2213,7 +2234,7 @@ class Playwright extends Helper {
|
|
|
2213
2234
|
* let pins = await I.grabTextFromAll('#pin li');
|
|
2214
2235
|
* ```
|
|
2215
2236
|
*
|
|
2216
|
-
* @param {
|
|
2237
|
+
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
2217
2238
|
* @returns {Promise<string[]>} attribute value
|
|
2218
2239
|
*
|
|
2219
2240
|
*
|
|
@@ -2236,7 +2257,7 @@ class Playwright extends Helper {
|
|
|
2236
2257
|
* ```js
|
|
2237
2258
|
* let email = await I.grabValueFrom('input[name=email]');
|
|
2238
2259
|
* ```
|
|
2239
|
-
* @param {
|
|
2260
|
+
* @param {CodeceptJS.LocatorOrString} locator field located by label|name|CSS|XPath|strict locator.
|
|
2240
2261
|
* @returns {Promise<string>} attribute value
|
|
2241
2262
|
*
|
|
2242
2263
|
*/
|
|
@@ -2254,7 +2275,7 @@ class Playwright extends Helper {
|
|
|
2254
2275
|
* ```js
|
|
2255
2276
|
* let inputs = await I.grabValueFromAll('//form/input');
|
|
2256
2277
|
* ```
|
|
2257
|
-
* @param {
|
|
2278
|
+
* @param {CodeceptJS.LocatorOrString} locator field located by label|name|CSS|XPath|strict locator.
|
|
2258
2279
|
* @returns {Promise<string[]>} attribute value
|
|
2259
2280
|
*
|
|
2260
2281
|
*/
|
|
@@ -2273,7 +2294,7 @@ class Playwright extends Helper {
|
|
|
2273
2294
|
* let postHTML = await I.grabHTMLFrom('#post');
|
|
2274
2295
|
* ```
|
|
2275
2296
|
*
|
|
2276
|
-
* @param {
|
|
2297
|
+
* @param {CodeceptJS.LocatorOrString} element located by CSS|XPath|strict locator.
|
|
2277
2298
|
* @returns {Promise<string>} HTML code for an element
|
|
2278
2299
|
*
|
|
2279
2300
|
*/
|
|
@@ -2292,7 +2313,7 @@ class Playwright extends Helper {
|
|
|
2292
2313
|
* let postHTMLs = await I.grabHTMLFromAll('.post');
|
|
2293
2314
|
* ```
|
|
2294
2315
|
*
|
|
2295
|
-
* @param {
|
|
2316
|
+
* @param {CodeceptJS.LocatorOrString} element located by CSS|XPath|strict locator.
|
|
2296
2317
|
* @returns {Promise<string[]>} HTML code for an element
|
|
2297
2318
|
*
|
|
2298
2319
|
*/
|
|
@@ -2311,7 +2332,7 @@ class Playwright extends Helper {
|
|
|
2311
2332
|
* const value = await I.grabCssPropertyFrom('h3', 'font-weight');
|
|
2312
2333
|
* ```
|
|
2313
2334
|
*
|
|
2314
|
-
* @param {
|
|
2335
|
+
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
2315
2336
|
* @param {string} cssProperty CSS property name.
|
|
2316
2337
|
* @returns {Promise<string>} CSS value
|
|
2317
2338
|
*
|
|
@@ -2332,7 +2353,7 @@ class Playwright extends Helper {
|
|
|
2332
2353
|
* const values = await I.grabCssPropertyFromAll('h3', 'font-weight');
|
|
2333
2354
|
* ```
|
|
2334
2355
|
*
|
|
2335
|
-
* @param {
|
|
2356
|
+
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
2336
2357
|
* @param {string} cssProperty CSS property name.
|
|
2337
2358
|
* @returns {Promise<string[]>} CSS value
|
|
2338
2359
|
*
|
|
@@ -2353,7 +2374,7 @@ class Playwright extends Helper {
|
|
|
2353
2374
|
* I.seeCssPropertiesOnElements('h3', { 'font-weight': "bold"});
|
|
2354
2375
|
* ```
|
|
2355
2376
|
*
|
|
2356
|
-
* @param {
|
|
2377
|
+
* @param {CodeceptJS.LocatorOrString} locator located by CSS|XPath|strict locator.
|
|
2357
2378
|
* @param {object} cssProperties object with CSS properties and their values to check.
|
|
2358
2379
|
*
|
|
2359
2380
|
*/
|
|
@@ -2398,7 +2419,7 @@ class Playwright extends Helper {
|
|
|
2398
2419
|
* I.seeAttributesOnElements('//form', { method: "post"});
|
|
2399
2420
|
* ```
|
|
2400
2421
|
*
|
|
2401
|
-
* @param {
|
|
2422
|
+
* @param {CodeceptJS.LocatorOrString} locator located by CSS|XPath|strict locator.
|
|
2402
2423
|
* @param {object} attributes attributes and their values to check.
|
|
2403
2424
|
*
|
|
2404
2425
|
*/
|
|
@@ -2436,7 +2457,7 @@ class Playwright extends Helper {
|
|
|
2436
2457
|
* I.dragSlider('#slider', -70);
|
|
2437
2458
|
* ```
|
|
2438
2459
|
*
|
|
2439
|
-
* @param {
|
|
2460
|
+
* @param {CodeceptJS.LocatorOrString} locator located by label|name|CSS|XPath|strict locator.
|
|
2440
2461
|
* @param {number} offsetX position to drag.
|
|
2441
2462
|
*
|
|
2442
2463
|
*/
|
|
@@ -2466,7 +2487,7 @@ class Playwright extends Helper {
|
|
|
2466
2487
|
* ```js
|
|
2467
2488
|
* let hint = await I.grabAttributeFrom('#tooltip', 'title');
|
|
2468
2489
|
* ```
|
|
2469
|
-
* @param {
|
|
2490
|
+
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
2470
2491
|
* @param {string} attr attribute name.
|
|
2471
2492
|
* @returns {Promise<string>} attribute value
|
|
2472
2493
|
*
|
|
@@ -2486,7 +2507,7 @@ class Playwright extends Helper {
|
|
|
2486
2507
|
* ```js
|
|
2487
2508
|
* let hints = await I.grabAttributeFromAll('.tooltip', 'title');
|
|
2488
2509
|
* ```
|
|
2489
|
-
* @param {
|
|
2510
|
+
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
2490
2511
|
* @param {string} attr attribute name.
|
|
2491
2512
|
* @returns {Promise<string[]>} attribute value
|
|
2492
2513
|
*
|
|
@@ -2513,7 +2534,7 @@ class Playwright extends Helper {
|
|
|
2513
2534
|
* I.saveElementScreenshot(`#submit`,'debug.png');
|
|
2514
2535
|
* ```
|
|
2515
2536
|
*
|
|
2516
|
-
* @param {
|
|
2537
|
+
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
2517
2538
|
* @param {string} fileName file name to save.
|
|
2518
2539
|
*
|
|
2519
2540
|
*
|
|
@@ -2565,12 +2586,17 @@ class Playwright extends Helper {
|
|
|
2565
2586
|
|
|
2566
2587
|
async _failed(test) {
|
|
2567
2588
|
await this._withinEnd();
|
|
2589
|
+
|
|
2590
|
+
if (!test.artifacts) {
|
|
2591
|
+
test.artifacts = {};
|
|
2592
|
+
}
|
|
2593
|
+
|
|
2568
2594
|
if (this.options.recordVideo && this.page.video()) {
|
|
2569
2595
|
test.artifacts.video = await this.page.video().path();
|
|
2570
2596
|
}
|
|
2571
2597
|
|
|
2572
2598
|
if (this.options.trace) {
|
|
2573
|
-
const path = `${global.output_dir}/trace/${clearString(test.title)}.zip`;
|
|
2599
|
+
const path = `${global.output_dir}/trace/${clearString(test.title).slice(0, 255)}.zip`;
|
|
2574
2600
|
await this.browserContext.tracing.stop({ path });
|
|
2575
2601
|
test.artifacts.trace = path;
|
|
2576
2602
|
}
|
|
@@ -2581,7 +2607,7 @@ class Playwright extends Helper {
|
|
|
2581
2607
|
if (this.options.keepVideoForPassedTests) {
|
|
2582
2608
|
test.artifacts.video = await this.page.video().path();
|
|
2583
2609
|
} else {
|
|
2584
|
-
this.page.video().delete();
|
|
2610
|
+
this.page.video().delete().catch(e => {});
|
|
2585
2611
|
}
|
|
2586
2612
|
}
|
|
2587
2613
|
|
|
@@ -2615,7 +2641,7 @@ class Playwright extends Helper {
|
|
|
2615
2641
|
* Waits for element to become enabled (by default waits for 1sec).
|
|
2616
2642
|
* Element can be located by CSS or XPath.
|
|
2617
2643
|
*
|
|
2618
|
-
* @param {
|
|
2644
|
+
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
2619
2645
|
* @param {number} [sec=1] (optional) time in seconds to wait, 1 by default.
|
|
2620
2646
|
*/
|
|
2621
2647
|
async waitForEnabled(locator, sec) {
|
|
@@ -2648,7 +2674,7 @@ class Playwright extends Helper {
|
|
|
2648
2674
|
* I.waitForValue('//input', "GoodValue");
|
|
2649
2675
|
* ```
|
|
2650
2676
|
*
|
|
2651
|
-
* @param {
|
|
2677
|
+
* @param {LocatorOrString} field input field.
|
|
2652
2678
|
* @param {string }value expected value.
|
|
2653
2679
|
* @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
|
|
2654
2680
|
*
|
|
@@ -2684,7 +2710,7 @@ class Playwright extends Helper {
|
|
|
2684
2710
|
* I.waitNumberOfVisibleElements('a', 3);
|
|
2685
2711
|
* ```
|
|
2686
2712
|
*
|
|
2687
|
-
* @param {
|
|
2713
|
+
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
2688
2714
|
* @param {number} num number of elements.
|
|
2689
2715
|
* @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
|
|
2690
2716
|
*
|
|
@@ -2725,7 +2751,7 @@ class Playwright extends Helper {
|
|
|
2725
2751
|
* I.waitForClickable('.btn.continue', 5); // wait for 5 secs
|
|
2726
2752
|
* ```
|
|
2727
2753
|
*
|
|
2728
|
-
* @param {
|
|
2754
|
+
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
2729
2755
|
* @param {number} [sec] (optional, `1` by default) time in seconds to wait
|
|
2730
2756
|
*/
|
|
2731
2757
|
async waitForClickable(locator, waitTimeout) {
|
|
@@ -2742,7 +2768,7 @@ class Playwright extends Helper {
|
|
|
2742
2768
|
* I.waitForElement('.btn.continue', 5); // wait for 5 secs
|
|
2743
2769
|
* ```
|
|
2744
2770
|
*
|
|
2745
|
-
* @param {
|
|
2771
|
+
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
2746
2772
|
* @param {number} [sec] (optional, `1` by default) time in seconds to wait
|
|
2747
2773
|
*
|
|
2748
2774
|
*/
|
|
@@ -2765,7 +2791,7 @@ class Playwright extends Helper {
|
|
|
2765
2791
|
* I.waitForVisible('#popup');
|
|
2766
2792
|
* ```
|
|
2767
2793
|
*
|
|
2768
|
-
* @param {
|
|
2794
|
+
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
2769
2795
|
* @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
|
|
2770
2796
|
*
|
|
2771
2797
|
*
|
|
@@ -2789,7 +2815,7 @@ class Playwright extends Helper {
|
|
|
2789
2815
|
* I.waitForInvisible('#popup');
|
|
2790
2816
|
* ```
|
|
2791
2817
|
*
|
|
2792
|
-
* @param {
|
|
2818
|
+
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
2793
2819
|
* @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
|
|
2794
2820
|
*/
|
|
2795
2821
|
async waitForInvisible(locator, sec) {
|
|
@@ -2810,7 +2836,7 @@ class Playwright extends Helper {
|
|
|
2810
2836
|
* I.waitToHide('#popup');
|
|
2811
2837
|
* ```
|
|
2812
2838
|
*
|
|
2813
|
-
* @param {
|
|
2839
|
+
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
2814
2840
|
* @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
|
|
2815
2841
|
*/
|
|
2816
2842
|
async waitToHide(locator, sec) {
|
|
@@ -2899,7 +2925,7 @@ class Playwright extends Helper {
|
|
|
2899
2925
|
*
|
|
2900
2926
|
* @param {string }text to wait for.
|
|
2901
2927
|
* @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
|
|
2902
|
-
* @param {
|
|
2928
|
+
* @param {CodeceptJS.LocatorOrString} [context] (optional) element located by CSS|XPath|strict locator.
|
|
2903
2929
|
*/
|
|
2904
2930
|
async waitForText(text, sec = null, context = null) {
|
|
2905
2931
|
const waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout;
|
|
@@ -2946,11 +2972,11 @@ class Playwright extends Helper {
|
|
|
2946
2972
|
}
|
|
2947
2973
|
|
|
2948
2974
|
/**
|
|
2949
|
-
* Waits for a network
|
|
2975
|
+
* Waits for a network response.
|
|
2950
2976
|
*
|
|
2951
2977
|
* ```js
|
|
2952
2978
|
* I.waitForResponse('http://example.com/resource');
|
|
2953
|
-
* I.waitForResponse(
|
|
2979
|
+
* I.waitForResponse(response => response.url() === 'https://example.com' && response.status() === 200);
|
|
2954
2980
|
* ```
|
|
2955
2981
|
*
|
|
2956
2982
|
* @param {string|function} urlOrPredicate
|
|
@@ -2969,7 +2995,7 @@ class Playwright extends Helper {
|
|
|
2969
2995
|
* I.switchTo(); // switch back to main page
|
|
2970
2996
|
* ```
|
|
2971
2997
|
*
|
|
2972
|
-
* @param {?
|
|
2998
|
+
* @param {?CodeceptJS.LocatorOrString} [locator=null] (optional, `null` by default) element located by CSS|XPath|strict locator.
|
|
2973
2999
|
*/
|
|
2974
3000
|
async switchTo(locator) {
|
|
2975
3001
|
if (Number.isInteger(locator)) {
|
|
@@ -3059,26 +3085,6 @@ class Playwright extends Helper {
|
|
|
3059
3085
|
return this.page.waitForNavigation(opts);
|
|
3060
3086
|
}
|
|
3061
3087
|
|
|
3062
|
-
/**
|
|
3063
|
-
* Waits for a function to return true (waits for 1sec by default).
|
|
3064
|
-
*
|
|
3065
|
-
* ```js
|
|
3066
|
-
* I.waitUntil(() => window.requests == 0);
|
|
3067
|
-
* I.waitUntil(() => window.requests == 0, 5);
|
|
3068
|
-
* ```
|
|
3069
|
-
*
|
|
3070
|
-
* @param {function|string} fn function which is executed in browser context.
|
|
3071
|
-
* @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
|
|
3072
|
-
* @param {string} [timeoutMsg=''] message to show in case of timeout fail.
|
|
3073
|
-
* @param {?number} [interval=null]
|
|
3074
|
-
*/
|
|
3075
|
-
async waitUntil(fn, sec = null) {
|
|
3076
|
-
console.log('This method will remove in CodeceptJS 1.4; use `waitForFunction` instead!');
|
|
3077
|
-
const waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout;
|
|
3078
|
-
const context = await this._getContext();
|
|
3079
|
-
return context.waitForFunction(fn, { timeout: waitTimeout });
|
|
3080
|
-
}
|
|
3081
|
-
|
|
3082
3088
|
async waitUntilExists(locator, sec) {
|
|
3083
3089
|
console.log(`waitUntilExists deprecated:
|
|
3084
3090
|
* use 'waitForElement' to wait for element to be attached
|
|
@@ -3094,7 +3100,7 @@ class Playwright extends Helper {
|
|
|
3094
3100
|
* I.waitForDetached('#popup');
|
|
3095
3101
|
* ```
|
|
3096
3102
|
*
|
|
3097
|
-
* @param {
|
|
3103
|
+
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
3098
3104
|
* @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
|
|
3099
3105
|
*/
|
|
3100
3106
|
async waitForDetached(locator, sec) {
|
|
@@ -3164,7 +3170,7 @@ class Playwright extends Helper {
|
|
|
3164
3170
|
* const width = await I.grabElementBoundingRect('h3', 'width');
|
|
3165
3171
|
* // width == 527
|
|
3166
3172
|
* ```
|
|
3167
|
-
* @param {
|
|
3173
|
+
* @param {LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
3168
3174
|
* @param {string=} elementSize x, y, width or height of the given element.
|
|
3169
3175
|
* @returns {Promise<DOMRect>|Promise<number>} Element bounding rectangle
|
|
3170
3176
|
*
|
|
@@ -3541,13 +3547,10 @@ async function targetCreatedHandler(page) {
|
|
|
3541
3547
|
});
|
|
3542
3548
|
});
|
|
3543
3549
|
page.on('console', (msg) => {
|
|
3544
|
-
this.debugSection(`Browser:${ucfirst(msg.type())}`, (msg._text || '') + msg.args().join(' '));
|
|
3550
|
+
this.debugSection(`Browser:${ucfirst(msg.type())}`, (msg.text && msg.text() || msg._text || '') + msg.args().join(' '));
|
|
3545
3551
|
consoleLogStore.add(msg);
|
|
3546
3552
|
});
|
|
3547
3553
|
|
|
3548
|
-
if (this.options.userAgent) {
|
|
3549
|
-
await page.setUserAgent(this.options.userAgent);
|
|
3550
|
-
}
|
|
3551
3554
|
if (this.options.windowSize && this.options.windowSize.indexOf('x') > 0 && this._getType() === 'Browser') {
|
|
3552
3555
|
await page.setViewportSize(parseWindowSize(this.options.windowSize));
|
|
3553
3556
|
}
|