playwright-cucumber-ts-steps 1.3.0 → 1.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/dist/backend/actions/click.d.ts +84 -0
- package/dist/backend/actions/click.d.ts.map +1 -1
- package/dist/backend/actions/click.js +167 -17
- package/dist/backend/actions/form.d.ts +6 -0
- package/dist/backend/actions/form.d.ts.map +1 -1
- package/dist/backend/actions/form.js +17 -1
- package/dist/backend/actions/formTable.js +1 -1
- package/dist/backend/actions/frames.js +3 -3
- package/dist/backend/actions/index.d.ts +2 -0
- package/dist/backend/actions/index.d.ts.map +1 -1
- package/dist/backend/actions/index.js +2 -0
- package/dist/backend/actions/inputs.js +18 -18
- package/dist/backend/actions/interactions.d.ts +14 -5
- package/dist/backend/actions/interactions.d.ts.map +1 -1
- package/dist/backend/actions/interactions.js +69 -13
- package/dist/backend/actions/keyboard.js +6 -6
- package/dist/backend/actions/misc.d.ts +8 -2
- package/dist/backend/actions/misc.d.ts.map +1 -1
- package/dist/backend/actions/misc.js +64 -16
- package/dist/backend/actions/mobile.js +7 -7
- package/dist/backend/actions/mouse.js +9 -9
- package/dist/backend/actions/navigation.js +5 -5
- package/dist/backend/actions/visual.d.ts +47 -0
- package/dist/backend/actions/visual.d.ts.map +1 -0
- package/dist/backend/actions/visual.js +97 -0
- package/dist/backend/actions/waits.d.ts +6 -0
- package/dist/backend/actions/waits.d.ts.map +1 -1
- package/dist/backend/actions/waits.js +18 -5
- package/dist/backend/api/assertions.js +3 -3
- package/dist/backend/api/mock.js +3 -3
- package/dist/backend/api/network.js +6 -6
- package/dist/backend/api/requests.js +4 -4
- package/dist/backend/assertions/document.d.ts +61 -0
- package/dist/backend/assertions/document.d.ts.map +1 -0
- package/dist/backend/assertions/document.js +166 -0
- package/dist/backend/assertions/elements.d.ts +163 -0
- package/dist/backend/assertions/elements.d.ts.map +1 -0
- package/dist/backend/assertions/elements.js +441 -0
- package/dist/backend/assertions/expectVisible.js +1 -1
- package/dist/backend/assertions/forms.d.ts +43 -0
- package/dist/backend/assertions/forms.d.ts.map +1 -0
- package/dist/backend/assertions/forms.js +126 -0
- package/dist/backend/assertions/index.d.ts +10 -0
- package/dist/backend/assertions/index.d.ts.map +1 -1
- package/dist/backend/assertions/index.js +10 -0
- package/dist/backend/assertions/pageState.js +4 -4
- package/dist/backend/assertions/storage.d.ts +67 -0
- package/dist/backend/assertions/storage.d.ts.map +1 -0
- package/dist/backend/assertions/storage.js +220 -0
- package/dist/backend/assertions/text.d.ts +103 -12
- package/dist/backend/assertions/text.d.ts.map +1 -1
- package/dist/backend/assertions/text.js +207 -28
- package/dist/backend/assertions/visibility.d.ts +18 -0
- package/dist/backend/assertions/visibility.d.ts.map +1 -1
- package/dist/backend/assertions/visibility.js +58 -12
- package/dist/backend/auth/index.js +2 -2
- package/dist/backend/db/steps.d.ts +2 -2
- package/dist/backend/db/steps.d.ts.map +1 -1
- package/dist/backend/db/steps.js +11 -11
- package/dist/backend/elements/alerts.js +3 -3
- package/dist/backend/elements/find.js +26 -24
- package/dist/backend/elements/forms.js +4 -4
- package/dist/backend/elements/frames.js +3 -3
- package/dist/backend/utils/fixtures.js +1 -1
- package/dist/backend/utils/resolver.d.ts +6 -0
- package/dist/backend/utils/resolver.d.ts.map +1 -0
- package/dist/backend/utils/resolver.js +19 -0
- package/dist/component/index.d.ts +3 -0
- package/dist/component/index.d.ts.map +1 -0
- package/dist/component/index.js +6 -0
- package/dist/component/runner.d.ts +18 -0
- package/dist/component/runner.d.ts.map +1 -0
- package/dist/component/runner.js +91 -0
- package/dist/core/runner.d.ts +1 -0
- package/dist/core/runner.d.ts.map +1 -1
- package/dist/core/runner.js +179 -124
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/metadata.json +564 -172
- package/package.json +4 -3
|
@@ -183,21 +183,21 @@ async function uploadFile(page, filePath) {
|
|
|
183
183
|
// ==================================================
|
|
184
184
|
// GLUE STEPS
|
|
185
185
|
// ==================================================
|
|
186
|
-
(0, registry_1.Step)("I type {string}", typeText, "When");
|
|
187
|
-
(0, registry_1.Step)("I fill {string}", typeText, "When");
|
|
188
|
-
(0, registry_1.Step)("I type stored {string}", typeStoredText, "When");
|
|
189
|
-
(0, registry_1.Step)("I fill stored {string}", typeStoredText, "When");
|
|
190
|
-
(0, registry_1.Step)("I slowly type {string}", typeSlowly, "When");
|
|
191
|
-
(0, registry_1.Step)("I slowly fill {string}", typeSlowly, "When");
|
|
192
|
-
(0, registry_1.Step)("I set value {string}", setInputValue, "When");
|
|
193
|
-
(0, registry_1.Step)("I clear", clearInput, "When");
|
|
194
|
-
(0, registry_1.Step)("I press {string}", pressKeyOnInput, "When");
|
|
195
|
-
(0, registry_1.Step)("I check", checkElement, "When");
|
|
196
|
-
(0, registry_1.Step)("I uncheck", uncheckElement, "When");
|
|
197
|
-
(0, registry_1.Step)("I check input", checkElement, "When");
|
|
198
|
-
(0, registry_1.Step)("I uncheck input", uncheckElement, "When");
|
|
199
|
-
(0, registry_1.Step)("I {string} {int}(?:st|nd|rd|th) selector {string}", checkNthElementBySelector, "When");
|
|
200
|
-
(0, registry_1.Step)("I select option {string}", selectOption, "When");
|
|
201
|
-
(0, registry_1.Step)("I submit", submitForm, "When");
|
|
202
|
-
(0, registry_1.Step)("I select file {string}", selectFile, "When");
|
|
203
|
-
(0, registry_1.Step)("I upload file {string}", uploadFile, "When");
|
|
186
|
+
(0, registry_1.Step)("I pw type {string}", typeText, "When");
|
|
187
|
+
(0, registry_1.Step)("I pw fill {string}", typeText, "When");
|
|
188
|
+
(0, registry_1.Step)("I pw type stored {string}", typeStoredText, "When");
|
|
189
|
+
(0, registry_1.Step)("I pw fill stored {string}", typeStoredText, "When");
|
|
190
|
+
(0, registry_1.Step)("I pw slowly type {string}", typeSlowly, "When");
|
|
191
|
+
(0, registry_1.Step)("I pw slowly fill {string}", typeSlowly, "When");
|
|
192
|
+
(0, registry_1.Step)("I pw set value {string}", setInputValue, "When");
|
|
193
|
+
(0, registry_1.Step)("I pw clear", clearInput, "When");
|
|
194
|
+
(0, registry_1.Step)("I pw press {string}", pressKeyOnInput, "When");
|
|
195
|
+
(0, registry_1.Step)("I pw check", checkElement, "When");
|
|
196
|
+
(0, registry_1.Step)("I pw uncheck", uncheckElement, "When");
|
|
197
|
+
(0, registry_1.Step)("I pw check input", checkElement, "When");
|
|
198
|
+
(0, registry_1.Step)("I pw uncheck input", uncheckElement, "When");
|
|
199
|
+
(0, registry_1.Step)("I pw {string} {int}(?:st|nd|rd|th) selector {string}", checkNthElementBySelector, "When");
|
|
200
|
+
(0, registry_1.Step)("I pw select option {string}", selectOption, "When");
|
|
201
|
+
(0, registry_1.Step)("I pw submit", submitForm, "When");
|
|
202
|
+
(0, registry_1.Step)("I pw select file {string}", selectFile, "When");
|
|
203
|
+
(0, registry_1.Step)("I pw upload file {string}", uploadFile, "When");
|
|
@@ -30,10 +30,19 @@ export declare function fillElement(page: any, selectorKey: string, value: strin
|
|
|
30
30
|
*/
|
|
31
31
|
export declare function pressKeyGlobal(page: any, key: string): Promise<void>;
|
|
32
32
|
/**
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
* @example When I
|
|
36
|
-
* @param
|
|
33
|
+
* Drags one element and drops it onto another.
|
|
34
|
+
* Supports fixtures for reusable selectors.
|
|
35
|
+
* @example When I drag "droppable.draggable" to "droppable.dropZone"
|
|
36
|
+
* @param sourceKey - The selector of the element to drag.
|
|
37
|
+
* @param targetKey - The selector of the drop target element.
|
|
38
|
+
*/
|
|
39
|
+
export declare function dragElementTo(page: any, sourceKey: string, targetKey: string): Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* Continues a drag operation from a previously selected element to a target.
|
|
42
|
+
* This is meant to be used after selecting an element to drag.
|
|
43
|
+
* Supports fixtures for reusable selectors.
|
|
44
|
+
* @example And I drag to "droppable.dropZone"
|
|
45
|
+
* @param targetKey - The selector of the drop target element.
|
|
37
46
|
*/
|
|
38
|
-
export declare function
|
|
47
|
+
export declare function dragToTarget(page: any, targetKey: string): Promise<void>;
|
|
39
48
|
//# sourceMappingURL=interactions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interactions.d.ts","sourceRoot":"","sources":["../../../src/backend/actions/interactions.ts"],"names":[],"mappings":"AAWA;;;;;GAKG;AACH,wBAAsB,YAAY,CAAC,IAAI,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAMhF;AAED;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAMrF;AAED;;;;;;GAMG;AACH,wBAAsB,WAAW,CAAC,IAAI,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAM9F;AAED;;;;;;GAMG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAG1E;AAED
|
|
1
|
+
{"version":3,"file":"interactions.d.ts","sourceRoot":"","sources":["../../../src/backend/actions/interactions.ts"],"names":[],"mappings":"AAWA;;;;;GAKG;AACH,wBAAsB,YAAY,CAAC,IAAI,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAMhF;AAED;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAMrF;AAED;;;;;;GAMG;AACH,wBAAsB,WAAW,CAAC,IAAI,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAM9F;AAED;;;;;;GAMG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAG1E;AAED;;;;;;GAMG;AACH,wBAAsB,aAAa,CAAC,IAAI,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAOlG;AAED;;;;;;GAMG;AACH,wBAAsB,YAAY,CAAC,IAAI,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAW9E"}
|
|
@@ -1,10 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
36
|
exports.clickElement = clickElement;
|
|
4
37
|
exports.forceClickElement = forceClickElement;
|
|
5
38
|
exports.fillElement = fillElement;
|
|
6
39
|
exports.pressKeyGlobal = pressKeyGlobal;
|
|
7
|
-
exports.
|
|
40
|
+
exports.dragElementTo = dragElementTo;
|
|
41
|
+
exports.dragToTarget = dragToTarget;
|
|
8
42
|
//src/backend/actions/interactions.ts
|
|
9
43
|
const registry_1 = require("../../core/registry");
|
|
10
44
|
const fixtures_1 = require("../utils/fixtures");
|
|
@@ -61,20 +95,42 @@ async function pressKeyGlobal(page, key) {
|
|
|
61
95
|
console.log(`🎹 Pressed global key: "${key}"`);
|
|
62
96
|
}
|
|
63
97
|
/**
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
* @example When I
|
|
67
|
-
* @param
|
|
98
|
+
* Drags one element and drops it onto another.
|
|
99
|
+
* Supports fixtures for reusable selectors.
|
|
100
|
+
* @example When I drag "droppable.draggable" to "droppable.dropZone"
|
|
101
|
+
* @param sourceKey - The selector of the element to drag.
|
|
102
|
+
* @param targetKey - The selector of the drop target element.
|
|
68
103
|
*/
|
|
69
|
-
async function
|
|
70
|
-
|
|
71
|
-
|
|
104
|
+
async function dragElementTo(page, sourceKey, targetKey) {
|
|
105
|
+
const selectors = (0, fixtures_1.loadFixture)("selectors.json");
|
|
106
|
+
const source = (0, fixtures_1.getFixtureValue)(selectors, sourceKey);
|
|
107
|
+
const target = (0, fixtures_1.getFixtureValue)(selectors, targetKey);
|
|
108
|
+
await page.locator(source).dragTo(page.locator(target));
|
|
109
|
+
console.log(`🔀 Dragged "${source}" to "${target}"`);
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Continues a drag operation from a previously selected element to a target.
|
|
113
|
+
* This is meant to be used after selecting an element to drag.
|
|
114
|
+
* Supports fixtures for reusable selectors.
|
|
115
|
+
* @example And I drag to "droppable.dropZone"
|
|
116
|
+
* @param targetKey - The selector of the drop target element.
|
|
117
|
+
*/
|
|
118
|
+
async function dragToTarget(page, targetKey) {
|
|
119
|
+
const selectors = (0, fixtures_1.loadFixture)("selectors.json");
|
|
120
|
+
const target = (0, fixtures_1.getFixtureValue)(selectors, targetKey);
|
|
121
|
+
// Get the active element that was selected in a previous step
|
|
122
|
+
const { getActiveElement } = await Promise.resolve().then(() => __importStar(require("../utils/state")));
|
|
123
|
+
const sourceElement = getActiveElement(page);
|
|
124
|
+
// Perform the drag operation from the active element to the target
|
|
125
|
+
await sourceElement.dragTo(page.locator(target));
|
|
126
|
+
console.log(`🔀 Dragged active element to "${target}"`);
|
|
72
127
|
}
|
|
73
128
|
// ==================================================
|
|
74
129
|
// GLUE STEPS
|
|
75
130
|
// ==================================================
|
|
76
|
-
(0, registry_1.Step)("I click {string}", clickElement, "When");
|
|
77
|
-
(0, registry_1.Step)("I force click {string}", forceClickElement, "When");
|
|
78
|
-
(0, registry_1.Step)("I fill {string} with {string}", fillElement, "When");
|
|
79
|
-
(0, registry_1.Step)("I press {string}", pressKeyGlobal, "When");
|
|
80
|
-
(0, registry_1.Step)("I
|
|
131
|
+
(0, registry_1.Step)("I pw click {string}", clickElement, "When");
|
|
132
|
+
(0, registry_1.Step)("I pw force click {string}", forceClickElement, "When");
|
|
133
|
+
(0, registry_1.Step)("I pw fill {string} with {string}", fillElement, "When");
|
|
134
|
+
(0, registry_1.Step)("I pw press {string}", pressKeyGlobal, "When");
|
|
135
|
+
(0, registry_1.Step)("I pw drag {string} to {string}", dragElementTo, "When");
|
|
136
|
+
(0, registry_1.Step)("I pw drag to {string}", dragToTarget, "And");
|
|
@@ -66,9 +66,9 @@ async function releaseKey(page, key) {
|
|
|
66
66
|
// ==================================================
|
|
67
67
|
// GLUE STEPS
|
|
68
68
|
// ==================================================
|
|
69
|
-
(0, registry_1.Step)("I press key {string}", pressKey, "When");
|
|
70
|
-
(0, registry_1.Step)("I press key {string} on element", pressKeyOnElement, "When");
|
|
71
|
-
(0, registry_1.Step)("I press keys {string}", typeKeysGlobal, "When");
|
|
72
|
-
(0, registry_1.Step)("I press shortcut {string}", pressShortcut, "When");
|
|
73
|
-
(0, registry_1.Step)("I hold down key {string}", holdDownKey, "When");
|
|
74
|
-
(0, registry_1.Step)("I release key {string}", releaseKey, "When");
|
|
69
|
+
(0, registry_1.Step)("I pw press key {string}", pressKey, "When");
|
|
70
|
+
(0, registry_1.Step)("I pw press key {string} on element", pressKeyOnElement, "When");
|
|
71
|
+
(0, registry_1.Step)("I pw press keys {string}", typeKeysGlobal, "When");
|
|
72
|
+
(0, registry_1.Step)("I pw press shortcut {string}", pressShortcut, "When");
|
|
73
|
+
(0, registry_1.Step)("I pw hold down key {string}", holdDownKey, "When");
|
|
74
|
+
(0, registry_1.Step)("I pw release key {string}", releaseKey, "When");
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Pauses execution for a specified number of milliseconds.
|
|
3
|
-
* @example When I wait
|
|
3
|
+
* @example When I wait 1000 milliseconds
|
|
4
4
|
*/
|
|
5
5
|
export declare function waitMilliseconds(page: any, ms: number): Promise<void>;
|
|
6
6
|
/**
|
|
7
7
|
* Pauses execution for a specified number of seconds.
|
|
8
|
-
* @example When I wait
|
|
8
|
+
* @example When I wait 5 seconds
|
|
9
9
|
*/
|
|
10
10
|
export declare function waitSeconds(page: any, seconds: number): Promise<void>;
|
|
11
11
|
/**
|
|
@@ -68,4 +68,10 @@ export declare function setSessionStorageItem(page: any, key: string, value: str
|
|
|
68
68
|
* @example When I clear session storage
|
|
69
69
|
*/
|
|
70
70
|
export declare function clearSessionStorage(page: any): Promise<void>;
|
|
71
|
+
/**
|
|
72
|
+
* Stores the text content of the currently active element in a variable.
|
|
73
|
+
* This should be used after a step that selects an element (e.g., "I find element by text").
|
|
74
|
+
* @example When I store text as "extractedCode"
|
|
75
|
+
*/
|
|
76
|
+
export declare function storeActiveElementText(page: any, alias: string): Promise<void>;
|
|
71
77
|
//# sourceMappingURL=misc.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"misc.d.ts","sourceRoot":"","sources":["../../../src/backend/actions/misc.ts"],"names":[],"mappings":"AAUA;;;GAGG;AACH,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAI3E;AAED;;;GAGG;AACH,wBAAsB,WAAW,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAK3E;AAED;;;GAGG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CAG7D;AAED;;;GAGG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CAG7D;AAED;;;GAGG;AACH,wBAAsB,UAAU,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE1E;AAED;;;GAGG;AACH,wBAAsB,YAAY,CAAC,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CAI3D;AAED;;;GAGG;AACH,wBAAsB,WAAW,CAAC,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CAM1D;AAED;;;GAGG;AACH,wBAAsB,SAAS,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CA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,IAAI,CAAC,CAQpF"}
|
|
@@ -1,4 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
36
|
exports.waitMilliseconds = waitMilliseconds;
|
|
4
37
|
exports.waitSeconds = waitSeconds;
|
|
@@ -14,6 +47,7 @@ exports.getLocalStorageItem = getLocalStorageItem;
|
|
|
14
47
|
exports.clearLocalStorage = clearLocalStorage;
|
|
15
48
|
exports.setSessionStorageItem = setSessionStorageItem;
|
|
16
49
|
exports.clearSessionStorage = clearSessionStorage;
|
|
50
|
+
exports.storeActiveElementText = storeActiveElementText;
|
|
17
51
|
//src/backend/actions/misc.ts
|
|
18
52
|
const registry_1 = require("../../core/registry");
|
|
19
53
|
const state_1 = require("../utils/state");
|
|
@@ -22,7 +56,7 @@ const state_1 = require("../utils/state");
|
|
|
22
56
|
// ==================================================
|
|
23
57
|
/**
|
|
24
58
|
* Pauses execution for a specified number of milliseconds.
|
|
25
|
-
* @example When I wait
|
|
59
|
+
* @example When I wait 1000 milliseconds
|
|
26
60
|
*/
|
|
27
61
|
async function waitMilliseconds(page, ms) {
|
|
28
62
|
console.warn(`⚠️ Hard wait detected (${ms}ms). Consider replacing with dynamic waits.`);
|
|
@@ -31,7 +65,7 @@ async function waitMilliseconds(page, ms) {
|
|
|
31
65
|
}
|
|
32
66
|
/**
|
|
33
67
|
* Pauses execution for a specified number of seconds.
|
|
34
|
-
* @example When I wait
|
|
68
|
+
* @example When I wait 5 seconds
|
|
35
69
|
*/
|
|
36
70
|
async function waitSeconds(page, seconds) {
|
|
37
71
|
const ms = seconds * 1000;
|
|
@@ -148,20 +182,34 @@ async function clearSessionStorage(page) {
|
|
|
148
182
|
await page.evaluate(() => sessionStorage.clear());
|
|
149
183
|
console.log("📦 Cleared session storage");
|
|
150
184
|
}
|
|
185
|
+
/**
|
|
186
|
+
* Stores the text content of the currently active element in a variable.
|
|
187
|
+
* This should be used after a step that selects an element (e.g., "I find element by text").
|
|
188
|
+
* @example When I store text as "extractedCode"
|
|
189
|
+
*/
|
|
190
|
+
async function storeActiveElementText(page, alias) {
|
|
191
|
+
const { getActiveElement, setVariable } = await Promise.resolve().then(() => __importStar(require("../utils/state")));
|
|
192
|
+
const element = getActiveElement(page);
|
|
193
|
+
const text = await element.textContent();
|
|
194
|
+
const cleanText = text?.trim() || "";
|
|
195
|
+
setVariable(page, alias, cleanText);
|
|
196
|
+
console.log(`💾 Stored text "${cleanText}" as variable "@${alias}"`);
|
|
197
|
+
}
|
|
151
198
|
// ==================================================
|
|
152
199
|
// GLUE STEPS
|
|
153
200
|
// ==================================================
|
|
154
|
-
(0, registry_1.Step)("I wait
|
|
155
|
-
(0, registry_1.Step)("I wait
|
|
156
|
-
(0, registry_1.Step)("I pause", pauseExecution, "When");
|
|
157
|
-
(0, registry_1.Step)("I debug", debugExecution, "When");
|
|
158
|
-
(0, registry_1.Step)("I log {string}", logMessage, "When");
|
|
159
|
-
(0, registry_1.Step)("I focus", focusElement, "When");
|
|
160
|
-
(0, registry_1.Step)("I blur", blurElement, "When");
|
|
161
|
-
(0, registry_1.Step)("I set cookie {string} to {string}", setCookie, "When");
|
|
162
|
-
(0, registry_1.Step)("I clear all cookies", clearAllCookies, "When");
|
|
163
|
-
(0, registry_1.Step)("I set local storage item {string} to {string}", setLocalStorageItem, "When");
|
|
164
|
-
(0, registry_1.Step)("I get local storage item {string}", getLocalStorageItem, "When");
|
|
165
|
-
(0, registry_1.Step)("I clear local storage", clearLocalStorage, "When");
|
|
166
|
-
(0, registry_1.Step)("I set session storage item {string} to {string}", setSessionStorageItem, "When");
|
|
167
|
-
(0, registry_1.Step)("I clear session storage", clearSessionStorage, "When");
|
|
201
|
+
(0, registry_1.Step)("I pw wait {int} milliseconds", waitMilliseconds, "When");
|
|
202
|
+
(0, registry_1.Step)("I pw wait {int} seconds", waitSeconds, "When");
|
|
203
|
+
(0, registry_1.Step)("I pw pause", pauseExecution, "When");
|
|
204
|
+
(0, registry_1.Step)("I pw debug", debugExecution, "When");
|
|
205
|
+
(0, registry_1.Step)("I pw log {string}", logMessage, "When");
|
|
206
|
+
(0, registry_1.Step)("I pw focus", focusElement, "When");
|
|
207
|
+
(0, registry_1.Step)("I pw blur", blurElement, "When");
|
|
208
|
+
(0, registry_1.Step)("I pw set cookie {string} to {string}", setCookie, "When");
|
|
209
|
+
(0, registry_1.Step)("I pw clear all cookies", clearAllCookies, "When");
|
|
210
|
+
(0, registry_1.Step)("I pw set local storage item {string} to {string}", setLocalStorageItem, "When");
|
|
211
|
+
(0, registry_1.Step)("I pw get local storage item {string}", getLocalStorageItem, "When");
|
|
212
|
+
(0, registry_1.Step)("I pw clear local storage", clearLocalStorage, "When");
|
|
213
|
+
(0, registry_1.Step)("I pw set session storage item {string} to {string}", setSessionStorageItem, "When");
|
|
214
|
+
(0, registry_1.Step)("I pw clear session storage", clearSessionStorage, "When");
|
|
215
|
+
(0, registry_1.Step)("I pw store text as {string}", storeActiveElementText, "When");
|
|
@@ -114,10 +114,10 @@ async function grantPermission(page, permission) {
|
|
|
114
114
|
// ==================================================
|
|
115
115
|
// GLUE STEPS
|
|
116
116
|
// ==================================================
|
|
117
|
-
(0, registry_1.Step)("I tap", tapStoredElement, "When");
|
|
118
|
-
(0, registry_1.Step)("I tap element {string}", tapElementBySelector, "When");
|
|
119
|
-
(0, registry_1.Step)("I tap coordinates x:{int} y:{int}", tapCoordinates, "When");
|
|
120
|
-
(0, registry_1.Step)("I resize window to width {int} and height {int}", resizeWindow, "When");
|
|
121
|
-
(0, registry_1.Step)("I simulate device {string}", simulateDevice, "When");
|
|
122
|
-
(0, registry_1.Step)("I set geolocation to lat: {float} long: {float}", setGeolocation, "When");
|
|
123
|
-
(0, registry_1.Step)("I grant permission {string}", grantPermission, "When");
|
|
117
|
+
(0, registry_1.Step)("I pw tap", tapStoredElement, "When");
|
|
118
|
+
(0, registry_1.Step)("I pw tap element {string}", tapElementBySelector, "When");
|
|
119
|
+
(0, registry_1.Step)("I pw tap coordinates x:{int} y:{int}", tapCoordinates, "When");
|
|
120
|
+
(0, registry_1.Step)("I pw resize window to width {int} and height {int}", resizeWindow, "When");
|
|
121
|
+
(0, registry_1.Step)("I pw simulate device {string}", simulateDevice, "When");
|
|
122
|
+
(0, registry_1.Step)("I pw set geolocation to lat: {float} long: {float}", setGeolocation, "When");
|
|
123
|
+
(0, registry_1.Step)("I pw grant permission {string}", grantPermission, "When");
|
|
@@ -154,12 +154,12 @@ async function hoverNthElementBySelector(page, indexStr, selectorKey, table) {
|
|
|
154
154
|
// ==================================================
|
|
155
155
|
// GLUE STEPS
|
|
156
156
|
// ==================================================
|
|
157
|
-
(0, registry_1.Step)("I scroll {string} into view", scrollIntoView, "When");
|
|
158
|
-
(0, registry_1.Step)("I scroll {string} to position x:{int} y:{int}", scrollElementToPosition, "When");
|
|
159
|
-
(0, registry_1.Step)("I scroll to coordinates x:{int} y:{int}", scrollWindowToCoordinates, "When");
|
|
160
|
-
(0, registry_1.Step)("I scroll mouse window to position top:{int} left:{int}", scrollWindowSmoothly, "When");
|
|
161
|
-
(0, registry_1.Step)("I scroll to {string}", scrollToDirection, "When");
|
|
162
|
-
(0, registry_1.Step)("I hover over the element {string}", hoverElement, "When");
|
|
163
|
-
(0, registry_1.Step)("I move mouse to coordinates {int}, {int}", moveMouseToCoordinates, "When");
|
|
164
|
-
(0, registry_1.Step)("I hover on {int}(?:st|nd|rd|th) element {string}", hoverNthElementByText, "When");
|
|
165
|
-
(0, registry_1.Step)("I hover on {int}(?:st|nd|rd|th) selector {string}", hoverNthElementBySelector, "When");
|
|
157
|
+
(0, registry_1.Step)("I pw scroll {string} into view", scrollIntoView, "When");
|
|
158
|
+
(0, registry_1.Step)("I pw scroll {string} to position x:{int} y:{int}", scrollElementToPosition, "When");
|
|
159
|
+
(0, registry_1.Step)("I pw scroll to coordinates x:{int} y:{int}", scrollWindowToCoordinates, "When");
|
|
160
|
+
(0, registry_1.Step)("I pw scroll mouse window to position top:{int} left:{int}", scrollWindowSmoothly, "When");
|
|
161
|
+
(0, registry_1.Step)("I pw scroll to {string}", scrollToDirection, "When");
|
|
162
|
+
(0, registry_1.Step)("I pw hover over the element {string}", hoverElement, "When");
|
|
163
|
+
(0, registry_1.Step)("I pw move mouse to coordinates {int}, {int}", moveMouseToCoordinates, "When");
|
|
164
|
+
(0, registry_1.Step)("I pw hover on {int}(?:st|nd|rd|th) element {string}", hoverNthElementByText, "When");
|
|
165
|
+
(0, registry_1.Step)("I pw hover on {int}(?:st|nd|rd|th) selector {string}", hoverNthElementBySelector, "When");
|
|
@@ -64,8 +64,8 @@ async function navigateToPath(page, path) {
|
|
|
64
64
|
// ==================================================
|
|
65
65
|
// GLUE STEPS
|
|
66
66
|
// ==================================================
|
|
67
|
-
(0, registry_1.Step)("I visit {string}", visitUrl, "Given");
|
|
68
|
-
(0, registry_1.Step)("I reload the page", reloadPage, "When");
|
|
69
|
-
(0, registry_1.Step)("I go back", goBack, "When");
|
|
70
|
-
(0, registry_1.Step)("I go forward", goForward, "When");
|
|
71
|
-
(0, registry_1.Step)("I navigate to {string}", navigateToPath, "When");
|
|
67
|
+
(0, registry_1.Step)("I pw visit {string}", visitUrl, "Given");
|
|
68
|
+
(0, registry_1.Step)("I pw reload the page", reloadPage, "When");
|
|
69
|
+
(0, registry_1.Step)("I pw go back", goBack, "When");
|
|
70
|
+
(0, registry_1.Step)("I pw go forward", goForward, "When");
|
|
71
|
+
(0, registry_1.Step)("I pw navigate to {string}", navigateToPath, "When");
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Takes a screenshot of the entire page.
|
|
3
|
+
* @param page - The Playwright page object
|
|
4
|
+
* @param filename - The filename to save the screenshot as
|
|
5
|
+
* @example When I take a screenshot of the page "dashboard-view.png"
|
|
6
|
+
*/
|
|
7
|
+
export declare function takePageScreenshot(page: any, filename: string): Promise<void>;
|
|
8
|
+
/**
|
|
9
|
+
* Takes a screenshot of a specific element.
|
|
10
|
+
* @param page - The Playwright page object
|
|
11
|
+
* @param selectorKey - The selector key (can be a fixture key or raw CSS selector)
|
|
12
|
+
* @param filename - The filename to save the screenshot as
|
|
13
|
+
* @example When I take a screenshot of element "header.navbar" as "navbar.png"
|
|
14
|
+
*/
|
|
15
|
+
export declare function takeElementScreenshot(page: any, selectorKey: string, filename: string): Promise<void>;
|
|
16
|
+
/**
|
|
17
|
+
* Takes a screenshot of the viewport area.
|
|
18
|
+
* @param page - The Playwright page object
|
|
19
|
+
* @param filename - The filename to save the screenshot as
|
|
20
|
+
* @example When I take a viewport screenshot "login-area.png"
|
|
21
|
+
*/
|
|
22
|
+
export declare function takeViewportScreenshot(page: any, filename: string): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* Compares the current page with a reference image using pixel match.
|
|
25
|
+
* @param page - The Playwright page object
|
|
26
|
+
* @param currentFilename - The filename of the current page screenshot
|
|
27
|
+
* @param referenceFilename - The filename of the reference screenshot to compare with
|
|
28
|
+
* @example Then I expect page "current-view.png" to closely match "reference-view.png"
|
|
29
|
+
*/
|
|
30
|
+
export declare function expectPageToCloselyMatch(page: any, currentFilename: string, referenceFilename: string): Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* Compares a specific element with a reference image.
|
|
33
|
+
* @param page - The Playwright page object
|
|
34
|
+
* @param selectorKey - The selector key (can be a fixture key or raw CSS selector)
|
|
35
|
+
* @param currentFilename - The filename of the current element screenshot
|
|
36
|
+
* @param referenceFilename - The filename of the reference screenshot to compare with
|
|
37
|
+
* @example Then I expect element "div.content" screenshot "content-current.png" to closely match "content-reference.png"
|
|
38
|
+
*/
|
|
39
|
+
export declare function expectElementToCloselyMatch(page: any, selectorKey: string, currentFilename: string, referenceFilename: string): Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* Takes a screenshot and attaches it to the test report.
|
|
42
|
+
* @param page - The Playwright page object
|
|
43
|
+
* @param name - The name to identify the screenshot in the report
|
|
44
|
+
* @example When I capture screenshot "error-state" for the report
|
|
45
|
+
*/
|
|
46
|
+
export declare function captureScreenshotForReport(page: any, name: string): Promise<void>;
|
|
47
|
+
//# sourceMappingURL=visual.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"visual.d.ts","sourceRoot":"","sources":["../../../src/backend/actions/visual.ts"],"names":[],"mappings":"AASA;;;;;GAKG;AACH,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAGnF;AAED;;;;;;GAMG;AACH,wBAAsB,qBAAqB,CAAC,IAAI,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAO3G;AAED;;;;;GAKG;AACH,wBAAsB,sBAAsB,CAAC,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAGvF;AAED;;;;;;GAMG;AACH,wBAAsB,wBAAwB,CAAC,IAAI,EAAE,GAAG,EAAE,eAAe,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAK3H;AAED;;;;;;;GAOG;AACH,wBAAsB,2BAA2B,CAAC,IAAI,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAOnJ;AAED;;;;;GAKG;AACH,wBAAsB,0BAA0B,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAIvF"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.takePageScreenshot = takePageScreenshot;
|
|
4
|
+
exports.takeElementScreenshot = takeElementScreenshot;
|
|
5
|
+
exports.takeViewportScreenshot = takeViewportScreenshot;
|
|
6
|
+
exports.expectPageToCloselyMatch = expectPageToCloselyMatch;
|
|
7
|
+
exports.expectElementToCloselyMatch = expectElementToCloselyMatch;
|
|
8
|
+
exports.captureScreenshotForReport = captureScreenshotForReport;
|
|
9
|
+
//src/backend/actions/visual.ts
|
|
10
|
+
const test_1 = require("@playwright/test");
|
|
11
|
+
const registry_1 = require("../../core/registry");
|
|
12
|
+
const fixtures_1 = require("../utils/fixtures");
|
|
13
|
+
// ==================================================
|
|
14
|
+
// CORE FUNCTIONS
|
|
15
|
+
// ==================================================
|
|
16
|
+
/**
|
|
17
|
+
* Takes a screenshot of the entire page.
|
|
18
|
+
* @param page - The Playwright page object
|
|
19
|
+
* @param filename - The filename to save the screenshot as
|
|
20
|
+
* @example When I take a screenshot of the page "dashboard-view.png"
|
|
21
|
+
*/
|
|
22
|
+
async function takePageScreenshot(page, filename) {
|
|
23
|
+
await page.screenshot({ path: `screenshots/${filename}`, fullPage: true });
|
|
24
|
+
console.log(`📷 Saved page screenshot: screenshots/${filename}`);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Takes a screenshot of a specific element.
|
|
28
|
+
* @param page - The Playwright page object
|
|
29
|
+
* @param selectorKey - The selector key (can be a fixture key or raw CSS selector)
|
|
30
|
+
* @param filename - The filename to save the screenshot as
|
|
31
|
+
* @example When I take a screenshot of element "header.navbar" as "navbar.png"
|
|
32
|
+
*/
|
|
33
|
+
async function takeElementScreenshot(page, selectorKey, filename) {
|
|
34
|
+
const selectors = (0, fixtures_1.loadFixture)("selectors.json");
|
|
35
|
+
const selector = (0, fixtures_1.getFixtureValue)(selectors, selectorKey);
|
|
36
|
+
const element = page.locator(selector);
|
|
37
|
+
await element.screenshot({ path: `screenshots/${filename}` });
|
|
38
|
+
console.log(`📷 Saved element "${selector}" screenshot: screenshots/${filename}`);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Takes a screenshot of the viewport area.
|
|
42
|
+
* @param page - The Playwright page object
|
|
43
|
+
* @param filename - The filename to save the screenshot as
|
|
44
|
+
* @example When I take a viewport screenshot "login-area.png"
|
|
45
|
+
*/
|
|
46
|
+
async function takeViewportScreenshot(page, filename) {
|
|
47
|
+
await page.screenshot({ path: `screenshots/${filename}` });
|
|
48
|
+
console.log(`📷 Saved viewport screenshot: screenshots/${filename}`);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Compares the current page with a reference image using pixel match.
|
|
52
|
+
* @param page - The Playwright page object
|
|
53
|
+
* @param currentFilename - The filename of the current page screenshot
|
|
54
|
+
* @param referenceFilename - The filename of the reference screenshot to compare with
|
|
55
|
+
* @example Then I expect page "current-view.png" to closely match "reference-view.png"
|
|
56
|
+
*/
|
|
57
|
+
async function expectPageToCloselyMatch(page, currentFilename, referenceFilename) {
|
|
58
|
+
// Playwright's screenshot comparison is already pixel-perfect by default
|
|
59
|
+
// This function provides semantic meaning for close matching
|
|
60
|
+
await (0, test_1.expect)(page).toHaveScreenshot(currentFilename);
|
|
61
|
+
console.log(`🔍 Page "${currentFilename}" compared with reference "${referenceFilename}"`);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Compares a specific element with a reference image.
|
|
65
|
+
* @param page - The Playwright page object
|
|
66
|
+
* @param selectorKey - The selector key (can be a fixture key or raw CSS selector)
|
|
67
|
+
* @param currentFilename - The filename of the current element screenshot
|
|
68
|
+
* @param referenceFilename - The filename of the reference screenshot to compare with
|
|
69
|
+
* @example Then I expect element "div.content" screenshot "content-current.png" to closely match "content-reference.png"
|
|
70
|
+
*/
|
|
71
|
+
async function expectElementToCloselyMatch(page, selectorKey, currentFilename, referenceFilename) {
|
|
72
|
+
const selectors = (0, fixtures_1.loadFixture)("selectors.json");
|
|
73
|
+
const selector = (0, fixtures_1.getFixtureValue)(selectors, selectorKey);
|
|
74
|
+
const element = page.locator(selector);
|
|
75
|
+
await (0, test_1.expect)(element).toHaveScreenshot(currentFilename);
|
|
76
|
+
console.log(`🔍 Element "${selector}" screenshot "${currentFilename}" compared with reference "${referenceFilename}"`);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Takes a screenshot and attaches it to the test report.
|
|
80
|
+
* @param page - The Playwright page object
|
|
81
|
+
* @param name - The name to identify the screenshot in the report
|
|
82
|
+
* @example When I capture screenshot "error-state" for the report
|
|
83
|
+
*/
|
|
84
|
+
async function captureScreenshotForReport(page, name) {
|
|
85
|
+
await page.screenshot();
|
|
86
|
+
// This would typically be attached to the test report
|
|
87
|
+
console.log(`📎 Captured screenshot "${name}" for test report`);
|
|
88
|
+
}
|
|
89
|
+
// ==================================================
|
|
90
|
+
// GLUE STEPS
|
|
91
|
+
// ==================================================
|
|
92
|
+
(0, registry_1.Step)("I pw take a screenshot of the page {string}", takePageScreenshot, "When");
|
|
93
|
+
(0, registry_1.Step)("I pw take a screenshot of element {string} as {string}", takeElementScreenshot, "When");
|
|
94
|
+
(0, registry_1.Step)("I pw take a viewport screenshot {string}", takeViewportScreenshot, "When");
|
|
95
|
+
(0, registry_1.Step)("I pw expect page {string} to closely match {string}", expectPageToCloselyMatch, "Then");
|
|
96
|
+
(0, registry_1.Step)("I pw expect element {string} screenshot {string} to closely match {string}", expectElementToCloselyMatch, "Then");
|
|
97
|
+
(0, registry_1.Step)("I pw capture screenshot {string} for the report", captureScreenshotForReport, "When");
|
|
@@ -15,6 +15,12 @@ export declare function waitForLoadState(page: any, state: string): Promise<void
|
|
|
15
15
|
* @example When I wait for element to be visible
|
|
16
16
|
*/
|
|
17
17
|
export declare function waitForElementVisible(page: any): Promise<void>;
|
|
18
|
+
/**
|
|
19
|
+
* Explicitly waits for a specific element to become visible.
|
|
20
|
+
* Useful for ensuring animations complete or modals appear before proceeding.
|
|
21
|
+
* @example When I wait for "#modal" to be visible
|
|
22
|
+
*/
|
|
23
|
+
export declare function waitForElementVisibleBySelector(page: any, selectorKey: string): Promise<void>;
|
|
18
24
|
/**
|
|
19
25
|
* Explicitly waits for the currently stored (active) element to become hidden or detached from the DOM.
|
|
20
26
|
* Useful for verifying that loading spinners have disappeared.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"waits.d.ts","sourceRoot":"","sources":["../../../src/backend/actions/waits.ts"],"names":[],"mappings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AE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAMpF"}
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.waitForNetworkIdle = waitForNetworkIdle;
|
|
4
4
|
exports.waitForLoadState = waitForLoadState;
|
|
5
5
|
exports.waitForElementVisible = waitForElementVisible;
|
|
6
|
+
exports.waitForElementVisibleBySelector = waitForElementVisibleBySelector;
|
|
6
7
|
exports.waitForElementHidden = waitForElementHidden;
|
|
7
8
|
exports.waitForUrlContain = waitForUrlContain;
|
|
8
9
|
const registry_1 = require("../../core/registry");
|
|
@@ -42,6 +43,17 @@ async function waitForElementVisible(page) {
|
|
|
42
43
|
await element.waitFor({ state: "visible" });
|
|
43
44
|
console.log("⏳ Element is now visible");
|
|
44
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* Explicitly waits for a specific element to become visible.
|
|
48
|
+
* Useful for ensuring animations complete or modals appear before proceeding.
|
|
49
|
+
* @example When I wait for "#modal" to be visible
|
|
50
|
+
*/
|
|
51
|
+
async function waitForElementVisibleBySelector(page, selectorKey) {
|
|
52
|
+
const selectors = (0, fixtures_1.loadFixture)("selectors.json");
|
|
53
|
+
const selector = (0, fixtures_1.getFixtureValue)(selectors, selectorKey);
|
|
54
|
+
await page.locator(selector).waitFor({ state: "visible" });
|
|
55
|
+
console.log(`⏳ Element "${selector}" is now visible`);
|
|
56
|
+
}
|
|
45
57
|
/**
|
|
46
58
|
* Explicitly waits for the currently stored (active) element to become hidden or detached from the DOM.
|
|
47
59
|
* Useful for verifying that loading spinners have disappeared.
|
|
@@ -66,8 +78,9 @@ async function waitForUrlContain(page, urlPartKey) {
|
|
|
66
78
|
// ==================================================
|
|
67
79
|
// GLUE STEPS
|
|
68
80
|
// ==================================================
|
|
69
|
-
(0, registry_1.Step)("I wait for network idle", waitForNetworkIdle, "When");
|
|
70
|
-
(0, registry_1.Step)("I wait for load state {string}", waitForLoadState, "When");
|
|
71
|
-
(0, registry_1.Step)("I wait for element to be visible", waitForElementVisible, "When");
|
|
72
|
-
(0, registry_1.Step)("I wait for
|
|
73
|
-
(0, registry_1.Step)("I wait for
|
|
81
|
+
(0, registry_1.Step)("I pw wait for network idle", waitForNetworkIdle, "When");
|
|
82
|
+
(0, registry_1.Step)("I pw wait for load state {string}", waitForLoadState, "When");
|
|
83
|
+
(0, registry_1.Step)("I pw wait for element to be visible", waitForElementVisible, "When");
|
|
84
|
+
(0, registry_1.Step)("I pw wait for {string} to be visible", waitForElementVisibleBySelector, "When");
|
|
85
|
+
(0, registry_1.Step)("I pw wait for element to be hidden", waitForElementHidden, "When");
|
|
86
|
+
(0, registry_1.Step)("I pw wait for URL to contain {string}", waitForUrlContain, "When");
|
|
@@ -58,6 +58,6 @@ async function expectResponseProperty(page, jsonPathKey, valueKey) {
|
|
|
58
58
|
// ==================================================
|
|
59
59
|
// GLUE STEPS
|
|
60
60
|
// ==================================================
|
|
61
|
-
(0, registry_1.Step)("I expect the response status to be {int}", expectResponseStatus, "Then");
|
|
62
|
-
(0, registry_1.Step)("I expect the response body to contain {string}", expectResponseBodyContain, "Then");
|
|
63
|
-
(0, registry_1.Step)("I expect the response property {string} to be {string}", expectResponseProperty, "Then");
|
|
61
|
+
(0, registry_1.Step)("I pw expect the response status to be {int}", expectResponseStatus, "Then");
|
|
62
|
+
(0, registry_1.Step)("I pw expect the response body to contain {string}", expectResponseBodyContain, "Then");
|
|
63
|
+
(0, registry_1.Step)("I pw expect the response property {string} to be {string}", expectResponseProperty, "Then");
|