codeceptjs 3.3.0-beta.5 → 3.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +50 -1
- package/README.md +6 -1
- package/docs/api.md +45 -30
- package/docs/bdd.md +1 -0
- package/docs/best.md +1 -1
- package/docs/build/ApiDataFactory.js +4 -3
- package/docs/build/Appium.js +53 -48
- 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 +101 -72
- package/docs/build/Playwright.js +166 -113
- package/docs/build/Protractor.js +72 -34
- package/docs/build/Puppeteer.js +143 -100
- package/docs/build/REST.js +5 -2
- package/docs/build/TestCafe.js +97 -66
- package/docs/build/WebDriver.js +183 -135
- package/docs/changelog.md +99 -0
- package/docs/custom-helpers.md +1 -1
- package/docs/data.md +2 -2
- package/docs/email.md +5 -0
- package/docs/helpers/ApiDataFactory.md +7 -3
- package/docs/helpers/Appium.md +217 -175
- package/docs/helpers/GraphQL.md +6 -0
- package/docs/helpers/GraphQLDataFactory.md +3 -3
- package/docs/helpers/JSONResponse.md +1 -1
- package/docs/helpers/MockRequest.md +8 -6
- package/docs/helpers/Nightmare.md +98 -45
- package/docs/helpers/Playwright.md +151 -59
- package/docs/helpers/Puppeteer.md +103 -26
- package/docs/helpers/REST.md +1 -1
- package/docs/helpers/TestCafe.md +77 -22
- package/docs/helpers/WebDriver.md +150 -62
- package/docs/index.md +1 -1
- package/docs/locators.md +1 -1
- package/docs/videos.md +2 -2
- 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/executeAsyncScript.mustache +1 -1
- package/docs/webapi/executeScript.mustache +1 -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 +2 -7
- 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 +28 -17
- package/lib/helper/REST.js +5 -2
- package/lib/helper/WebDriver.js +4 -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 +578 -109
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
|
}
|
|
@@ -538,7 +553,7 @@ class Playwright extends Helper {
|
|
|
538
553
|
* ```
|
|
539
554
|
*
|
|
540
555
|
* @param {string} description used to show in logs.
|
|
541
|
-
* @param {function} fn async function that executed with Playwright helper as
|
|
556
|
+
* @param {function} fn async function that executed with Playwright helper as argumen
|
|
542
557
|
*/
|
|
543
558
|
usePlaywrightTo(description, fn) {
|
|
544
559
|
return this._useTo(...arguments);
|
|
@@ -596,7 +611,7 @@ class Playwright extends Helper {
|
|
|
596
611
|
* I.seeInPopup('Popup text');
|
|
597
612
|
* ```
|
|
598
613
|
* @param {string} text value to check.
|
|
599
|
-
*
|
|
614
|
+
* [!] returns a _promise_ which is synchronized internally by recorder
|
|
600
615
|
*/
|
|
601
616
|
async seeInPopup(text) {
|
|
602
617
|
popupStore.assertPopupVisible();
|
|
@@ -777,6 +792,7 @@ class Playwright extends Helper {
|
|
|
777
792
|
* ```
|
|
778
793
|
*
|
|
779
794
|
* @param {string} url url path or global url.
|
|
795
|
+
* @return {void} automatically synchronized promise with recorder #!
|
|
780
796
|
*/
|
|
781
797
|
async amOnPage(url) {
|
|
782
798
|
if (this.isElectron) {
|
|
@@ -814,6 +830,7 @@ class Playwright extends Helper {
|
|
|
814
830
|
*
|
|
815
831
|
* @param {number} width width in pixels or `maximize`.
|
|
816
832
|
* @param {number} height height in pixels.
|
|
833
|
+
* [!] returns a _promise_ which is synchronized internally by recorder
|
|
817
834
|
*
|
|
818
835
|
* Unlike other drivers Playwright changes the size of a viewport, not the window!
|
|
819
836
|
* Playwright does not control the window of a browser so it can't adjust its real size.
|
|
@@ -863,10 +880,10 @@ class Playwright extends Helper {
|
|
|
863
880
|
* I.moveCursorTo('#submit', 5,5);
|
|
864
881
|
* ```
|
|
865
882
|
*
|
|
866
|
-
* @param {
|
|
883
|
+
* @param {CodeceptJS.LocatorOrString} locator located by CSS|XPath|strict locator.
|
|
867
884
|
* @param {number} [offsetX=0] (optional, `0` by default) X-axis offset.
|
|
868
885
|
* @param {number} [offsetY=0] (optional, `0` by default) Y-axis offset.
|
|
869
|
-
*
|
|
886
|
+
* [!] returns a _promise_ which is synchronized internally by recorder
|
|
870
887
|
*
|
|
871
888
|
*/
|
|
872
889
|
async moveCursorTo(locator, offsetX = 0, offsetY = 0) {
|
|
@@ -886,11 +903,11 @@ class Playwright extends Helper {
|
|
|
886
903
|
* I.dragAndDrop('#dragHandle', '#container');
|
|
887
904
|
* ```
|
|
888
905
|
*
|
|
889
|
-
* @param {
|
|
890
|
-
* @param {
|
|
891
|
-
*
|
|
906
|
+
* @param {LocatorOrString} srcElement located by CSS|XPath|strict locator.
|
|
907
|
+
* @param {LocatorOrString} destElement located by CSS|XPath|strict locator.
|
|
908
|
+
* [!] returns a _promise_ which is synchronized internally by recorder
|
|
892
909
|
*
|
|
893
|
-
* [Additional options](https://playwright.dev/docs/api/class-page#page-drag-and-drop) can be passed as 3rd argument.
|
|
910
|
+
* @param {any} [options] [Additional options](https://playwright.dev/docs/api/class-page#page-drag-and-drop) can be passed as 3rd argument.
|
|
894
911
|
*
|
|
895
912
|
* ```js
|
|
896
913
|
* // specify coordinates for source position
|
|
@@ -912,7 +929,7 @@ class Playwright extends Helper {
|
|
|
912
929
|
* ```js
|
|
913
930
|
* I.refreshPage();
|
|
914
931
|
* ```
|
|
915
|
-
*
|
|
932
|
+
* [!] returns a _promise_ which is synchronized internally by recorder
|
|
916
933
|
*/
|
|
917
934
|
async refreshPage() {
|
|
918
935
|
return this.page.reload({ timeout: this.options.getPageTimeout, waitUntil: this.options.waitForNavigation });
|
|
@@ -924,7 +941,7 @@ class Playwright extends Helper {
|
|
|
924
941
|
* ```js
|
|
925
942
|
* I.scrollPageToTop();
|
|
926
943
|
* ```
|
|
927
|
-
*
|
|
944
|
+
* [!] returns a _promise_ which is synchronized internally by recorder
|
|
928
945
|
*/
|
|
929
946
|
scrollPageToTop() {
|
|
930
947
|
return this.executeScript(() => {
|
|
@@ -938,9 +955,9 @@ class Playwright extends Helper {
|
|
|
938
955
|
* ```js
|
|
939
956
|
* I.scrollPageToBottom();
|
|
940
957
|
* ```
|
|
941
|
-
*
|
|
958
|
+
* [!] returns a _promise_ which is synchronized internally by recorder
|
|
942
959
|
*/
|
|
943
|
-
scrollPageToBottom() {
|
|
960
|
+
async scrollPageToBottom() {
|
|
944
961
|
return this.executeScript(() => {
|
|
945
962
|
const body = document.body;
|
|
946
963
|
const html = document.documentElement;
|
|
@@ -960,9 +977,10 @@ class Playwright extends Helper {
|
|
|
960
977
|
* I.scrollTo('#submit', 5, 5);
|
|
961
978
|
* ```
|
|
962
979
|
*
|
|
963
|
-
* @param {
|
|
980
|
+
* @param {CodeceptJS.LocatorOrString} locator located by CSS|XPath|strict locator.
|
|
964
981
|
* @param {number} [offsetX=0] (optional, `0` by default) X-axis offset.
|
|
965
982
|
* @param {number} [offsetY=0] (optional, `0` by default) Y-axis offset.
|
|
983
|
+
* [!] returns a _promise_ which is synchronized internally by recorder
|
|
966
984
|
*/
|
|
967
985
|
async scrollTo(locator, offsetX = 0, offsetY = 0) {
|
|
968
986
|
if (typeof locator === 'number' && typeof offsetX === 'number') {
|
|
@@ -991,6 +1009,7 @@ class Playwright extends Helper {
|
|
|
991
1009
|
* ```
|
|
992
1010
|
*
|
|
993
1011
|
* @param {string} text text value to check.
|
|
1012
|
+
* [!] returns a _promise_ which is synchronized internally by recorder
|
|
994
1013
|
*/
|
|
995
1014
|
async seeInTitle(text) {
|
|
996
1015
|
const title = await this.page.title();
|
|
@@ -1021,14 +1040,14 @@ class Playwright extends Helper {
|
|
|
1021
1040
|
}
|
|
1022
1041
|
|
|
1023
1042
|
/**
|
|
1024
|
-
*
|
|
1025
|
-
*
|
|
1026
|
-
* ```js
|
|
1027
|
-
* I.seeTitleEquals('Test title.');
|
|
1028
|
-
* ```
|
|
1043
|
+
* Checks that title is equal to provided one.
|
|
1029
1044
|
*
|
|
1030
|
-
*
|
|
1045
|
+
* ```js
|
|
1046
|
+
* I.seeTitleEquals('Test title.');
|
|
1047
|
+
* ```
|
|
1031
1048
|
*
|
|
1049
|
+
* @param {string} text value to check.
|
|
1050
|
+
* [!] returns a _promise_ which is synchronized internally by recorder
|
|
1032
1051
|
*/
|
|
1033
1052
|
async seeTitleEquals(text) {
|
|
1034
1053
|
const title = await this.page.title();
|
|
@@ -1043,6 +1062,7 @@ class Playwright extends Helper {
|
|
|
1043
1062
|
* ```
|
|
1044
1063
|
*
|
|
1045
1064
|
* @param {string} text value to check.
|
|
1065
|
+
* [!] returns a _promise_ which is synchronized internally by recorder
|
|
1046
1066
|
*/
|
|
1047
1067
|
async dontSeeInTitle(text) {
|
|
1048
1068
|
const title = await this.page.title();
|
|
@@ -1070,8 +1090,6 @@ class Playwright extends Helper {
|
|
|
1070
1090
|
* ```js
|
|
1071
1091
|
* const elements = await this.helpers['Playwright']._locate({name: 'password'});
|
|
1072
1092
|
* ```
|
|
1073
|
-
*
|
|
1074
|
-
*
|
|
1075
1093
|
*/
|
|
1076
1094
|
async _locate(locator) {
|
|
1077
1095
|
const context = await this.context || await this._getContext();
|
|
@@ -1248,7 +1266,8 @@ class Playwright extends Helper {
|
|
|
1248
1266
|
* ```js
|
|
1249
1267
|
* I.seeElement('#modal');
|
|
1250
1268
|
* ```
|
|
1251
|
-
* @param {
|
|
1269
|
+
* @param {CodeceptJS.LocatorOrString} locator located by CSS|XPath|strict locator.
|
|
1270
|
+
* [!] returns a _promise_ which is synchronized internally by recorder
|
|
1252
1271
|
*
|
|
1253
1272
|
*/
|
|
1254
1273
|
async seeElement(locator) {
|
|
@@ -1264,7 +1283,8 @@ class Playwright extends Helper {
|
|
|
1264
1283
|
* I.dontSeeElement('.modal'); // modal is not shown
|
|
1265
1284
|
* ```
|
|
1266
1285
|
*
|
|
1267
|
-
* @param {
|
|
1286
|
+
* @param {CodeceptJS.LocatorOrString} locator located by CSS|XPath|Strict locator.
|
|
1287
|
+
* [!] returns a _promise_ which is synchronized internally by recorder
|
|
1268
1288
|
*
|
|
1269
1289
|
*/
|
|
1270
1290
|
async dontSeeElement(locator) {
|
|
@@ -1280,8 +1300,8 @@ class Playwright extends Helper {
|
|
|
1280
1300
|
* ```js
|
|
1281
1301
|
* I.seeElementInDOM('#modal');
|
|
1282
1302
|
* ```
|
|
1283
|
-
* @param {
|
|
1284
|
-
*
|
|
1303
|
+
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
1304
|
+
* [!] returns a _promise_ which is synchronized internally by recorder
|
|
1285
1305
|
*/
|
|
1286
1306
|
async seeElementInDOM(locator) {
|
|
1287
1307
|
const els = await this._locate(locator);
|
|
@@ -1295,7 +1315,8 @@ class Playwright extends Helper {
|
|
|
1295
1315
|
* I.dontSeeElementInDOM('.nav'); // checks that element is not on page visible or not
|
|
1296
1316
|
* ```
|
|
1297
1317
|
*
|
|
1298
|
-
* @param {
|
|
1318
|
+
* @param {CodeceptJS.LocatorOrString} locator located by CSS|XPath|Strict locator.
|
|
1319
|
+
* [!] returns a _promise_ which is synchronized internally by recorder
|
|
1299
1320
|
*/
|
|
1300
1321
|
async dontSeeElementInDOM(locator) {
|
|
1301
1322
|
const els = await this._locate(locator);
|
|
@@ -1317,6 +1338,7 @@ class Playwright extends Helper {
|
|
|
1317
1338
|
* ```
|
|
1318
1339
|
*
|
|
1319
1340
|
* @param {string} [fileName] set filename for downloaded file
|
|
1341
|
+
* @return {Promise<void>}
|
|
1320
1342
|
*/
|
|
1321
1343
|
async handleDownloads(fileName = 'downloads') {
|
|
1322
1344
|
this.page.waitForEvent('download').then(async (download) => {
|
|
@@ -1355,11 +1377,12 @@ class Playwright extends Helper {
|
|
|
1355
1377
|
* I.click({css: 'nav a.login'});
|
|
1356
1378
|
* ```
|
|
1357
1379
|
*
|
|
1358
|
-
* @param {
|
|
1359
|
-
* @param {?
|
|
1380
|
+
* @param {CodeceptJS.LocatorOrString} locator clickable link or button located by text, or any element located by CSS|XPath|strict locator.
|
|
1381
|
+
* @param {?CodeceptJS.LocatorOrString | null} [context=null] (optional, `null` by default) element to search in CSS|XPath|Strict locator.
|
|
1382
|
+
* [!] returns a _promise_ which is synchronized internally by recorder
|
|
1360
1383
|
*
|
|
1361
1384
|
*
|
|
1362
|
-
* [Additional options](https://playwright.dev/docs/api/class-page#page-click) for click available as 3rd argument.
|
|
1385
|
+
* @param {any} [opts] [Additional options](https://playwright.dev/docs/api/class-page#page-click) for click available as 3rd argument.
|
|
1363
1386
|
*
|
|
1364
1387
|
* Examples:
|
|
1365
1388
|
*
|
|
@@ -1411,8 +1434,9 @@ class Playwright extends Helper {
|
|
|
1411
1434
|
* I.forceClick({css: 'nav a.login'});
|
|
1412
1435
|
* ```
|
|
1413
1436
|
*
|
|
1414
|
-
* @param {
|
|
1415
|
-
* @param {?
|
|
1437
|
+
* @param {CodeceptJS.LocatorOrString} locator clickable link or button located by text, or any element located by CSS|XPath|strict locator.
|
|
1438
|
+
* @param {?CodeceptJS.LocatorOrString} [context=null] (optional, `null` by default) element to search in CSS|XPath|Strict locator.
|
|
1439
|
+
* [!] returns a _promise_ which is synchronized internally by recorder
|
|
1416
1440
|
*
|
|
1417
1441
|
*/
|
|
1418
1442
|
async forceClick(locator, context = null) {
|
|
@@ -1430,9 +1454,9 @@ class Playwright extends Helper {
|
|
|
1430
1454
|
* I.doubleClick('.btn.edit');
|
|
1431
1455
|
* ```
|
|
1432
1456
|
*
|
|
1433
|
-
* @param {
|
|
1434
|
-
* @param {?
|
|
1435
|
-
*
|
|
1457
|
+
* @param {CodeceptJS.LocatorOrString} locator clickable link or button located by text, or any element located by CSS|XPath|strict locator.
|
|
1458
|
+
* @param {?CodeceptJS.LocatorOrString} [context=null] (optional, `null` by default) element to search in CSS|XPath|Strict locator.
|
|
1459
|
+
* [!] returns a _promise_ which is synchronized internally by recorder
|
|
1436
1460
|
*
|
|
1437
1461
|
*
|
|
1438
1462
|
*/
|
|
@@ -1452,9 +1476,9 @@ class Playwright extends Helper {
|
|
|
1452
1476
|
* I.rightClick('Click me', '.context');
|
|
1453
1477
|
* ```
|
|
1454
1478
|
*
|
|
1455
|
-
* @param {
|
|
1456
|
-
* @param {?
|
|
1457
|
-
*
|
|
1479
|
+
* @param {CodeceptJS.LocatorOrString} locator clickable element located by CSS|XPath|strict locator.
|
|
1480
|
+
* @param {?CodeceptJS.LocatorOrString} [context=null] (optional, `null` by default) element located by CSS|XPath|strict locator.
|
|
1481
|
+
* [!] returns a _promise_ which is synchronized internally by recorder
|
|
1458
1482
|
*
|
|
1459
1483
|
*
|
|
1460
1484
|
*/
|
|
@@ -1473,8 +1497,9 @@ class Playwright extends Helper {
|
|
|
1473
1497
|
* I.checkOption('I Agree to Terms and Conditions');
|
|
1474
1498
|
* I.checkOption('agree', '//form');
|
|
1475
1499
|
* ```
|
|
1476
|
-
* @param {
|
|
1477
|
-
* @param {?
|
|
1500
|
+
* @param {CodeceptJS.LocatorOrString} field checkbox located by label | name | CSS | XPath | strict locator.
|
|
1501
|
+
* @param {?CodeceptJS.LocatorOrString} [context=null] (optional, `null` by default) element located by CSS | XPath | strict locator.
|
|
1502
|
+
* [!] returns a _promise_ which is synchronized internally by recorder
|
|
1478
1503
|
*
|
|
1479
1504
|
* [Additional options](https://playwright.dev/docs/api/class-elementhandle#element-handle-check) for check available as 3rd argument.
|
|
1480
1505
|
*
|
|
@@ -1503,8 +1528,9 @@ class Playwright extends Helper {
|
|
|
1503
1528
|
* I.uncheckOption('I Agree to Terms and Conditions');
|
|
1504
1529
|
* I.uncheckOption('agree', '//form');
|
|
1505
1530
|
* ```
|
|
1506
|
-
* @param {
|
|
1507
|
-
* @param {?
|
|
1531
|
+
* @param {CodeceptJS.LocatorOrString} field checkbox located by label | name | CSS | XPath | strict locator.
|
|
1532
|
+
* @param {?CodeceptJS.LocatorOrString} [context=null] (optional, `null` by default) element located by CSS | XPath | strict locator.
|
|
1533
|
+
* [!] returns a _promise_ which is synchronized internally by recorder
|
|
1508
1534
|
*
|
|
1509
1535
|
* [Additional options](https://playwright.dev/docs/api/class-elementhandle#element-handle-uncheck) for uncheck available as 3rd argument.
|
|
1510
1536
|
*
|
|
@@ -1531,8 +1557,8 @@ class Playwright extends Helper {
|
|
|
1531
1557
|
* I.seeCheckboxIsChecked({css: '#signup_form input[type=checkbox]'});
|
|
1532
1558
|
* ```
|
|
1533
1559
|
*
|
|
1534
|
-
* @param {
|
|
1535
|
-
*
|
|
1560
|
+
* @param {CodeceptJS.LocatorOrString} field located by label|name|CSS|XPath|strict locator.
|
|
1561
|
+
* [!] returns a _promise_ which is synchronized internally by recorder
|
|
1536
1562
|
*/
|
|
1537
1563
|
async seeCheckboxIsChecked(field) {
|
|
1538
1564
|
return proceedIsChecked.call(this, 'assert', field);
|
|
@@ -1547,8 +1573,8 @@ class Playwright extends Helper {
|
|
|
1547
1573
|
* I.dontSeeCheckboxIsChecked('agree'); // located by name
|
|
1548
1574
|
* ```
|
|
1549
1575
|
*
|
|
1550
|
-
* @param {
|
|
1551
|
-
*
|
|
1576
|
+
* @param {CodeceptJS.LocatorOrString} field located by label|name|CSS|XPath|strict locator.
|
|
1577
|
+
* [!] returns a _promise_ which is synchronized internally by recorder
|
|
1552
1578
|
*/
|
|
1553
1579
|
async dontSeeCheckboxIsChecked(field) {
|
|
1554
1580
|
return proceedIsChecked.call(this, 'negate', field);
|
|
@@ -1566,7 +1592,7 @@ class Playwright extends Helper {
|
|
|
1566
1592
|
* ```
|
|
1567
1593
|
*
|
|
1568
1594
|
* @param {string} key name of key to press down.
|
|
1569
|
-
*
|
|
1595
|
+
* [!] returns a _promise_ which is synchronized internally by recorder
|
|
1570
1596
|
*/
|
|
1571
1597
|
async pressKeyDown(key) {
|
|
1572
1598
|
key = getNormalizedKey.call(this, key);
|
|
@@ -1586,7 +1612,7 @@ class Playwright extends Helper {
|
|
|
1586
1612
|
* ```
|
|
1587
1613
|
*
|
|
1588
1614
|
* @param {string} key name of key to release.
|
|
1589
|
-
*
|
|
1615
|
+
* [!] returns a _promise_ which is synchronized internally by recorder
|
|
1590
1616
|
*/
|
|
1591
1617
|
async pressKeyUp(key) {
|
|
1592
1618
|
key = getNormalizedKey.call(this, key);
|
|
@@ -1654,6 +1680,7 @@ class Playwright extends Helper {
|
|
|
1654
1680
|
* - `'Tab'`
|
|
1655
1681
|
*
|
|
1656
1682
|
* @param {string|string[]} key key or array of keys to press.
|
|
1683
|
+
* [!] returns a _promise_ which is synchronized internally by recorder
|
|
1657
1684
|
*
|
|
1658
1685
|
*
|
|
1659
1686
|
* _Note:_ Shortcuts like `'Meta'` + `'A'` do not work on macOS ([GoogleChrome/Puppeteer#1313](https://github.com/GoogleChrome/puppeteer/issues/1313)).
|
|
@@ -1701,7 +1728,7 @@ class Playwright extends Helper {
|
|
|
1701
1728
|
*
|
|
1702
1729
|
* @param {string|string[]} key or array of keys to type.
|
|
1703
1730
|
* @param {?number} [delay=null] (optional) delay in ms between key presses
|
|
1704
|
-
*
|
|
1731
|
+
* [!] returns a _promise_ which is synchronized internally by recorder
|
|
1705
1732
|
*/
|
|
1706
1733
|
async type(keys, delay = null) {
|
|
1707
1734
|
if (!Array.isArray(keys)) {
|
|
@@ -1728,9 +1755,9 @@ class Playwright extends Helper {
|
|
|
1728
1755
|
* // or by strict locator
|
|
1729
1756
|
* I.fillField({css: 'form#login input[name=username]'}, 'John');
|
|
1730
1757
|
* ```
|
|
1731
|
-
* @param {
|
|
1732
|
-
* @param {
|
|
1733
|
-
*
|
|
1758
|
+
* @param {CodeceptJS.LocatorOrString} field located by label|name|CSS|XPath|strict locator.
|
|
1759
|
+
* @param {CodeceptJS.StringOrSecret} value text value to fill.
|
|
1760
|
+
* [!] returns a _promise_ which is synchronized internally by recorder
|
|
1734
1761
|
*
|
|
1735
1762
|
*/
|
|
1736
1763
|
async fillField(field, value) {
|
|
@@ -1756,8 +1783,8 @@ class Playwright extends Helper {
|
|
|
1756
1783
|
* I.clearField('user[email]');
|
|
1757
1784
|
* I.clearField('#email');
|
|
1758
1785
|
* ```
|
|
1759
|
-
* @param {
|
|
1760
|
-
*
|
|
1786
|
+
* @param {LocatorOrString} editable field located by label|name|CSS|XPath|strict locator.
|
|
1787
|
+
* [!] returns a _promise_ which is synchronized internally by recorder
|
|
1761
1788
|
*/
|
|
1762
1789
|
async clearField(field) {
|
|
1763
1790
|
return this.fillField(field, '');
|
|
@@ -1770,8 +1797,9 @@ class Playwright extends Helper {
|
|
|
1770
1797
|
* ```js
|
|
1771
1798
|
* I.appendField('#myTextField', 'appended');
|
|
1772
1799
|
* ```
|
|
1773
|
-
* @param {
|
|
1800
|
+
* @param {CodeceptJS.LocatorOrString} field located by label|name|CSS|XPath|strict locator
|
|
1774
1801
|
* @param {string} value text value to append.
|
|
1802
|
+
* [!] returns a _promise_ which is synchronized internally by recorder
|
|
1775
1803
|
*
|
|
1776
1804
|
*
|
|
1777
1805
|
*/
|
|
@@ -1793,9 +1821,9 @@ class Playwright extends Helper {
|
|
|
1793
1821
|
* I.seeInField('form input[type=hidden]','hidden_value');
|
|
1794
1822
|
* I.seeInField('#searchform input','Search');
|
|
1795
1823
|
* ```
|
|
1796
|
-
* @param {
|
|
1824
|
+
* @param {CodeceptJS.LocatorOrString} field located by label|name|CSS|XPath|strict locator.
|
|
1797
1825
|
* @param {string} value value to check.
|
|
1798
|
-
*
|
|
1826
|
+
* [!] returns a _promise_ which is synchronized internally by recorder
|
|
1799
1827
|
*/
|
|
1800
1828
|
async seeInField(field, value) {
|
|
1801
1829
|
return proceedSeeInField.call(this, 'assert', field, value);
|
|
@@ -1810,8 +1838,9 @@ class Playwright extends Helper {
|
|
|
1810
1838
|
* I.dontSeeInField({ css: 'form input.email' }, 'user@user.com'); // field by CSS
|
|
1811
1839
|
* ```
|
|
1812
1840
|
*
|
|
1813
|
-
* @param {
|
|
1841
|
+
* @param {CodeceptJS.LocatorOrString} field located by label|name|CSS|XPath|strict locator.
|
|
1814
1842
|
* @param {string} value value to check.
|
|
1843
|
+
* [!] returns a _promise_ which is synchronized internally by recorder
|
|
1815
1844
|
*/
|
|
1816
1845
|
async dontSeeInField(field, value) {
|
|
1817
1846
|
return proceedSeeInField.call(this, 'negate', field, value);
|
|
@@ -1827,8 +1856,9 @@ class Playwright extends Helper {
|
|
|
1827
1856
|
* I.attachFile('form input[name=avatar]', 'data/avatar.jpg');
|
|
1828
1857
|
* ```
|
|
1829
1858
|
*
|
|
1830
|
-
* @param {
|
|
1859
|
+
* @param {CodeceptJS.LocatorOrString} locator field located by label|name|CSS|XPath|strict locator.
|
|
1831
1860
|
* @param {string} pathToFile local file path relative to codecept.json config file.
|
|
1861
|
+
* [!] returns a _promise_ which is synchronized internally by recorder
|
|
1832
1862
|
*
|
|
1833
1863
|
*/
|
|
1834
1864
|
async attachFile(locator, pathToFile) {
|
|
@@ -1862,9 +1892,9 @@ class Playwright extends Helper {
|
|
|
1862
1892
|
* ```js
|
|
1863
1893
|
* I.selectOption('Which OS do you use?', ['Android', 'iOS']);
|
|
1864
1894
|
* ```
|
|
1865
|
-
* @param {
|
|
1895
|
+
* @param {LocatorOrString} select field located by label|name|CSS|XPath|strict locator.
|
|
1866
1896
|
* @param {string|Array<*>} option visible text or value of option.
|
|
1867
|
-
*
|
|
1897
|
+
* [!] returns a _promise_ which is synchronized internally by recorder
|
|
1868
1898
|
*/
|
|
1869
1899
|
async selectOption(select, option) {
|
|
1870
1900
|
const els = await findFields.call(this, select);
|
|
@@ -1903,7 +1933,7 @@ class Playwright extends Helper {
|
|
|
1903
1933
|
* let numOfElements = await I.grabNumberOfVisibleElements('p');
|
|
1904
1934
|
* ```
|
|
1905
1935
|
*
|
|
1906
|
-
* @param {
|
|
1936
|
+
* @param {CodeceptJS.LocatorOrString} locator located by CSS|XPath|strict locator.
|
|
1907
1937
|
* @returns {Promise<number>} number of visible elements
|
|
1908
1938
|
*
|
|
1909
1939
|
*/
|
|
@@ -1921,6 +1951,7 @@ class Playwright extends Helper {
|
|
|
1921
1951
|
* ```
|
|
1922
1952
|
*
|
|
1923
1953
|
* @param {string} url a fragment to check
|
|
1954
|
+
* [!] returns a _promise_ which is synchronized internally by recorder
|
|
1924
1955
|
*/
|
|
1925
1956
|
async seeInCurrentUrl(url) {
|
|
1926
1957
|
stringIncludes('url').assert(url, await this._getPageUrl());
|
|
@@ -1930,6 +1961,7 @@ class Playwright extends Helper {
|
|
|
1930
1961
|
* Checks that current url does not contain a provided fragment.
|
|
1931
1962
|
*
|
|
1932
1963
|
* @param {string} url value to check.
|
|
1964
|
+
* [!] returns a _promise_ which is synchronized internally by recorder
|
|
1933
1965
|
*/
|
|
1934
1966
|
async dontSeeInCurrentUrl(url) {
|
|
1935
1967
|
stringIncludes('url').negate(url, await this._getPageUrl());
|
|
@@ -1946,6 +1978,7 @@ class Playwright extends Helper {
|
|
|
1946
1978
|
* ```
|
|
1947
1979
|
*
|
|
1948
1980
|
* @param {string} url value to check.
|
|
1981
|
+
* [!] returns a _promise_ which is synchronized internally by recorder
|
|
1949
1982
|
*/
|
|
1950
1983
|
async seeCurrentUrlEquals(url) {
|
|
1951
1984
|
urlEquals(this.options.url).assert(url, await this._getPageUrl());
|
|
@@ -1961,6 +1994,7 @@ class Playwright extends Helper {
|
|
|
1961
1994
|
* ```
|
|
1962
1995
|
*
|
|
1963
1996
|
* @param {string} url value to check.
|
|
1997
|
+
* [!] returns a _promise_ which is synchronized internally by recorder
|
|
1964
1998
|
*/
|
|
1965
1999
|
async dontSeeCurrentUrlEquals(url) {
|
|
1966
2000
|
urlEquals(this.options.url).negate(url, await this._getPageUrl());
|
|
@@ -1976,7 +2010,8 @@ class Playwright extends Helper {
|
|
|
1976
2010
|
* I.see('Register', {css: 'form.register'}); // use strict locator
|
|
1977
2011
|
* ```
|
|
1978
2012
|
* @param {string} text expected on page.
|
|
1979
|
-
* @param {?
|
|
2013
|
+
* @param {?CodeceptJS.LocatorOrString} [context=null] (optional, `null` by default) element located by CSS|Xpath|strict locator in which to search for text.
|
|
2014
|
+
* [!] returns a _promise_ which is synchronized internally by recorder
|
|
1980
2015
|
*
|
|
1981
2016
|
*
|
|
1982
2017
|
*/
|
|
@@ -1992,7 +2027,8 @@ class Playwright extends Helper {
|
|
|
1992
2027
|
* ```
|
|
1993
2028
|
*
|
|
1994
2029
|
* @param {string} text element value to check.
|
|
1995
|
-
* @param {
|
|
2030
|
+
* @param {CodeceptJS.LocatorOrString?} [context=null] element located by CSS|XPath|strict locator.
|
|
2031
|
+
* [!] returns a _promise_ which is synchronized internally by recorder
|
|
1996
2032
|
*/
|
|
1997
2033
|
async seeTextEquals(text, context = null) {
|
|
1998
2034
|
return proceedSee.call(this, 'assert', text, context, true);
|
|
@@ -2008,8 +2044,8 @@ class Playwright extends Helper {
|
|
|
2008
2044
|
* ```
|
|
2009
2045
|
*
|
|
2010
2046
|
* @param {string} text which is not present.
|
|
2011
|
-
* @param {
|
|
2012
|
-
*
|
|
2047
|
+
* @param {CodeceptJS.LocatorOrString} [context] (optional) element located by CSS|XPath|strict locator in which to perfrom search.
|
|
2048
|
+
* [!] returns a _promise_ which is synchronized internally by recorder
|
|
2013
2049
|
*
|
|
2014
2050
|
*
|
|
2015
2051
|
*/
|
|
@@ -2068,6 +2104,7 @@ class Playwright extends Helper {
|
|
|
2068
2104
|
* I.seeInSource('<h1>Green eggs & ham</h1>');
|
|
2069
2105
|
* ```
|
|
2070
2106
|
* @param {string} text value to check.
|
|
2107
|
+
* [!] returns a _promise_ which is synchronized internally by recorder
|
|
2071
2108
|
*/
|
|
2072
2109
|
async seeInSource(text) {
|
|
2073
2110
|
const source = await this.page.content();
|
|
@@ -2082,7 +2119,7 @@ class Playwright extends Helper {
|
|
|
2082
2119
|
* ```
|
|
2083
2120
|
*
|
|
2084
2121
|
* @param {string} value to check.
|
|
2085
|
-
*
|
|
2122
|
+
* [!] returns a _promise_ which is synchronized internally by recorder
|
|
2086
2123
|
*/
|
|
2087
2124
|
async dontSeeInSource(text) {
|
|
2088
2125
|
const source = await this.page.content();
|
|
@@ -2098,9 +2135,9 @@ class Playwright extends Helper {
|
|
|
2098
2135
|
* I.seeNumberOfElements('#submitBtn', 1);
|
|
2099
2136
|
* ```
|
|
2100
2137
|
*
|
|
2101
|
-
* @param {
|
|
2138
|
+
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
2102
2139
|
* @param {number} num number of elements.
|
|
2103
|
-
*
|
|
2140
|
+
* [!] returns a _promise_ which is synchronized internally by recorder
|
|
2104
2141
|
*
|
|
2105
2142
|
*
|
|
2106
2143
|
*/
|
|
@@ -2117,9 +2154,9 @@ class Playwright extends Helper {
|
|
|
2117
2154
|
* I.seeNumberOfVisibleElements('.buttons', 3);
|
|
2118
2155
|
* ```
|
|
2119
2156
|
*
|
|
2120
|
-
* @param {
|
|
2157
|
+
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
2121
2158
|
* @param {number} num number of elements.
|
|
2122
|
-
*
|
|
2159
|
+
* [!] returns a _promise_ which is synchronized internally by recorder
|
|
2123
2160
|
*
|
|
2124
2161
|
*
|
|
2125
2162
|
*/
|
|
@@ -2144,7 +2181,7 @@ class Playwright extends Helper {
|
|
|
2144
2181
|
* ```
|
|
2145
2182
|
*
|
|
2146
2183
|
* @param {Cookie|Array<Cookie>} cookie a cookie object or array of cookie objects.
|
|
2147
|
-
*
|
|
2184
|
+
* [!] returns a _promise_ which is synchronized internally by recorder
|
|
2148
2185
|
*/
|
|
2149
2186
|
async setCookie(cookie) {
|
|
2150
2187
|
if (Array.isArray(cookie)) {
|
|
@@ -2161,7 +2198,7 @@ class Playwright extends Helper {
|
|
|
2161
2198
|
* ```
|
|
2162
2199
|
*
|
|
2163
2200
|
* @param {string} name cookie name.
|
|
2164
|
-
*
|
|
2201
|
+
* [!] returns a _promise_ which is synchronized internally by recorder
|
|
2165
2202
|
*
|
|
2166
2203
|
*/
|
|
2167
2204
|
async seeCookie(name) {
|
|
@@ -2177,6 +2214,7 @@ class Playwright extends Helper {
|
|
|
2177
2214
|
* ```
|
|
2178
2215
|
*
|
|
2179
2216
|
* @param {string} name cookie name.
|
|
2217
|
+
* [!] returns a _promise_ which is synchronized internally by recorder
|
|
2180
2218
|
*/
|
|
2181
2219
|
async dontSeeCookie(name) {
|
|
2182
2220
|
const cookies = await this.browserContext.cookies();
|
|
@@ -2216,6 +2254,7 @@ class Playwright extends Helper {
|
|
|
2216
2254
|
* ```
|
|
2217
2255
|
*
|
|
2218
2256
|
* @param {?string} [cookie=null] (optional, `null` by default) cookie name
|
|
2257
|
+
* [!] returns a _promise_ which is synchronized internally by recorder
|
|
2219
2258
|
*/
|
|
2220
2259
|
async clearCookie() {
|
|
2221
2260
|
// Playwright currently doesn't support to delete a certain cookie
|
|
@@ -2246,7 +2285,6 @@ class Playwright extends Helper {
|
|
|
2246
2285
|
*
|
|
2247
2286
|
* @param {string|function} fn function to be executed in browser context.
|
|
2248
2287
|
* @param {any} [arg] optional argument to pass to the function
|
|
2249
|
-
* @return {Promise<any>}
|
|
2250
2288
|
*/
|
|
2251
2289
|
async executeScript(fn, arg) {
|
|
2252
2290
|
let context = this.page;
|
|
@@ -2281,7 +2319,7 @@ class Playwright extends Helper {
|
|
|
2281
2319
|
* ```
|
|
2282
2320
|
* If multiple elements found returns first element.
|
|
2283
2321
|
*
|
|
2284
|
-
* @param {
|
|
2322
|
+
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
2285
2323
|
* @returns {Promise<string>} attribute value
|
|
2286
2324
|
*
|
|
2287
2325
|
*
|
|
@@ -2302,7 +2340,7 @@ class Playwright extends Helper {
|
|
|
2302
2340
|
* let pins = await I.grabTextFromAll('#pin li');
|
|
2303
2341
|
* ```
|
|
2304
2342
|
*
|
|
2305
|
-
* @param {
|
|
2343
|
+
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
2306
2344
|
* @returns {Promise<string[]>} attribute value
|
|
2307
2345
|
*
|
|
2308
2346
|
*
|
|
@@ -2325,7 +2363,7 @@ class Playwright extends Helper {
|
|
|
2325
2363
|
* ```js
|
|
2326
2364
|
* let email = await I.grabValueFrom('input[name=email]');
|
|
2327
2365
|
* ```
|
|
2328
|
-
* @param {
|
|
2366
|
+
* @param {CodeceptJS.LocatorOrString} locator field located by label|name|CSS|XPath|strict locator.
|
|
2329
2367
|
* @returns {Promise<string>} attribute value
|
|
2330
2368
|
*
|
|
2331
2369
|
*/
|
|
@@ -2343,7 +2381,7 @@ class Playwright extends Helper {
|
|
|
2343
2381
|
* ```js
|
|
2344
2382
|
* let inputs = await I.grabValueFromAll('//form/input');
|
|
2345
2383
|
* ```
|
|
2346
|
-
* @param {
|
|
2384
|
+
* @param {CodeceptJS.LocatorOrString} locator field located by label|name|CSS|XPath|strict locator.
|
|
2347
2385
|
* @returns {Promise<string[]>} attribute value
|
|
2348
2386
|
*
|
|
2349
2387
|
*/
|
|
@@ -2362,7 +2400,7 @@ class Playwright extends Helper {
|
|
|
2362
2400
|
* let postHTML = await I.grabHTMLFrom('#post');
|
|
2363
2401
|
* ```
|
|
2364
2402
|
*
|
|
2365
|
-
* @param {
|
|
2403
|
+
* @param {CodeceptJS.LocatorOrString} element located by CSS|XPath|strict locator.
|
|
2366
2404
|
* @returns {Promise<string>} HTML code for an element
|
|
2367
2405
|
*
|
|
2368
2406
|
*/
|
|
@@ -2381,7 +2419,7 @@ class Playwright extends Helper {
|
|
|
2381
2419
|
* let postHTMLs = await I.grabHTMLFromAll('.post');
|
|
2382
2420
|
* ```
|
|
2383
2421
|
*
|
|
2384
|
-
* @param {
|
|
2422
|
+
* @param {CodeceptJS.LocatorOrString} element located by CSS|XPath|strict locator.
|
|
2385
2423
|
* @returns {Promise<string[]>} HTML code for an element
|
|
2386
2424
|
*
|
|
2387
2425
|
*/
|
|
@@ -2400,7 +2438,7 @@ class Playwright extends Helper {
|
|
|
2400
2438
|
* const value = await I.grabCssPropertyFrom('h3', 'font-weight');
|
|
2401
2439
|
* ```
|
|
2402
2440
|
*
|
|
2403
|
-
* @param {
|
|
2441
|
+
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
2404
2442
|
* @param {string} cssProperty CSS property name.
|
|
2405
2443
|
* @returns {Promise<string>} CSS value
|
|
2406
2444
|
*
|
|
@@ -2421,7 +2459,7 @@ class Playwright extends Helper {
|
|
|
2421
2459
|
* const values = await I.grabCssPropertyFromAll('h3', 'font-weight');
|
|
2422
2460
|
* ```
|
|
2423
2461
|
*
|
|
2424
|
-
* @param {
|
|
2462
|
+
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
2425
2463
|
* @param {string} cssProperty CSS property name.
|
|
2426
2464
|
* @returns {Promise<string[]>} CSS value
|
|
2427
2465
|
*
|
|
@@ -2442,8 +2480,9 @@ class Playwright extends Helper {
|
|
|
2442
2480
|
* I.seeCssPropertiesOnElements('h3', { 'font-weight': "bold"});
|
|
2443
2481
|
* ```
|
|
2444
2482
|
*
|
|
2445
|
-
* @param {
|
|
2483
|
+
* @param {CodeceptJS.LocatorOrString} locator located by CSS|XPath|strict locator.
|
|
2446
2484
|
* @param {object} cssProperties object with CSS properties and their values to check.
|
|
2485
|
+
* [!] returns a _promise_ which is synchronized internally by recorder
|
|
2447
2486
|
*
|
|
2448
2487
|
*/
|
|
2449
2488
|
async seeCssPropertiesOnElements(locator, cssProperties) {
|
|
@@ -2487,8 +2526,9 @@ class Playwright extends Helper {
|
|
|
2487
2526
|
* I.seeAttributesOnElements('//form', { method: "post"});
|
|
2488
2527
|
* ```
|
|
2489
2528
|
*
|
|
2490
|
-
* @param {
|
|
2529
|
+
* @param {CodeceptJS.LocatorOrString} locator located by CSS|XPath|strict locator.
|
|
2491
2530
|
* @param {object} attributes attributes and their values to check.
|
|
2531
|
+
* [!] returns a _promise_ which is synchronized internally by recorder
|
|
2492
2532
|
*
|
|
2493
2533
|
*/
|
|
2494
2534
|
async seeAttributesOnElements(locator, attributes) {
|
|
@@ -2525,8 +2565,9 @@ class Playwright extends Helper {
|
|
|
2525
2565
|
* I.dragSlider('#slider', -70);
|
|
2526
2566
|
* ```
|
|
2527
2567
|
*
|
|
2528
|
-
* @param {
|
|
2568
|
+
* @param {CodeceptJS.LocatorOrString} locator located by label|name|CSS|XPath|strict locator.
|
|
2529
2569
|
* @param {number} offsetX position to drag.
|
|
2570
|
+
* [!] returns a _promise_ which is synchronized internally by recorder
|
|
2530
2571
|
*
|
|
2531
2572
|
*/
|
|
2532
2573
|
async dragSlider(locator, offsetX = 0) {
|
|
@@ -2555,7 +2596,7 @@ class Playwright extends Helper {
|
|
|
2555
2596
|
* ```js
|
|
2556
2597
|
* let hint = await I.grabAttributeFrom('#tooltip', 'title');
|
|
2557
2598
|
* ```
|
|
2558
|
-
* @param {
|
|
2599
|
+
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
2559
2600
|
* @param {string} attr attribute name.
|
|
2560
2601
|
* @returns {Promise<string>} attribute value
|
|
2561
2602
|
*
|
|
@@ -2575,7 +2616,7 @@ class Playwright extends Helper {
|
|
|
2575
2616
|
* ```js
|
|
2576
2617
|
* let hints = await I.grabAttributeFromAll('.tooltip', 'title');
|
|
2577
2618
|
* ```
|
|
2578
|
-
* @param {
|
|
2619
|
+
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
2579
2620
|
* @param {string} attr attribute name.
|
|
2580
2621
|
* @returns {Promise<string[]>} attribute value
|
|
2581
2622
|
*
|
|
@@ -2602,9 +2643,9 @@ class Playwright extends Helper {
|
|
|
2602
2643
|
* I.saveElementScreenshot(`#submit`,'debug.png');
|
|
2603
2644
|
* ```
|
|
2604
2645
|
*
|
|
2605
|
-
* @param {
|
|
2646
|
+
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
2606
2647
|
* @param {string} fileName file name to save.
|
|
2607
|
-
*
|
|
2648
|
+
* [!] returns a _promise_ which is synchronized internally by recorder
|
|
2608
2649
|
*
|
|
2609
2650
|
*/
|
|
2610
2651
|
async saveElementScreenshot(locator, fileName) {
|
|
@@ -2630,6 +2671,7 @@ class Playwright extends Helper {
|
|
|
2630
2671
|
*
|
|
2631
2672
|
* @param {string} fileName file name to save.
|
|
2632
2673
|
* @param {boolean} [fullPage=false] (optional, `false` by default) flag to enable fullscreen screenshot mode.
|
|
2674
|
+
* [!] returns a _promise_ which is synchronized internally by recorder
|
|
2633
2675
|
*/
|
|
2634
2676
|
async saveScreenshot(fileName, fullPage) {
|
|
2635
2677
|
const fullPageOption = fullPage || this.options.fullPageScreenshots;
|
|
@@ -2706,7 +2748,7 @@ class Playwright extends Helper {
|
|
|
2706
2748
|
test.artifacts = {};
|
|
2707
2749
|
}
|
|
2708
2750
|
|
|
2709
|
-
if (this.options.recordVideo && this.page.video()) {
|
|
2751
|
+
if (this.options.recordVideo && this.page && this.page.video()) {
|
|
2710
2752
|
test.artifacts.video = await this.page.video().path();
|
|
2711
2753
|
}
|
|
2712
2754
|
|
|
@@ -2718,7 +2760,7 @@ class Playwright extends Helper {
|
|
|
2718
2760
|
}
|
|
2719
2761
|
|
|
2720
2762
|
async _passed(test) {
|
|
2721
|
-
if (this.options.recordVideo && this.page.video()) {
|
|
2763
|
+
if (this.options.recordVideo && this.page && this.page.video()) {
|
|
2722
2764
|
if (this.options.keepVideoForPassedTests) {
|
|
2723
2765
|
test.artifacts.video = await this.page.video().path();
|
|
2724
2766
|
} else {
|
|
@@ -2745,6 +2787,7 @@ class Playwright extends Helper {
|
|
|
2745
2787
|
* ```
|
|
2746
2788
|
*
|
|
2747
2789
|
* @param {number} sec number of second to wait.
|
|
2790
|
+
* [!] returns a _promise_ which is synchronized internally by recorder
|
|
2748
2791
|
*/
|
|
2749
2792
|
async wait(sec) {
|
|
2750
2793
|
return new Promise(((done) => {
|
|
@@ -2756,8 +2799,9 @@ class Playwright extends Helper {
|
|
|
2756
2799
|
* Waits for element to become enabled (by default waits for 1sec).
|
|
2757
2800
|
* Element can be located by CSS or XPath.
|
|
2758
2801
|
*
|
|
2759
|
-
* @param {
|
|
2802
|
+
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
2760
2803
|
* @param {number} [sec=1] (optional) time in seconds to wait, 1 by default.
|
|
2804
|
+
* [!] returns a _promise_ which is synchronized internally by recorder
|
|
2761
2805
|
*/
|
|
2762
2806
|
async waitForEnabled(locator, sec) {
|
|
2763
2807
|
const waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout;
|
|
@@ -2789,10 +2833,10 @@ class Playwright extends Helper {
|
|
|
2789
2833
|
* I.waitForValue('//input', "GoodValue");
|
|
2790
2834
|
* ```
|
|
2791
2835
|
*
|
|
2792
|
-
* @param {
|
|
2836
|
+
* @param {LocatorOrString} field input field.
|
|
2793
2837
|
* @param {string }value expected value.
|
|
2794
2838
|
* @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
|
|
2795
|
-
*
|
|
2839
|
+
* [!] returns a _promise_ which is synchronized internally by recorder
|
|
2796
2840
|
*/
|
|
2797
2841
|
async waitForValue(field, value, sec) {
|
|
2798
2842
|
const waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout;
|
|
@@ -2825,9 +2869,10 @@ class Playwright extends Helper {
|
|
|
2825
2869
|
* I.waitNumberOfVisibleElements('a', 3);
|
|
2826
2870
|
* ```
|
|
2827
2871
|
*
|
|
2828
|
-
* @param {
|
|
2872
|
+
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
2829
2873
|
* @param {number} num number of elements.
|
|
2830
2874
|
* @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
|
|
2875
|
+
* [!] returns a _promise_ which is synchronized internally by recorder
|
|
2831
2876
|
*
|
|
2832
2877
|
*/
|
|
2833
2878
|
async waitNumberOfVisibleElements(locator, num, sec) {
|
|
@@ -2866,8 +2911,9 @@ class Playwright extends Helper {
|
|
|
2866
2911
|
* I.waitForClickable('.btn.continue', 5); // wait for 5 secs
|
|
2867
2912
|
* ```
|
|
2868
2913
|
*
|
|
2869
|
-
* @param {
|
|
2914
|
+
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
2870
2915
|
* @param {number} [sec] (optional, `1` by default) time in seconds to wait
|
|
2916
|
+
* [!] returns a _promise_ which is synchronized internally by recorder
|
|
2871
2917
|
*/
|
|
2872
2918
|
async waitForClickable(locator, waitTimeout) {
|
|
2873
2919
|
console.log('I.waitForClickable is DEPRECATED: This is no longer needed, Playwright automatically waits for element to be clickable');
|
|
@@ -2883,8 +2929,9 @@ class Playwright extends Helper {
|
|
|
2883
2929
|
* I.waitForElement('.btn.continue', 5); // wait for 5 secs
|
|
2884
2930
|
* ```
|
|
2885
2931
|
*
|
|
2886
|
-
* @param {
|
|
2932
|
+
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
2887
2933
|
* @param {number} [sec] (optional, `1` by default) time in seconds to wait
|
|
2934
|
+
* [!] returns a _promise_ which is synchronized internally by recorder
|
|
2888
2935
|
*
|
|
2889
2936
|
*/
|
|
2890
2937
|
async waitForElement(locator, sec) {
|
|
@@ -2906,9 +2953,9 @@ class Playwright extends Helper {
|
|
|
2906
2953
|
* I.waitForVisible('#popup');
|
|
2907
2954
|
* ```
|
|
2908
2955
|
*
|
|
2909
|
-
* @param {
|
|
2956
|
+
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
2910
2957
|
* @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
|
|
2911
|
-
*
|
|
2958
|
+
* [!] returns a _promise_ which is synchronized internally by recorder
|
|
2912
2959
|
*
|
|
2913
2960
|
* This method accepts [React selectors](https://codecept.io/react).
|
|
2914
2961
|
*/
|
|
@@ -2930,8 +2977,9 @@ class Playwright extends Helper {
|
|
|
2930
2977
|
* I.waitForInvisible('#popup');
|
|
2931
2978
|
* ```
|
|
2932
2979
|
*
|
|
2933
|
-
* @param {
|
|
2980
|
+
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
2934
2981
|
* @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
|
|
2982
|
+
* [!] returns a _promise_ which is synchronized internally by recorder
|
|
2935
2983
|
*/
|
|
2936
2984
|
async waitForInvisible(locator, sec) {
|
|
2937
2985
|
const waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout;
|
|
@@ -2951,8 +2999,9 @@ class Playwright extends Helper {
|
|
|
2951
2999
|
* I.waitToHide('#popup');
|
|
2952
3000
|
* ```
|
|
2953
3001
|
*
|
|
2954
|
-
* @param {
|
|
3002
|
+
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
2955
3003
|
* @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
|
|
3004
|
+
* [!] returns a _promise_ which is synchronized internally by recorder
|
|
2956
3005
|
*/
|
|
2957
3006
|
async waitToHide(locator, sec) {
|
|
2958
3007
|
const waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout;
|
|
@@ -2979,6 +3028,7 @@ class Playwright extends Helper {
|
|
|
2979
3028
|
*
|
|
2980
3029
|
* @param {string} urlPart value to check.
|
|
2981
3030
|
* @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
|
|
3031
|
+
* [!] returns a _promise_ which is synchronized internally by recorder
|
|
2982
3032
|
*/
|
|
2983
3033
|
async waitInUrl(urlPart, sec = null) {
|
|
2984
3034
|
const waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout;
|
|
@@ -3006,6 +3056,7 @@ class Playwright extends Helper {
|
|
|
3006
3056
|
*
|
|
3007
3057
|
* @param {string} urlPart value to check.
|
|
3008
3058
|
* @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
|
|
3059
|
+
* [!] returns a _promise_ which is synchronized internally by recorder
|
|
3009
3060
|
*/
|
|
3010
3061
|
async waitUrlEquals(urlPart, sec = null) {
|
|
3011
3062
|
const waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout;
|
|
@@ -3040,7 +3091,8 @@ class Playwright extends Helper {
|
|
|
3040
3091
|
*
|
|
3041
3092
|
* @param {string }text to wait for.
|
|
3042
3093
|
* @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
|
|
3043
|
-
* @param {
|
|
3094
|
+
* @param {CodeceptJS.LocatorOrString} [context] (optional) element located by CSS|XPath|strict locator.
|
|
3095
|
+
* [!] returns a _promise_ which is synchronized internally by recorder
|
|
3044
3096
|
*/
|
|
3045
3097
|
async waitForText(text, sec = null, context = null) {
|
|
3046
3098
|
const waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout;
|
|
@@ -3110,7 +3162,8 @@ class Playwright extends Helper {
|
|
|
3110
3162
|
* I.switchTo(); // switch back to main page
|
|
3111
3163
|
* ```
|
|
3112
3164
|
*
|
|
3113
|
-
* @param {?
|
|
3165
|
+
* @param {?CodeceptJS.LocatorOrString} [locator=null] (optional, `null` by default) element located by CSS|XPath|strict locator.
|
|
3166
|
+
* [!] returns a _promise_ which is synchronized internally by recorder
|
|
3114
3167
|
*/
|
|
3115
3168
|
async switchTo(locator) {
|
|
3116
3169
|
if (Number.isInteger(locator)) {
|
|
@@ -3168,7 +3221,7 @@ class Playwright extends Helper {
|
|
|
3168
3221
|
* @param {string|function} fn to be executed in browser context.
|
|
3169
3222
|
* @param {any[]|number} [argsOrSec] (optional, `1` by default) arguments for function or seconds.
|
|
3170
3223
|
* @param {number} [sec] (optional, `1` by default) time in seconds to wait
|
|
3171
|
-
*
|
|
3224
|
+
* [!] returns a _promise_ which is synchronized internally by recorder
|
|
3172
3225
|
*/
|
|
3173
3226
|
async waitForFunction(fn, argsOrSec = null, sec = null) {
|
|
3174
3227
|
let args = [];
|
|
@@ -3215,8 +3268,9 @@ class Playwright extends Helper {
|
|
|
3215
3268
|
* I.waitForDetached('#popup');
|
|
3216
3269
|
* ```
|
|
3217
3270
|
*
|
|
3218
|
-
* @param {
|
|
3271
|
+
* @param {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
3219
3272
|
* @param {number} [sec=1] (optional, `1` by default) time in seconds to wait
|
|
3273
|
+
* [!] returns a _promise_ which is synchronized internally by recorder
|
|
3220
3274
|
*/
|
|
3221
3275
|
async waitForDetached(locator, sec) {
|
|
3222
3276
|
const waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout;
|
|
@@ -3262,6 +3316,7 @@ class Playwright extends Helper {
|
|
|
3262
3316
|
* loadEventEnd: 241
|
|
3263
3317
|
* }
|
|
3264
3318
|
* ```
|
|
3319
|
+
* @return {Promise<any>} automatically synchronized promise through #recorder
|
|
3265
3320
|
*/
|
|
3266
3321
|
async grabDataFromPerformanceTiming() {
|
|
3267
3322
|
return perfTiming;
|
|
@@ -3285,7 +3340,7 @@ class Playwright extends Helper {
|
|
|
3285
3340
|
* const width = await I.grabElementBoundingRect('h3', 'width');
|
|
3286
3341
|
* // width == 527
|
|
3287
3342
|
* ```
|
|
3288
|
-
* @param {
|
|
3343
|
+
* @param {LocatorOrString} locator element located by CSS|XPath|strict locator.
|
|
3289
3344
|
* @param {string=} elementSize x, y, width or height of the given element.
|
|
3290
3345
|
* @returns {Promise<DOMRect>|Promise<number>} Element bounding rectangle
|
|
3291
3346
|
*
|
|
@@ -3306,9 +3361,8 @@ class Playwright extends Helper {
|
|
|
3306
3361
|
* ```
|
|
3307
3362
|
* This method allows intercepting and mocking requests & responses. [Learn more about it](https://playwright.dev/docs/network#handle-requests)
|
|
3308
3363
|
*
|
|
3309
|
-
* @param {string} [url] URL, regex or pattern for to match URL
|
|
3310
|
-
* @param {function} [handler] a function to process
|
|
3311
|
-
*
|
|
3364
|
+
* @param {string|RegExp} [url] URL, regex or pattern for to match URL
|
|
3365
|
+
* @param {function} [handler] a function to process reques
|
|
3312
3366
|
*/
|
|
3313
3367
|
async mockRoute(url, handler) {
|
|
3314
3368
|
return this.browserContext.route(...arguments);
|
|
@@ -3323,9 +3377,8 @@ class Playwright extends Helper {
|
|
|
3323
3377
|
* ```
|
|
3324
3378
|
* If no handler is passed, all mock requests for the rote are disabled.
|
|
3325
3379
|
*
|
|
3326
|
-
* @param {string} [url] URL, regex or pattern for to match URL
|
|
3327
|
-
* @param {function} [handler] a function to process
|
|
3328
|
-
*
|
|
3380
|
+
* @param {string|RegExp} [url] URL, regex or pattern for to match URL
|
|
3381
|
+
* @param {function} [handler] a function to process reques
|
|
3329
3382
|
*/
|
|
3330
3383
|
async stopMockingRoute(url, handler) {
|
|
3331
3384
|
return this.browserContext.unroute(...arguments);
|