codeceptjs 3.3.0 → 3.3.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 +39 -1
- package/README.md +26 -0
- package/docs/api.md +1 -1
- package/docs/bdd.md +1 -0
- package/docs/best.md +1 -1
- package/docs/build/ApiDataFactory.js +4 -3
- package/docs/build/Appium.js +26 -11
- package/docs/build/GraphQL.js +4 -2
- package/docs/build/GraphQLDataFactory.js +3 -3
- package/docs/build/JSONResponse.js +1 -1
- package/docs/build/Nightmare.js +52 -23
- package/docs/build/Playwright.js +126 -48
- package/docs/build/Protractor.js +70 -32
- package/docs/build/Puppeteer.js +78 -35
- package/docs/build/REST.js +4 -1
- package/docs/build/TestCafe.js +53 -22
- package/docs/build/WebDriver.js +115 -65
- package/docs/changelog.md +39 -1
- package/docs/custom-helpers.md +1 -1
- package/docs/data.md +2 -2
- package/docs/helpers/ApiDataFactory.md +7 -3
- package/docs/helpers/Appium.md +113 -15
- package/docs/helpers/GraphQL.md +6 -0
- package/docs/helpers/GraphQLDataFactory.md +3 -3
- package/docs/helpers/JSONResponse.md +1 -1
- package/docs/helpers/Nightmare.md +131 -29
- package/docs/helpers/Playwright.md +424 -215
- package/docs/helpers/Puppeteer.md +229 -92
- package/docs/helpers/REST.md +1 -1
- package/docs/helpers/TestCafe.md +166 -62
- package/docs/helpers/WebDriver.md +254 -103
- package/docs/index.md +1 -1
- package/docs/locators.md +1 -1
- package/docs/webapi/amOnPage.mustache +2 -1
- package/docs/webapi/appendField.mustache +2 -1
- package/docs/webapi/attachFile.mustache +2 -1
- package/docs/webapi/checkOption.mustache +2 -1
- package/docs/webapi/clearCookie.mustache +2 -1
- package/docs/webapi/clearField.mustache +1 -0
- package/docs/webapi/click.mustache +2 -1
- package/docs/webapi/clickLink.mustache +2 -1
- package/docs/webapi/closeCurrentTab.mustache +6 -4
- package/docs/webapi/closeOtherTabs.mustache +6 -4
- package/docs/webapi/dontSee.mustache +1 -0
- package/docs/webapi/dontSeeCheckboxIsChecked.mustache +1 -0
- package/docs/webapi/dontSeeCookie.mustache +2 -1
- package/docs/webapi/dontSeeCurrentUrlEquals.mustache +2 -1
- package/docs/webapi/dontSeeElement.mustache +2 -1
- package/docs/webapi/dontSeeElementInDOM.mustache +2 -1
- package/docs/webapi/dontSeeInCurrentUrl.mustache +2 -1
- package/docs/webapi/dontSeeInField.mustache +2 -1
- package/docs/webapi/dontSeeInSource.mustache +1 -0
- package/docs/webapi/dontSeeInTitle.mustache +2 -1
- package/docs/webapi/doubleClick.mustache +1 -0
- package/docs/webapi/downloadFile.mustache +2 -1
- package/docs/webapi/dragAndDrop.mustache +1 -0
- package/docs/webapi/dragSlider.mustache +2 -1
- package/docs/webapi/fillField.mustache +1 -0
- package/docs/webapi/forceClick.mustache +1 -0
- package/docs/webapi/forceRightClick.mustache +1 -0
- package/docs/webapi/grabDataFromPerformanceTiming.mustache +2 -1
- package/docs/webapi/moveCursorTo.mustache +1 -0
- package/docs/webapi/openNewTab.mustache +6 -4
- package/docs/webapi/pressKey.mustache +2 -1
- package/docs/webapi/pressKeyDown.mustache +1 -0
- package/docs/webapi/pressKeyUp.mustache +1 -0
- package/docs/webapi/pressKeyWithKeyNormalization.mustache +1 -0
- package/docs/webapi/refreshPage.mustache +1 -0
- package/docs/webapi/resizeWindow.mustache +2 -1
- package/docs/webapi/rightClick.mustache +1 -0
- package/docs/webapi/saveElementScreenshot.mustache +1 -0
- package/docs/webapi/saveScreenshot.mustache +2 -1
- package/docs/webapi/say.mustache +2 -1
- package/docs/webapi/scrollIntoView.mustache +1 -0
- package/docs/webapi/scrollPageToBottom.mustache +1 -0
- package/docs/webapi/scrollPageToTop.mustache +1 -0
- package/docs/webapi/scrollTo.mustache +2 -1
- package/docs/webapi/see.mustache +2 -1
- package/docs/webapi/seeAttributesOnElements.mustache +2 -1
- package/docs/webapi/seeCheckboxIsChecked.mustache +1 -0
- package/docs/webapi/seeCookie.mustache +1 -0
- package/docs/webapi/seeCssPropertiesOnElements.mustache +2 -1
- package/docs/webapi/seeCurrentUrlEquals.mustache +2 -1
- package/docs/webapi/seeElement.mustache +2 -1
- package/docs/webapi/seeElementInDOM.mustache +1 -0
- package/docs/webapi/seeInCurrentUrl.mustache +2 -1
- package/docs/webapi/seeInField.mustache +1 -0
- package/docs/webapi/seeInPopup.mustache +1 -0
- package/docs/webapi/seeInSource.mustache +2 -1
- package/docs/webapi/seeInTitle.mustache +2 -1
- package/docs/webapi/seeNumberOfElements.mustache +1 -0
- package/docs/webapi/seeNumberOfVisibleElements.mustache +1 -0
- package/docs/webapi/seeTextEquals.mustache +2 -1
- package/docs/webapi/seeTitleEquals.mustache +6 -5
- package/docs/webapi/selectOption.mustache +1 -0
- package/docs/webapi/setCookie.mustache +1 -0
- package/docs/webapi/setGeoLocation.mustache +1 -0
- package/docs/webapi/switchTo.mustache +2 -1
- package/docs/webapi/switchToNextTab.mustache +8 -7
- package/docs/webapi/switchToPreviousTab.mustache +8 -7
- package/docs/webapi/type.mustache +1 -0
- package/docs/webapi/uncheckOption.mustache +2 -1
- package/docs/webapi/wait.mustache +2 -1
- package/docs/webapi/waitForClickable.mustache +2 -1
- package/docs/webapi/waitForDetached.mustache +2 -1
- package/docs/webapi/waitForElement.mustache +2 -1
- package/docs/webapi/waitForEnabled.mustache +2 -1
- package/docs/webapi/waitForFunction.mustache +1 -0
- package/docs/webapi/waitForInvisible.mustache +2 -1
- package/docs/webapi/waitForText.mustache +2 -1
- package/docs/webapi/waitForValue.mustache +1 -0
- package/docs/webapi/waitForVisible.mustache +1 -0
- package/docs/webapi/waitInUrl.mustache +2 -1
- package/docs/webapi/waitNumberOfVisibleElements.mustache +2 -1
- package/docs/webapi/waitToHide.mustache +2 -1
- package/docs/webapi/waitUrlEquals.mustache +2 -1
- package/lib/command/definitions.js +9 -0
- package/lib/command/run.js +2 -2
- package/lib/command/workers/runTests.js +40 -0
- package/lib/helper/ApiDataFactory.js +4 -3
- package/lib/helper/Appium.js +7 -2
- package/lib/helper/GraphQL.js +4 -2
- package/lib/helper/GraphQLDataFactory.js +3 -3
- package/lib/helper/JSONResponse.js +1 -1
- package/lib/helper/Playwright.js +49 -13
- package/lib/helper/REST.js +4 -1
- package/lib/helper/WebDriver.js +6 -0
- package/lib/interfaces/bdd.js +5 -0
- package/lib/listener/steps.js +1 -0
- package/lib/plugin/fakerTransform.js +1 -1
- package/lib/plugin/stepByStepReport.js +8 -6
- package/lib/workers.js +12 -0
- package/package.json +3 -3
- package/typings/types.d.ts +558 -607
package/docs/build/Playwright.js
CHANGED
|
@@ -92,6 +92,7 @@ const { createValueEngine, createDisabledEngine } = require('./extras/Playwright
|
|
|
92
92
|
* * `waitForTimeout`: (optional) default wait* timeout in ms. Default: 1000.
|
|
93
93
|
* * `basicAuth`: (optional) the basic authentication to pass to base url. Example: {username: 'username', password: 'password'}
|
|
94
94
|
* * `windowSize`: (optional) default window size. Set a dimension like `640x480`.
|
|
95
|
+
* * `colorScheme`: (optional) default color scheme. Possible values: `dark` | `light` | `no-preference`.
|
|
95
96
|
* * `userAgent`: (optional) user-agent string.
|
|
96
97
|
* * `locale`: (optional) locale string. Example: 'en-GB', 'de-DE', 'fr-FR', ...
|
|
97
98
|
* * `manualStart`: (optional, default: false) - do not start browser before a test, start it manually inside a helper with `this.helpers["Playwright"]._startBrowser()`.
|
|
@@ -212,7 +213,7 @@ const { createValueEngine, createDisabledEngine } = require('./extras/Playwright
|
|
|
212
213
|
* }
|
|
213
214
|
* ```
|
|
214
215
|
*
|
|
215
|
-
* #### Example #7: Launch test with a
|
|
216
|
+
* #### Example #7: Launch test with a specific user locale
|
|
216
217
|
*
|
|
217
218
|
* ```js
|
|
218
219
|
* {
|
|
@@ -225,6 +226,19 @@ const { createValueEngine, createDisabledEngine } = require('./extras/Playwright
|
|
|
225
226
|
* }
|
|
226
227
|
* ```
|
|
227
228
|
*
|
|
229
|
+
* * #### Example #8: Launch test with a specific color scheme
|
|
230
|
+
*
|
|
231
|
+
* ```js
|
|
232
|
+
* {
|
|
233
|
+
* helpers: {
|
|
234
|
+
* Playwright : {
|
|
235
|
+
* url: "http://localhost",
|
|
236
|
+
* colorScheme: "dark",
|
|
237
|
+
* }
|
|
238
|
+
* }
|
|
239
|
+
* }
|
|
240
|
+
* ```
|
|
241
|
+
*
|
|
228
242
|
* Note: When connecting to remote browser `show` and specific `chrome` options (e.g. `headless` or `devtools`) are ignored.
|
|
229
243
|
*
|
|
230
244
|
* ## Access From Helpers
|
|
@@ -273,7 +287,7 @@ class Playwright extends Helper {
|
|
|
273
287
|
waitForAction: 100,
|
|
274
288
|
waitForTimeout: 1000,
|
|
275
289
|
pressKeyDelay: 10,
|
|
276
|
-
timeout:
|
|
290
|
+
timeout: 5000,
|
|
277
291
|
fullPageScreenshots: false,
|
|
278
292
|
disableScreenshots: false,
|
|
279
293
|
ignoreLog: ['warning', 'log'],
|
|
@@ -411,6 +425,7 @@ class Playwright extends Helper {
|
|
|
411
425
|
if (this.storageState) contextOptions.storageState = this.storageState;
|
|
412
426
|
if (this.options.userAgent) contextOptions.userAgent = this.options.userAgent;
|
|
413
427
|
if (this.options.locale) contextOptions.locale = this.options.locale;
|
|
428
|
+
if (this.options.colorScheme) contextOptions.colorScheme = this.options.colorScheme;
|
|
414
429
|
if (!this.browserContext || !restartsSession()) {
|
|
415
430
|
this.browserContext = await this.browser.newContext(contextOptions); // Adding the HTTPSError ignore in the context so that we can ignore those errors
|
|
416
431
|
}
|
|
@@ -539,6 +554,7 @@ class Playwright extends Helper {
|
|
|
539
554
|
*
|
|
540
555
|
* @param {string} description used to show in logs.
|
|
541
556
|
* @param {function} fn async function that executed with Playwright helper as argument
|
|
557
|
+
* @return {Promise<any>}
|
|
542
558
|
*/
|
|
543
559
|
usePlaywrightTo(description, fn) {
|
|
544
560
|
return this._useTo(...arguments);
|
|
@@ -553,6 +569,7 @@ class Playwright extends Helper {
|
|
|
553
569
|
* I.click('#triggerPopup');
|
|
554
570
|
* I.acceptPopup();
|
|
555
571
|
* ```
|
|
572
|
+
* @return {Promise<any>}
|
|
556
573
|
*/
|
|
557
574
|
amAcceptingPopups() {
|
|
558
575
|
popupStore.actionType = 'accept';
|
|
@@ -562,6 +579,7 @@ class Playwright extends Helper {
|
|
|
562
579
|
* Accepts the active JavaScript native popup window, as created by window.alert|window.confirm|window.prompt.
|
|
563
580
|
* Don't confuse popups with modal windows, as created by [various
|
|
564
581
|
* libraries](http://jster.net/category/windows-modals-popups).
|
|
582
|
+
* @return {Promise<any>}
|
|
565
583
|
*/
|
|
566
584
|
acceptPopup() {
|
|
567
585
|
popupStore.assertPopupActionType('accept');
|
|
@@ -576,6 +594,7 @@ class Playwright extends Helper {
|
|
|
576
594
|
* I.click('#triggerPopup');
|
|
577
595
|
* I.cancelPopup();
|
|
578
596
|
* ```
|
|
597
|
+
* @return {Promise<any>}
|
|
579
598
|
*/
|
|
580
599
|
amCancellingPopups() {
|
|
581
600
|
popupStore.actionType = 'cancel';
|
|
@@ -583,6 +602,7 @@ class Playwright extends Helper {
|
|
|
583
602
|
|
|
584
603
|
/**
|
|
585
604
|
* Dismisses the active JavaScript popup, as created by window.alert|window.confirm|window.prompt.
|
|
605
|
+
* @return {Promise<any>}
|
|
586
606
|
*/
|
|
587
607
|
cancelPopup() {
|
|
588
608
|
popupStore.assertPopupActionType('cancel');
|
|
@@ -596,7 +616,7 @@ class Playwright extends Helper {
|
|
|
596
616
|
* I.seeInPopup('Popup text');
|
|
597
617
|
* ```
|
|
598
618
|
* @param {string} text value to check.
|
|
599
|
-
*
|
|
619
|
+
* @return {Promise<any>}
|
|
600
620
|
*/
|
|
601
621
|
async seeInPopup(text) {
|
|
602
622
|
popupStore.assertPopupVisible();
|
|
@@ -607,6 +627,7 @@ class Playwright extends Helper {
|
|
|
607
627
|
/**
|
|
608
628
|
* Set current page
|
|
609
629
|
* @param {object} page page to set
|
|
630
|
+
* @return {Promise<any>}
|
|
610
631
|
*/
|
|
611
632
|
async _setPage(page) {
|
|
612
633
|
page = await page;
|
|
@@ -631,6 +652,7 @@ class Playwright extends Helper {
|
|
|
631
652
|
/**
|
|
632
653
|
* Add the 'dialog' event listener to a page
|
|
633
654
|
* @page {playwright.Page}
|
|
655
|
+
* @return {Promise<any>}
|
|
634
656
|
*
|
|
635
657
|
* The popup listener handles the dialog with the predefined action when it appears on the page.
|
|
636
658
|
* It also saves a reference to the object which is used in seeInPopup.
|
|
@@ -661,6 +683,7 @@ class Playwright extends Helper {
|
|
|
661
683
|
|
|
662
684
|
/**
|
|
663
685
|
* Gets page URL including hash.
|
|
686
|
+
* @return {Promise<any>}
|
|
664
687
|
*/
|
|
665
688
|
async _getPageUrl() {
|
|
666
689
|
return this.executeScript(() => window.location.href);
|
|
@@ -777,6 +800,7 @@ class Playwright extends Helper {
|
|
|
777
800
|
* ```
|
|
778
801
|
*
|
|
779
802
|
* @param {string} url url path or global url.
|
|
803
|
+
* @return {Promise<any>}
|
|
780
804
|
*/
|
|
781
805
|
async amOnPage(url) {
|
|
782
806
|
if (this.isElectron) {
|
|
@@ -814,6 +838,7 @@ class Playwright extends Helper {
|
|
|
814
838
|
*
|
|
815
839
|
* @param {number} width width in pixels or `maximize`.
|
|
816
840
|
* @param {number} height height in pixels.
|
|
841
|
+
* @return {Promise<any>}
|
|
817
842
|
*
|
|
818
843
|
* Unlike other drivers Playwright changes the size of a viewport, not the window!
|
|
819
844
|
* Playwright does not control the window of a browser so it can't adjust its real size.
|
|
@@ -846,6 +871,7 @@ class Playwright extends Helper {
|
|
|
846
871
|
* ```
|
|
847
872
|
*
|
|
848
873
|
* @param {object} customHeaders headers to set
|
|
874
|
+
* @return {Promise<any>}
|
|
849
875
|
*/
|
|
850
876
|
async haveRequestHeaders(customHeaders) {
|
|
851
877
|
if (!customHeaders) {
|
|
@@ -866,7 +892,7 @@ class Playwright extends Helper {
|
|
|
866
892
|
* @param {CodeceptJS.LocatorOrString} locator located by CSS|XPath|strict locator.
|
|
867
893
|
* @param {number} [offsetX=0] (optional, `0` by default) X-axis offset.
|
|
868
894
|
* @param {number} [offsetY=0] (optional, `0` by default) Y-axis offset.
|
|
869
|
-
*
|
|
895
|
+
* @return {Promise<any>}
|
|
870
896
|
*
|
|
871
897
|
*/
|
|
872
898
|
async moveCursorTo(locator, offsetX = 0, offsetY = 0) {
|
|
@@ -888,9 +914,9 @@ class Playwright extends Helper {
|
|
|
888
914
|
*
|
|
889
915
|
* @param {LocatorOrString} srcElement located by CSS|XPath|strict locator.
|
|
890
916
|
* @param {LocatorOrString} destElement located by CSS|XPath|strict locator.
|
|
891
|
-
*
|
|
917
|
+
* @return {Promise<any>}
|
|
892
918
|
*
|
|
893
|
-
* [Additional options](https://playwright.dev/docs/api/class-page#page-drag-and-drop) can be passed as 3rd argument.
|
|
919
|
+
* @param {any} [options] [Additional options](https://playwright.dev/docs/api/class-page#page-drag-and-drop) can be passed as 3rd argument.
|
|
894
920
|
*
|
|
895
921
|
* ```js
|
|
896
922
|
* // specify coordinates for source position
|
|
@@ -912,7 +938,7 @@ class Playwright extends Helper {
|
|
|
912
938
|
* ```js
|
|
913
939
|
* I.refreshPage();
|
|
914
940
|
* ```
|
|
915
|
-
*
|
|
941
|
+
* @return {Promise<any>}
|
|
916
942
|
*/
|
|
917
943
|
async refreshPage() {
|
|
918
944
|
return this.page.reload({ timeout: this.options.getPageTimeout, waitUntil: this.options.waitForNavigation });
|
|
@@ -924,7 +950,7 @@ class Playwright extends Helper {
|
|
|
924
950
|
* ```js
|
|
925
951
|
* I.scrollPageToTop();
|
|
926
952
|
* ```
|
|
927
|
-
*
|
|
953
|
+
* @return {Promise<any>}
|
|
928
954
|
*/
|
|
929
955
|
scrollPageToTop() {
|
|
930
956
|
return this.executeScript(() => {
|
|
@@ -938,9 +964,9 @@ class Playwright extends Helper {
|
|
|
938
964
|
* ```js
|
|
939
965
|
* I.scrollPageToBottom();
|
|
940
966
|
* ```
|
|
941
|
-
*
|
|
967
|
+
* @return {Promise<any>}
|
|
942
968
|
*/
|
|
943
|
-
scrollPageToBottom() {
|
|
969
|
+
async scrollPageToBottom() {
|
|
944
970
|
return this.executeScript(() => {
|
|
945
971
|
const body = document.body;
|
|
946
972
|
const html = document.documentElement;
|
|
@@ -963,6 +989,7 @@ class Playwright extends Helper {
|
|
|
963
989
|
* @param {CodeceptJS.LocatorOrString} locator located by CSS|XPath|strict locator.
|
|
964
990
|
* @param {number} [offsetX=0] (optional, `0` by default) X-axis offset.
|
|
965
991
|
* @param {number} [offsetY=0] (optional, `0` by default) Y-axis offset.
|
|
992
|
+
* @return {Promise<any>}
|
|
966
993
|
*/
|
|
967
994
|
async scrollTo(locator, offsetX = 0, offsetY = 0) {
|
|
968
995
|
if (typeof locator === 'number' && typeof offsetX === 'number') {
|
|
@@ -991,6 +1018,7 @@ class Playwright extends Helper {
|
|
|
991
1018
|
* ```
|
|
992
1019
|
*
|
|
993
1020
|
* @param {string} text text value to check.
|
|
1021
|
+
* @return {Promise<any>}
|
|
994
1022
|
*/
|
|
995
1023
|
async seeInTitle(text) {
|
|
996
1024
|
const title = await this.page.title();
|
|
@@ -1021,14 +1049,14 @@ class Playwright extends Helper {
|
|
|
1021
1049
|
}
|
|
1022
1050
|
|
|
1023
1051
|
/**
|
|
1024
|
-
*
|
|
1052
|
+
* Checks that title is equal to provided one.
|
|
1025
1053
|
*
|
|
1026
|
-
*
|
|
1027
|
-
*
|
|
1028
|
-
*
|
|
1029
|
-
*
|
|
1030
|
-
* @param {string} text value to check.
|
|
1054
|
+
* ```js
|
|
1055
|
+
* I.seeTitleEquals('Test title.');
|
|
1056
|
+
* ```
|
|
1031
1057
|
*
|
|
1058
|
+
* @param {string} text value to check.
|
|
1059
|
+
* @return {Promise<any>}
|
|
1032
1060
|
*/
|
|
1033
1061
|
async seeTitleEquals(text) {
|
|
1034
1062
|
const title = await this.page.title();
|
|
@@ -1043,6 +1071,7 @@ class Playwright extends Helper {
|
|
|
1043
1071
|
* ```
|
|
1044
1072
|
*
|
|
1045
1073
|
* @param {string} text value to check.
|
|
1074
|
+
* @return {Promise<any>}
|
|
1046
1075
|
*/
|
|
1047
1076
|
async dontSeeInTitle(text) {
|
|
1048
1077
|
const title = await this.page.title();
|
|
@@ -1070,8 +1099,7 @@ class Playwright extends Helper {
|
|
|
1070
1099
|
* ```js
|
|
1071
1100
|
* const elements = await this.helpers['Playwright']._locate({name: 'password'});
|
|
1072
1101
|
* ```
|
|
1073
|
-
*
|
|
1074
|
-
*
|
|
1102
|
+
* @return {Promise<any>}
|
|
1075
1103
|
*/
|
|
1076
1104
|
async _locate(locator) {
|
|
1077
1105
|
const context = await this.context || await this._getContext();
|
|
@@ -1085,6 +1113,7 @@ class Playwright extends Helper {
|
|
|
1085
1113
|
* ```js
|
|
1086
1114
|
* this.helpers['Playwright']._locateCheckable('I agree with terms and conditions').then // ...
|
|
1087
1115
|
* ```
|
|
1116
|
+
* @return {Promise<any>}
|
|
1088
1117
|
*/
|
|
1089
1118
|
async _locateCheckable(locator, providedContext = null) {
|
|
1090
1119
|
const context = providedContext || await this._getContext();
|
|
@@ -1099,6 +1128,7 @@ class Playwright extends Helper {
|
|
|
1099
1128
|
* ```js
|
|
1100
1129
|
* this.helpers['Playwright']._locateClickable('Next page').then // ...
|
|
1101
1130
|
* ```
|
|
1131
|
+
* @return {Promise<any>}
|
|
1102
1132
|
*/
|
|
1103
1133
|
async _locateClickable(locator) {
|
|
1104
1134
|
const context = await this._getContext();
|
|
@@ -1111,6 +1141,7 @@ class Playwright extends Helper {
|
|
|
1111
1141
|
* ```js
|
|
1112
1142
|
* this.helpers['Playwright']._locateFields('Your email').then // ...
|
|
1113
1143
|
* ```
|
|
1144
|
+
* @return {Promise<any>}
|
|
1114
1145
|
*/
|
|
1115
1146
|
async _locateFields(locator) {
|
|
1116
1147
|
return findFields.call(this, locator);
|
|
@@ -1125,6 +1156,7 @@ class Playwright extends Helper {
|
|
|
1125
1156
|
* ```
|
|
1126
1157
|
*
|
|
1127
1158
|
* @param {number} [num=1]
|
|
1159
|
+
* @return {Promise<any>}
|
|
1128
1160
|
*/
|
|
1129
1161
|
async switchToNextTab(num = 1) {
|
|
1130
1162
|
if (this.isElectron) {
|
|
@@ -1151,6 +1183,7 @@ class Playwright extends Helper {
|
|
|
1151
1183
|
* I.switchToPreviousTab(2);
|
|
1152
1184
|
* ```
|
|
1153
1185
|
* @param {number} [num=1]
|
|
1186
|
+
* @return {Promise<any>}
|
|
1154
1187
|
*/
|
|
1155
1188
|
async switchToPreviousTab(num = 1) {
|
|
1156
1189
|
if (this.isElectron) {
|
|
@@ -1175,6 +1208,7 @@ class Playwright extends Helper {
|
|
|
1175
1208
|
* ```js
|
|
1176
1209
|
* I.closeCurrentTab();
|
|
1177
1210
|
* ```
|
|
1211
|
+
* @return {Promise<any>}
|
|
1178
1212
|
*/
|
|
1179
1213
|
async closeCurrentTab() {
|
|
1180
1214
|
if (this.isElectron) {
|
|
@@ -1192,6 +1226,7 @@ class Playwright extends Helper {
|
|
|
1192
1226
|
* ```js
|
|
1193
1227
|
* I.closeOtherTabs();
|
|
1194
1228
|
* ```
|
|
1229
|
+
* @return {Promise<any>}
|
|
1195
1230
|
*/
|
|
1196
1231
|
async closeOtherTabs() {
|
|
1197
1232
|
const pages = await this.browserContext.pages();
|
|
@@ -1216,6 +1251,7 @@ class Playwright extends Helper {
|
|
|
1216
1251
|
* // enable mobile
|
|
1217
1252
|
* I.openNewTab({ isMobile: true });
|
|
1218
1253
|
* ```
|
|
1254
|
+
* @return {Promise<any>}
|
|
1219
1255
|
*/
|
|
1220
1256
|
async openNewTab(options) {
|
|
1221
1257
|
if (this.isElectron) {
|
|
@@ -1249,6 +1285,7 @@ class Playwright extends Helper {
|
|
|
1249
1285
|
* I.seeElement('#modal');
|
|
1250
1286
|
* ```
|
|
1251
1287
|
* @param {CodeceptJS.LocatorOrString} locator located by CSS|XPath|strict locator.
|
|
1288
|
+
* @return {Promise<any>}
|
|
1252
1289
|
*
|
|
1253
1290
|
*/
|
|
1254
1291
|
async seeElement(locator) {
|
|
@@ -1265,6 +1302,7 @@ class Playwright extends Helper {
|
|
|
1265
1302
|
* ```
|
|
1266
1303
|
*
|
|
1267
1304
|
* @param {CodeceptJS.LocatorOrString} locator located by CSS|XPath|Strict locator.
|
|
1305
|
+
* @return {Promise<any>}
|
|
1268
1306
|
*
|
|
1269
1307
|
*/
|
|
1270
1308
|
async dontSeeElement(locator) {
|
|
@@ -1281,7 +1319,7 @@ class Playwright extends Helper {
|
|
|
1281
1319
|
* I.seeElementInDOM('#modal');
|
|
1282
1320
|
* ```
|
|
1283
1321
|
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
1284
|
-
*
|
|
1322
|
+
* @return {Promise<any>}
|
|
1285
1323
|
*/
|
|
1286
1324
|
async seeElementInDOM(locator) {
|
|
1287
1325
|
const els = await this._locate(locator);
|
|
@@ -1296,6 +1334,7 @@ class Playwright extends Helper {
|
|
|
1296
1334
|
* ```
|
|
1297
1335
|
*
|
|
1298
1336
|
* @param {CodeceptJS.LocatorOrString} locator located by CSS|XPath|Strict locator.
|
|
1337
|
+
* @return {Promise<any>}
|
|
1299
1338
|
*/
|
|
1300
1339
|
async dontSeeElementInDOM(locator) {
|
|
1301
1340
|
const els = await this._locate(locator);
|
|
@@ -1317,6 +1356,7 @@ class Playwright extends Helper {
|
|
|
1317
1356
|
* ```
|
|
1318
1357
|
*
|
|
1319
1358
|
* @param {string} [fileName] set filename for downloaded file
|
|
1359
|
+
* @return {Promise<void>}
|
|
1320
1360
|
*/
|
|
1321
1361
|
async handleDownloads(fileName = 'downloads') {
|
|
1322
1362
|
this.page.waitForEvent('download').then(async (download) => {
|
|
@@ -1356,10 +1396,11 @@ class Playwright extends Helper {
|
|
|
1356
1396
|
* ```
|
|
1357
1397
|
*
|
|
1358
1398
|
* @param {CodeceptJS.LocatorOrString} locator clickable link or button located by text, or any element located by CSS|XPath|strict locator.
|
|
1359
|
-
* @param {?CodeceptJS.LocatorOrString} [context=null] (optional, `null` by default) element to search in CSS|XPath|Strict locator.
|
|
1399
|
+
* @param {?CodeceptJS.LocatorOrString | null} [context=null] (optional, `null` by default) element to search in CSS|XPath|Strict locator.
|
|
1400
|
+
* @return {Promise<any>}
|
|
1360
1401
|
*
|
|
1361
1402
|
*
|
|
1362
|
-
* [Additional options](https://playwright.dev/docs/api/class-page#page-click) for click available as 3rd argument.
|
|
1403
|
+
* @param {any} [opts] [Additional options](https://playwright.dev/docs/api/class-page#page-click) for click available as 3rd argument.
|
|
1363
1404
|
*
|
|
1364
1405
|
* Examples:
|
|
1365
1406
|
*
|
|
@@ -1378,6 +1419,7 @@ class Playwright extends Helper {
|
|
|
1378
1419
|
|
|
1379
1420
|
/**
|
|
1380
1421
|
* Clicks link and waits for navigation (deprecated)
|
|
1422
|
+
* @return {Promise<any>}
|
|
1381
1423
|
*/
|
|
1382
1424
|
async clickLink(locator, context = null) {
|
|
1383
1425
|
console.log('clickLink deprecated: Playwright automatically waits for navigation to happen.');
|
|
@@ -1413,6 +1455,7 @@ class Playwright extends Helper {
|
|
|
1413
1455
|
*
|
|
1414
1456
|
* @param {CodeceptJS.LocatorOrString} locator clickable link or button located by text, or any element located by CSS|XPath|strict locator.
|
|
1415
1457
|
* @param {?CodeceptJS.LocatorOrString} [context=null] (optional, `null` by default) element to search in CSS|XPath|Strict locator.
|
|
1458
|
+
* @return {Promise<any>}
|
|
1416
1459
|
*
|
|
1417
1460
|
*/
|
|
1418
1461
|
async forceClick(locator, context = null) {
|
|
@@ -1432,7 +1475,7 @@ class Playwright extends Helper {
|
|
|
1432
1475
|
*
|
|
1433
1476
|
* @param {CodeceptJS.LocatorOrString} locator clickable link or button located by text, or any element located by CSS|XPath|strict locator.
|
|
1434
1477
|
* @param {?CodeceptJS.LocatorOrString} [context=null] (optional, `null` by default) element to search in CSS|XPath|Strict locator.
|
|
1435
|
-
*
|
|
1478
|
+
* @return {Promise<any>}
|
|
1436
1479
|
*
|
|
1437
1480
|
*
|
|
1438
1481
|
*/
|
|
@@ -1454,7 +1497,7 @@ class Playwright extends Helper {
|
|
|
1454
1497
|
*
|
|
1455
1498
|
* @param {CodeceptJS.LocatorOrString} locator clickable element located by CSS|XPath|strict locator.
|
|
1456
1499
|
* @param {?CodeceptJS.LocatorOrString} [context=null] (optional, `null` by default) element located by CSS|XPath|strict locator.
|
|
1457
|
-
*
|
|
1500
|
+
* @return {Promise<any>}
|
|
1458
1501
|
*
|
|
1459
1502
|
*
|
|
1460
1503
|
*/
|
|
@@ -1475,6 +1518,7 @@ class Playwright extends Helper {
|
|
|
1475
1518
|
* ```
|
|
1476
1519
|
* @param {CodeceptJS.LocatorOrString} field checkbox located by label | name | CSS | XPath | strict locator.
|
|
1477
1520
|
* @param {?CodeceptJS.LocatorOrString} [context=null] (optional, `null` by default) element located by CSS | XPath | strict locator.
|
|
1521
|
+
* @return {Promise<any>}
|
|
1478
1522
|
*
|
|
1479
1523
|
* [Additional options](https://playwright.dev/docs/api/class-elementhandle#element-handle-check) for check available as 3rd argument.
|
|
1480
1524
|
*
|
|
@@ -1505,6 +1549,7 @@ class Playwright extends Helper {
|
|
|
1505
1549
|
* ```
|
|
1506
1550
|
* @param {CodeceptJS.LocatorOrString} field checkbox located by label | name | CSS | XPath | strict locator.
|
|
1507
1551
|
* @param {?CodeceptJS.LocatorOrString} [context=null] (optional, `null` by default) element located by CSS | XPath | strict locator.
|
|
1552
|
+
* @return {Promise<any>}
|
|
1508
1553
|
*
|
|
1509
1554
|
* [Additional options](https://playwright.dev/docs/api/class-elementhandle#element-handle-uncheck) for uncheck available as 3rd argument.
|
|
1510
1555
|
*
|
|
@@ -1532,7 +1577,7 @@ class Playwright extends Helper {
|
|
|
1532
1577
|
* ```
|
|
1533
1578
|
*
|
|
1534
1579
|
* @param {CodeceptJS.LocatorOrString} field located by label|name|CSS|XPath|strict locator.
|
|
1535
|
-
*
|
|
1580
|
+
* @return {Promise<any>}
|
|
1536
1581
|
*/
|
|
1537
1582
|
async seeCheckboxIsChecked(field) {
|
|
1538
1583
|
return proceedIsChecked.call(this, 'assert', field);
|
|
@@ -1548,7 +1593,7 @@ class Playwright extends Helper {
|
|
|
1548
1593
|
* ```
|
|
1549
1594
|
*
|
|
1550
1595
|
* @param {CodeceptJS.LocatorOrString} field located by label|name|CSS|XPath|strict locator.
|
|
1551
|
-
*
|
|
1596
|
+
* @return {Promise<any>}
|
|
1552
1597
|
*/
|
|
1553
1598
|
async dontSeeCheckboxIsChecked(field) {
|
|
1554
1599
|
return proceedIsChecked.call(this, 'negate', field);
|
|
@@ -1566,7 +1611,7 @@ class Playwright extends Helper {
|
|
|
1566
1611
|
* ```
|
|
1567
1612
|
*
|
|
1568
1613
|
* @param {string} key name of key to press down.
|
|
1569
|
-
*
|
|
1614
|
+
* @return {Promise<any>}
|
|
1570
1615
|
*/
|
|
1571
1616
|
async pressKeyDown(key) {
|
|
1572
1617
|
key = getNormalizedKey.call(this, key);
|
|
@@ -1586,7 +1631,7 @@ class Playwright extends Helper {
|
|
|
1586
1631
|
* ```
|
|
1587
1632
|
*
|
|
1588
1633
|
* @param {string} key name of key to release.
|
|
1589
|
-
*
|
|
1634
|
+
* @return {Promise<any>}
|
|
1590
1635
|
*/
|
|
1591
1636
|
async pressKeyUp(key) {
|
|
1592
1637
|
key = getNormalizedKey.call(this, key);
|
|
@@ -1654,6 +1699,7 @@ class Playwright extends Helper {
|
|
|
1654
1699
|
* - `'Tab'`
|
|
1655
1700
|
*
|
|
1656
1701
|
* @param {string|string[]} key key or array of keys to press.
|
|
1702
|
+
* @return {Promise<any>}
|
|
1657
1703
|
*
|
|
1658
1704
|
*
|
|
1659
1705
|
* _Note:_ Shortcuts like `'Meta'` + `'A'` do not work on macOS ([GoogleChrome/Puppeteer#1313](https://github.com/GoogleChrome/puppeteer/issues/1313)).
|
|
@@ -1701,7 +1747,7 @@ class Playwright extends Helper {
|
|
|
1701
1747
|
*
|
|
1702
1748
|
* @param {string|string[]} key or array of keys to type.
|
|
1703
1749
|
* @param {?number} [delay=null] (optional) delay in ms between key presses
|
|
1704
|
-
*
|
|
1750
|
+
* @return {Promise<any>}
|
|
1705
1751
|
*/
|
|
1706
1752
|
async type(keys, delay = null) {
|
|
1707
1753
|
if (!Array.isArray(keys)) {
|
|
@@ -1730,7 +1776,7 @@ class Playwright extends Helper {
|
|
|
1730
1776
|
* ```
|
|
1731
1777
|
* @param {CodeceptJS.LocatorOrString} field located by label|name|CSS|XPath|strict locator.
|
|
1732
1778
|
* @param {CodeceptJS.StringOrSecret} value text value to fill.
|
|
1733
|
-
*
|
|
1779
|
+
* @return {Promise<any>}
|
|
1734
1780
|
*
|
|
1735
1781
|
*/
|
|
1736
1782
|
async fillField(field, value) {
|
|
@@ -1757,7 +1803,7 @@ class Playwright extends Helper {
|
|
|
1757
1803
|
* I.clearField('#email');
|
|
1758
1804
|
* ```
|
|
1759
1805
|
* @param {LocatorOrString} editable field located by label|name|CSS|XPath|strict locator.
|
|
1760
|
-
*
|
|
1806
|
+
* @return {Promise<any>}
|
|
1761
1807
|
*/
|
|
1762
1808
|
async clearField(field) {
|
|
1763
1809
|
return this.fillField(field, '');
|
|
@@ -1772,6 +1818,7 @@ class Playwright extends Helper {
|
|
|
1772
1818
|
* ```
|
|
1773
1819
|
* @param {CodeceptJS.LocatorOrString} field located by label|name|CSS|XPath|strict locator
|
|
1774
1820
|
* @param {string} value text value to append.
|
|
1821
|
+
* @return {Promise<any>}
|
|
1775
1822
|
*
|
|
1776
1823
|
*
|
|
1777
1824
|
*/
|
|
@@ -1795,7 +1842,7 @@ class Playwright extends Helper {
|
|
|
1795
1842
|
* ```
|
|
1796
1843
|
* @param {CodeceptJS.LocatorOrString} field located by label|name|CSS|XPath|strict locator.
|
|
1797
1844
|
* @param {string} value value to check.
|
|
1798
|
-
*
|
|
1845
|
+
* @return {Promise<any>}
|
|
1799
1846
|
*/
|
|
1800
1847
|
async seeInField(field, value) {
|
|
1801
1848
|
return proceedSeeInField.call(this, 'assert', field, value);
|
|
@@ -1812,6 +1859,7 @@ class Playwright extends Helper {
|
|
|
1812
1859
|
*
|
|
1813
1860
|
* @param {CodeceptJS.LocatorOrString} field located by label|name|CSS|XPath|strict locator.
|
|
1814
1861
|
* @param {string} value value to check.
|
|
1862
|
+
* @return {Promise<any>}
|
|
1815
1863
|
*/
|
|
1816
1864
|
async dontSeeInField(field, value) {
|
|
1817
1865
|
return proceedSeeInField.call(this, 'negate', field, value);
|
|
@@ -1829,6 +1877,7 @@ class Playwright extends Helper {
|
|
|
1829
1877
|
*
|
|
1830
1878
|
* @param {CodeceptJS.LocatorOrString} locator field located by label|name|CSS|XPath|strict locator.
|
|
1831
1879
|
* @param {string} pathToFile local file path relative to codecept.json config file.
|
|
1880
|
+
* @return {Promise<any>}
|
|
1832
1881
|
*
|
|
1833
1882
|
*/
|
|
1834
1883
|
async attachFile(locator, pathToFile) {
|
|
@@ -1864,7 +1913,7 @@ class Playwright extends Helper {
|
|
|
1864
1913
|
* ```
|
|
1865
1914
|
* @param {LocatorOrString} select field located by label|name|CSS|XPath|strict locator.
|
|
1866
1915
|
* @param {string|Array<*>} option visible text or value of option.
|
|
1867
|
-
*
|
|
1916
|
+
* @return {Promise<any>}
|
|
1868
1917
|
*/
|
|
1869
1918
|
async selectOption(select, option) {
|
|
1870
1919
|
const els = await findFields.call(this, select);
|
|
@@ -1921,6 +1970,7 @@ class Playwright extends Helper {
|
|
|
1921
1970
|
* ```
|
|
1922
1971
|
*
|
|
1923
1972
|
* @param {string} url a fragment to check
|
|
1973
|
+
* @return {Promise<any>}
|
|
1924
1974
|
*/
|
|
1925
1975
|
async seeInCurrentUrl(url) {
|
|
1926
1976
|
stringIncludes('url').assert(url, await this._getPageUrl());
|
|
@@ -1930,6 +1980,7 @@ class Playwright extends Helper {
|
|
|
1930
1980
|
* Checks that current url does not contain a provided fragment.
|
|
1931
1981
|
*
|
|
1932
1982
|
* @param {string} url value to check.
|
|
1983
|
+
* @return {Promise<any>}
|
|
1933
1984
|
*/
|
|
1934
1985
|
async dontSeeInCurrentUrl(url) {
|
|
1935
1986
|
stringIncludes('url').negate(url, await this._getPageUrl());
|
|
@@ -1946,6 +1997,7 @@ class Playwright extends Helper {
|
|
|
1946
1997
|
* ```
|
|
1947
1998
|
*
|
|
1948
1999
|
* @param {string} url value to check.
|
|
2000
|
+
* @return {Promise<any>}
|
|
1949
2001
|
*/
|
|
1950
2002
|
async seeCurrentUrlEquals(url) {
|
|
1951
2003
|
urlEquals(this.options.url).assert(url, await this._getPageUrl());
|
|
@@ -1961,6 +2013,7 @@ class Playwright extends Helper {
|
|
|
1961
2013
|
* ```
|
|
1962
2014
|
*
|
|
1963
2015
|
* @param {string} url value to check.
|
|
2016
|
+
* @return {Promise<any>}
|
|
1964
2017
|
*/
|
|
1965
2018
|
async dontSeeCurrentUrlEquals(url) {
|
|
1966
2019
|
urlEquals(this.options.url).negate(url, await this._getPageUrl());
|
|
@@ -1977,6 +2030,7 @@ class Playwright extends Helper {
|
|
|
1977
2030
|
* ```
|
|
1978
2031
|
* @param {string} text expected on page.
|
|
1979
2032
|
* @param {?CodeceptJS.LocatorOrString} [context=null] (optional, `null` by default) element located by CSS|Xpath|strict locator in which to search for text.
|
|
2033
|
+
* @return {Promise<any>}
|
|
1980
2034
|
*
|
|
1981
2035
|
*
|
|
1982
2036
|
*/
|
|
@@ -1993,6 +2047,7 @@ class Playwright extends Helper {
|
|
|
1993
2047
|
*
|
|
1994
2048
|
* @param {string} text element value to check.
|
|
1995
2049
|
* @param {CodeceptJS.LocatorOrString?} [context=null] element located by CSS|XPath|strict locator.
|
|
2050
|
+
* @return {Promise<any>}
|
|
1996
2051
|
*/
|
|
1997
2052
|
async seeTextEquals(text, context = null) {
|
|
1998
2053
|
return proceedSee.call(this, 'assert', text, context, true);
|
|
@@ -2009,7 +2064,7 @@ class Playwright extends Helper {
|
|
|
2009
2064
|
*
|
|
2010
2065
|
* @param {string} text which is not present.
|
|
2011
2066
|
* @param {CodeceptJS.LocatorOrString} [context] (optional) element located by CSS|XPath|strict locator in which to perfrom search.
|
|
2012
|
-
*
|
|
2067
|
+
* @return {Promise<any>}
|
|
2013
2068
|
*
|
|
2014
2069
|
*
|
|
2015
2070
|
*/
|
|
@@ -2068,6 +2123,7 @@ class Playwright extends Helper {
|
|
|
2068
2123
|
* I.seeInSource('<h1>Green eggs & ham</h1>');
|
|
2069
2124
|
* ```
|
|
2070
2125
|
* @param {string} text value to check.
|
|
2126
|
+
* @return {Promise<any>}
|
|
2071
2127
|
*/
|
|
2072
2128
|
async seeInSource(text) {
|
|
2073
2129
|
const source = await this.page.content();
|
|
@@ -2082,7 +2138,7 @@ class Playwright extends Helper {
|
|
|
2082
2138
|
* ```
|
|
2083
2139
|
*
|
|
2084
2140
|
* @param {string} value to check.
|
|
2085
|
-
*
|
|
2141
|
+
* @return {Promise<any>}
|
|
2086
2142
|
*/
|
|
2087
2143
|
async dontSeeInSource(text) {
|
|
2088
2144
|
const source = await this.page.content();
|
|
@@ -2100,7 +2156,7 @@ class Playwright extends Helper {
|
|
|
2100
2156
|
*
|
|
2101
2157
|
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
2102
2158
|
* @param {number} num number of elements.
|
|
2103
|
-
*
|
|
2159
|
+
* @return {Promise<any>}
|
|
2104
2160
|
*
|
|
2105
2161
|
*
|
|
2106
2162
|
*/
|
|
@@ -2119,7 +2175,7 @@ class Playwright extends Helper {
|
|
|
2119
2175
|
*
|
|
2120
2176
|
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
2121
2177
|
* @param {number} num number of elements.
|
|
2122
|
-
*
|
|
2178
|
+
* @return {Promise<any>}
|
|
2123
2179
|
*
|
|
2124
2180
|
*
|
|
2125
2181
|
*/
|
|
@@ -2144,7 +2200,7 @@ class Playwright extends Helper {
|
|
|
2144
2200
|
* ```
|
|
2145
2201
|
*
|
|
2146
2202
|
* @param {Cookie|Array<Cookie>} cookie a cookie object or array of cookie objects.
|
|
2147
|
-
*
|
|
2203
|
+
* @return {Promise<any>}
|
|
2148
2204
|
*/
|
|
2149
2205
|
async setCookie(cookie) {
|
|
2150
2206
|
if (Array.isArray(cookie)) {
|
|
@@ -2161,7 +2217,7 @@ class Playwright extends Helper {
|
|
|
2161
2217
|
* ```
|
|
2162
2218
|
*
|
|
2163
2219
|
* @param {string} name cookie name.
|
|
2164
|
-
*
|
|
2220
|
+
* @return {Promise<any>}
|
|
2165
2221
|
*
|
|
2166
2222
|
*/
|
|
2167
2223
|
async seeCookie(name) {
|
|
@@ -2177,6 +2233,7 @@ class Playwright extends Helper {
|
|
|
2177
2233
|
* ```
|
|
2178
2234
|
*
|
|
2179
2235
|
* @param {string} name cookie name.
|
|
2236
|
+
* @return {Promise<any>}
|
|
2180
2237
|
*/
|
|
2181
2238
|
async dontSeeCookie(name) {
|
|
2182
2239
|
const cookies = await this.browserContext.cookies();
|
|
@@ -2216,6 +2273,7 @@ class Playwright extends Helper {
|
|
|
2216
2273
|
* ```
|
|
2217
2274
|
*
|
|
2218
2275
|
* @param {?string} [cookie=null] (optional, `null` by default) cookie name
|
|
2276
|
+
* @return {Promise<any>}
|
|
2219
2277
|
*/
|
|
2220
2278
|
async clearCookie() {
|
|
2221
2279
|
// Playwright currently doesn't support to delete a certain cookie
|
|
@@ -2444,6 +2502,7 @@ class Playwright extends Helper {
|
|
|
2444
2502
|
*
|
|
2445
2503
|
* @param {CodeceptJS.LocatorOrString} locator located by CSS|XPath|strict locator.
|
|
2446
2504
|
* @param {object} cssProperties object with CSS properties and their values to check.
|
|
2505
|
+
* @return {Promise<any>}
|
|
2447
2506
|
*
|
|
2448
2507
|
*/
|
|
2449
2508
|
async seeCssPropertiesOnElements(locator, cssProperties) {
|
|
@@ -2489,6 +2548,7 @@ class Playwright extends Helper {
|
|
|
2489
2548
|
*
|
|
2490
2549
|
* @param {CodeceptJS.LocatorOrString} locator located by CSS|XPath|strict locator.
|
|
2491
2550
|
* @param {object} attributes attributes and their values to check.
|
|
2551
|
+
* @return {Promise<any>}
|
|
2492
2552
|
*
|
|
2493
2553
|
*/
|
|
2494
2554
|
async seeAttributesOnElements(locator, attributes) {
|
|
@@ -2527,6 +2587,7 @@ class Playwright extends Helper {
|
|
|
2527
2587
|
*
|
|
2528
2588
|
* @param {CodeceptJS.LocatorOrString} locator located by label|name|CSS|XPath|strict locator.
|
|
2529
2589
|
* @param {number} offsetX position to drag.
|
|
2590
|
+
* @return {Promise<any>}
|
|
2530
2591
|
*
|
|
2531
2592
|
*/
|
|
2532
2593
|
async dragSlider(locator, offsetX = 0) {
|
|
@@ -2604,7 +2665,7 @@ class Playwright extends Helper {
|
|
|
2604
2665
|
*
|
|
2605
2666
|
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
2606
2667
|
* @param {string} fileName file name to save.
|
|
2607
|
-
*
|
|
2668
|
+
* @return {Promise<any>}
|
|
2608
2669
|
*
|
|
2609
2670
|
*/
|
|
2610
2671
|
async saveElementScreenshot(locator, fileName) {
|
|
@@ -2630,6 +2691,7 @@ class Playwright extends Helper {
|
|
|
2630
2691
|
*
|
|
2631
2692
|
* @param {string} fileName file name to save.
|
|
2632
2693
|
* @param {boolean} [fullPage=false] (optional, `false` by default) flag to enable fullscreen screenshot mode.
|
|
2694
|
+
* @return {Promise<any>}
|
|
2633
2695
|
*/
|
|
2634
2696
|
async saveScreenshot(fileName, fullPage) {
|
|
2635
2697
|
const fullPageOption = fullPage || this.options.fullPageScreenshots;
|
|
@@ -2706,7 +2768,7 @@ class Playwright extends Helper {
|
|
|
2706
2768
|
test.artifacts = {};
|
|
2707
2769
|
}
|
|
2708
2770
|
|
|
2709
|
-
if (this.options.recordVideo && this.page.video()) {
|
|
2771
|
+
if (this.options.recordVideo && this.page && this.page.video()) {
|
|
2710
2772
|
test.artifacts.video = await this.page.video().path();
|
|
2711
2773
|
}
|
|
2712
2774
|
|
|
@@ -2718,7 +2780,7 @@ class Playwright extends Helper {
|
|
|
2718
2780
|
}
|
|
2719
2781
|
|
|
2720
2782
|
async _passed(test) {
|
|
2721
|
-
if (this.options.recordVideo && this.page.video()) {
|
|
2783
|
+
if (this.options.recordVideo && this.page && this.page.video()) {
|
|
2722
2784
|
if (this.options.keepVideoForPassedTests) {
|
|
2723
2785
|
test.artifacts.video = await this.page.video().path();
|
|
2724
2786
|
} else {
|
|
@@ -2745,6 +2807,7 @@ class Playwright extends Helper {
|
|
|
2745
2807
|
* ```
|
|
2746
2808
|
*
|
|
2747
2809
|
* @param {number} sec number of second to wait.
|
|
2810
|
+
* @return {Promise<any>}
|
|
2748
2811
|
*/
|
|
2749
2812
|
async wait(sec) {
|
|
2750
2813
|
return new Promise(((done) => {
|
|
@@ -2758,6 +2821,7 @@ class Playwright extends Helper {
|
|
|
2758
2821
|
*
|
|
2759
2822
|
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
2760
2823
|
* @param {number} [sec=1] (optional) time in seconds to wait, 1 by default.
|
|
2824
|
+
* @return {Promise<any>}
|
|
2761
2825
|
*/
|
|
2762
2826
|
async waitForEnabled(locator, sec) {
|
|
2763
2827
|
const waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout;
|
|
@@ -2792,7 +2856,7 @@ class Playwright extends Helper {
|
|
|
2792
2856
|
* @param {LocatorOrString} field input field.
|
|
2793
2857
|
* @param {string }value expected value.
|
|
2794
2858
|
* @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
|
|
2795
|
-
*
|
|
2859
|
+
* @return {Promise<any>}
|
|
2796
2860
|
*/
|
|
2797
2861
|
async waitForValue(field, value, sec) {
|
|
2798
2862
|
const waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout;
|
|
@@ -2828,6 +2892,7 @@ class Playwright extends Helper {
|
|
|
2828
2892
|
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
2829
2893
|
* @param {number} num number of elements.
|
|
2830
2894
|
* @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
|
|
2895
|
+
* @return {Promise<any>}
|
|
2831
2896
|
*
|
|
2832
2897
|
*/
|
|
2833
2898
|
async waitNumberOfVisibleElements(locator, num, sec) {
|
|
@@ -2868,6 +2933,7 @@ class Playwright extends Helper {
|
|
|
2868
2933
|
*
|
|
2869
2934
|
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
2870
2935
|
* @param {number} [sec] (optional, `1` by default) time in seconds to wait
|
|
2936
|
+
* @return {Promise<any>}
|
|
2871
2937
|
*/
|
|
2872
2938
|
async waitForClickable(locator, waitTimeout) {
|
|
2873
2939
|
console.log('I.waitForClickable is DEPRECATED: This is no longer needed, Playwright automatically waits for element to be clickable');
|
|
@@ -2885,6 +2951,7 @@ class Playwright extends Helper {
|
|
|
2885
2951
|
*
|
|
2886
2952
|
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
2887
2953
|
* @param {number} [sec] (optional, `1` by default) time in seconds to wait
|
|
2954
|
+
* @return {Promise<any>}
|
|
2888
2955
|
*
|
|
2889
2956
|
*/
|
|
2890
2957
|
async waitForElement(locator, sec) {
|
|
@@ -2908,7 +2975,7 @@ class Playwright extends Helper {
|
|
|
2908
2975
|
*
|
|
2909
2976
|
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
2910
2977
|
* @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
|
|
2911
|
-
*
|
|
2978
|
+
* @return {Promise<any>}
|
|
2912
2979
|
*
|
|
2913
2980
|
* This method accepts [React selectors](https://codecept.io/react).
|
|
2914
2981
|
*/
|
|
@@ -2932,6 +2999,7 @@ class Playwright extends Helper {
|
|
|
2932
2999
|
*
|
|
2933
3000
|
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
2934
3001
|
* @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
|
|
3002
|
+
* @return {Promise<any>}
|
|
2935
3003
|
*/
|
|
2936
3004
|
async waitForInvisible(locator, sec) {
|
|
2937
3005
|
const waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout;
|
|
@@ -2953,6 +3021,7 @@ class Playwright extends Helper {
|
|
|
2953
3021
|
*
|
|
2954
3022
|
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
2955
3023
|
* @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
|
|
3024
|
+
* @return {Promise<any>}
|
|
2956
3025
|
*/
|
|
2957
3026
|
async waitToHide(locator, sec) {
|
|
2958
3027
|
const waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout;
|
|
@@ -2979,6 +3048,7 @@ class Playwright extends Helper {
|
|
|
2979
3048
|
*
|
|
2980
3049
|
* @param {string} urlPart value to check.
|
|
2981
3050
|
* @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
|
|
3051
|
+
* @return {Promise<any>}
|
|
2982
3052
|
*/
|
|
2983
3053
|
async waitInUrl(urlPart, sec = null) {
|
|
2984
3054
|
const waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout;
|
|
@@ -3006,6 +3076,7 @@ class Playwright extends Helper {
|
|
|
3006
3076
|
*
|
|
3007
3077
|
* @param {string} urlPart value to check.
|
|
3008
3078
|
* @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
|
|
3079
|
+
* @return {Promise<any>}
|
|
3009
3080
|
*/
|
|
3010
3081
|
async waitUrlEquals(urlPart, sec = null) {
|
|
3011
3082
|
const waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout;
|
|
@@ -3041,6 +3112,7 @@ class Playwright extends Helper {
|
|
|
3041
3112
|
* @param {string }text to wait for.
|
|
3042
3113
|
* @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
|
|
3043
3114
|
* @param {CodeceptJS.LocatorOrString} [context] (optional) element located by CSS|XPath|strict locator.
|
|
3115
|
+
* @return {Promise<any>}
|
|
3044
3116
|
*/
|
|
3045
3117
|
async waitForText(text, sec = null, context = null) {
|
|
3046
3118
|
const waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout;
|
|
@@ -3080,6 +3152,7 @@ class Playwright extends Helper {
|
|
|
3080
3152
|
*
|
|
3081
3153
|
* @param {string|function} urlOrPredicate
|
|
3082
3154
|
* @param {?number} [sec=null] seconds to wait
|
|
3155
|
+
* @return {Promise<any>}
|
|
3083
3156
|
*/
|
|
3084
3157
|
async waitForRequest(urlOrPredicate, sec = null) {
|
|
3085
3158
|
const timeout = sec ? sec * 1000 : this.options.waitForTimeout;
|
|
@@ -3096,6 +3169,7 @@ class Playwright extends Helper {
|
|
|
3096
3169
|
*
|
|
3097
3170
|
* @param {string|function} urlOrPredicate
|
|
3098
3171
|
* @param {?number} [sec=null] number of seconds to wait
|
|
3172
|
+
* @return {Promise<any>}
|
|
3099
3173
|
*/
|
|
3100
3174
|
async waitForResponse(urlOrPredicate, sec = null) {
|
|
3101
3175
|
const timeout = sec ? sec * 1000 : this.options.waitForTimeout;
|
|
@@ -3111,6 +3185,7 @@ class Playwright extends Helper {
|
|
|
3111
3185
|
* ```
|
|
3112
3186
|
*
|
|
3113
3187
|
* @param {?CodeceptJS.LocatorOrString} [locator=null] (optional, `null` by default) element located by CSS|XPath|strict locator.
|
|
3188
|
+
* @return {Promise<any>}
|
|
3114
3189
|
*/
|
|
3115
3190
|
async switchTo(locator) {
|
|
3116
3191
|
if (Number.isInteger(locator)) {
|
|
@@ -3168,7 +3243,7 @@ class Playwright extends Helper {
|
|
|
3168
3243
|
* @param {string|function} fn to be executed in browser context.
|
|
3169
3244
|
* @param {any[]|number} [argsOrSec] (optional, `1` by default) arguments for function or seconds.
|
|
3170
3245
|
* @param {number} [sec] (optional, `1` by default) time in seconds to wait
|
|
3171
|
-
*
|
|
3246
|
+
* @return {Promise<any>}
|
|
3172
3247
|
*/
|
|
3173
3248
|
async waitForFunction(fn, argsOrSec = null, sec = null) {
|
|
3174
3249
|
let args = [];
|
|
@@ -3190,6 +3265,7 @@ class Playwright extends Helper {
|
|
|
3190
3265
|
* See [Playwright's reference](https://playwright.dev/docs/api/class-page?_highlight=waitfornavi#pagewaitfornavigationoptions)
|
|
3191
3266
|
*
|
|
3192
3267
|
* @param {*} opts
|
|
3268
|
+
* @return {Promise<any>}
|
|
3193
3269
|
*/
|
|
3194
3270
|
async waitForNavigation(opts = {}) {
|
|
3195
3271
|
opts = {
|
|
@@ -3217,6 +3293,7 @@ class Playwright extends Helper {
|
|
|
3217
3293
|
*
|
|
3218
3294
|
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
3219
3295
|
* @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
|
|
3296
|
+
* @return {Promise<any>}
|
|
3220
3297
|
*/
|
|
3221
3298
|
async waitForDetached(locator, sec) {
|
|
3222
3299
|
const waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout;
|
|
@@ -3262,6 +3339,7 @@ class Playwright extends Helper {
|
|
|
3262
3339
|
* loadEventEnd: 241
|
|
3263
3340
|
* }
|
|
3264
3341
|
* ```
|
|
3342
|
+
* @return {Promise<any>}
|
|
3265
3343
|
*/
|
|
3266
3344
|
async grabDataFromPerformanceTiming() {
|
|
3267
3345
|
return perfTiming;
|
|
@@ -3306,9 +3384,9 @@ class Playwright extends Helper {
|
|
|
3306
3384
|
* ```
|
|
3307
3385
|
* This method allows intercepting and mocking requests & responses. [Learn more about it](https://playwright.dev/docs/network#handle-requests)
|
|
3308
3386
|
*
|
|
3309
|
-
* @param {string} [url] URL, regex or pattern for to match URL
|
|
3387
|
+
* @param {string|RegExp} [url] URL, regex or pattern for to match URL
|
|
3310
3388
|
* @param {function} [handler] a function to process request
|
|
3311
|
-
*
|
|
3389
|
+
* @return {Promise<any>}
|
|
3312
3390
|
*/
|
|
3313
3391
|
async mockRoute(url, handler) {
|
|
3314
3392
|
return this.browserContext.route(...arguments);
|
|
@@ -3323,9 +3401,9 @@ class Playwright extends Helper {
|
|
|
3323
3401
|
* ```
|
|
3324
3402
|
* If no handler is passed, all mock requests for the rote are disabled.
|
|
3325
3403
|
*
|
|
3326
|
-
* @param {string} [url] URL, regex or pattern for to match URL
|
|
3404
|
+
* @param {string|RegExp} [url] URL, regex or pattern for to match URL
|
|
3327
3405
|
* @param {function} [handler] a function to process request
|
|
3328
|
-
*
|
|
3406
|
+
* @return {Promise<any>}
|
|
3329
3407
|
*/
|
|
3330
3408
|
async stopMockingRoute(url, handler) {
|
|
3331
3409
|
return this.browserContext.unroute(...arguments);
|