playwright-cucumber-ts-steps 1.3.1 → 1.3.3
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/README.md +358 -671
- package/dist/backend/actions/click.d.ts +29 -29
- package/dist/backend/actions/click.js +59 -59
- package/dist/backend/actions/form.d.ts +2 -2
- package/dist/backend/actions/form.js +4 -4
- package/dist/backend/actions/formTable.d.ts +1 -1
- package/dist/backend/actions/formTable.js +2 -2
- package/dist/backend/actions/frames.d.ts +3 -3
- package/dist/backend/actions/frames.js +6 -6
- package/dist/backend/actions/inputs.d.ts +14 -14
- package/dist/backend/actions/inputs.js +32 -32
- package/dist/backend/actions/interactions.d.ts +7 -7
- package/dist/backend/actions/interactions.js +13 -13
- package/dist/backend/actions/keyboard.d.ts +6 -6
- package/dist/backend/actions/keyboard.js +12 -12
- package/dist/backend/actions/misc.d.ts +15 -15
- package/dist/backend/actions/misc.js +30 -30
- package/dist/backend/actions/mobile.d.ts +7 -7
- package/dist/backend/actions/mobile.js +14 -14
- package/dist/backend/actions/mouse.d.ts +9 -9
- package/dist/backend/actions/mouse.js +18 -18
- package/dist/backend/actions/navigation.d.ts +5 -5
- package/dist/backend/actions/navigation.js +10 -10
- package/dist/backend/actions/visual.d.ts +6 -6
- package/dist/backend/actions/visual.js +13 -13
- package/dist/backend/actions/waits.d.ts +6 -6
- package/dist/backend/actions/waits.js +12 -12
- package/dist/backend/api/assertions.d.ts +3 -3
- package/dist/backend/api/assertions.js +6 -6
- package/dist/backend/api/mock.d.ts +3 -3
- package/dist/backend/api/mock.js +6 -6
- package/dist/backend/api/network.d.ts +6 -6
- package/dist/backend/api/network.js +12 -12
- package/dist/backend/api/requests.d.ts +4 -4
- package/dist/backend/api/requests.js +8 -8
- package/dist/backend/assertions/document.d.ts +10 -10
- package/dist/backend/assertions/document.js +20 -20
- package/dist/backend/assertions/elements.d.ts +28 -28
- package/dist/backend/assertions/elements.js +56 -56
- package/dist/backend/assertions/expectVisible.d.ts +1 -1
- package/dist/backend/assertions/expectVisible.js +2 -2
- package/dist/backend/assertions/forms.d.ts +7 -7
- package/dist/backend/assertions/forms.js +14 -14
- package/dist/backend/assertions/pageState.d.ts +4 -4
- package/dist/backend/assertions/pageState.js +8 -8
- package/dist/backend/assertions/storage.d.ts +11 -11
- package/dist/backend/assertions/storage.js +22 -22
- package/dist/backend/assertions/text.d.ts +17 -17
- package/dist/backend/assertions/text.js +34 -34
- package/dist/backend/assertions/visibility.d.ts +15 -15
- package/dist/backend/assertions/visibility.js +30 -30
- package/dist/backend/auth/index.d.ts +2 -2
- package/dist/backend/auth/index.js +4 -4
- package/dist/backend/db/steps.d.ts +10 -10
- package/dist/backend/db/steps.d.ts.map +1 -1
- package/dist/backend/db/steps.js +19 -19
- package/dist/backend/elements/alerts.d.ts +3 -3
- package/dist/backend/elements/alerts.js +6 -6
- package/dist/backend/elements/find.d.ts +15 -15
- package/dist/backend/elements/find.js +41 -41
- package/dist/backend/elements/forms.d.ts +4 -4
- package/dist/backend/elements/forms.js +8 -8
- package/dist/backend/elements/frames.d.ts +3 -3
- package/dist/backend/elements/frames.js +6 -6
- package/dist/backend/utils/fixtures.d.ts +22 -0
- package/dist/backend/utils/fixtures.d.ts.map +1 -1
- package/dist/backend/utils/fixtures.js +76 -2
- package/dist/backend/utils/resolver.js +1 -1
- package/dist/component/runner.d.ts +1 -1
- package/dist/component/runner.d.ts.map +1 -1
- package/dist/component/runner.js +38 -5
- package/dist/core/runner.js +3 -3
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/metadata.json +270 -270
- package/package.json +3 -2
|
@@ -56,7 +56,7 @@ const state_1 = require("../utils/state");
|
|
|
56
56
|
// ==================================================
|
|
57
57
|
/**
|
|
58
58
|
* Pauses execution for a specified number of milliseconds.
|
|
59
|
-
* @example When I wait 1000 milliseconds
|
|
59
|
+
* @example When I pw wait 1000 milliseconds
|
|
60
60
|
*/
|
|
61
61
|
async function waitMilliseconds(page, ms) {
|
|
62
62
|
console.warn(`⚠️ Hard wait detected (${ms}ms). Consider replacing with dynamic waits.`);
|
|
@@ -65,7 +65,7 @@ async function waitMilliseconds(page, ms) {
|
|
|
65
65
|
}
|
|
66
66
|
/**
|
|
67
67
|
* Pauses execution for a specified number of seconds.
|
|
68
|
-
* @example When I wait 5 seconds
|
|
68
|
+
* @example When I pw wait 5 seconds
|
|
69
69
|
*/
|
|
70
70
|
async function waitSeconds(page, seconds) {
|
|
71
71
|
const ms = seconds * 1000;
|
|
@@ -75,7 +75,7 @@ async function waitSeconds(page, seconds) {
|
|
|
75
75
|
}
|
|
76
76
|
/**
|
|
77
77
|
* Pauses the test execution and opens the Playwright Inspector.
|
|
78
|
-
* @example When I pause
|
|
78
|
+
* @example When I pw pause
|
|
79
79
|
*/
|
|
80
80
|
async function pauseExecution(page) {
|
|
81
81
|
console.log("⏸️ Pausing test execution...");
|
|
@@ -83,7 +83,7 @@ async function pauseExecution(page) {
|
|
|
83
83
|
}
|
|
84
84
|
/**
|
|
85
85
|
* Alias for pauseExecution. Pauses execution for debugging.
|
|
86
|
-
* @example When I debug
|
|
86
|
+
* @example When I pw debug
|
|
87
87
|
*/
|
|
88
88
|
async function debugExecution(page) {
|
|
89
89
|
console.log("🐞 Debugging...");
|
|
@@ -91,14 +91,14 @@ async function debugExecution(page) {
|
|
|
91
91
|
}
|
|
92
92
|
/**
|
|
93
93
|
* Prints a custom message to the console logs.
|
|
94
|
-
* @example When I log "Starting Login Flow"
|
|
94
|
+
* @example When I pw log "Starting Login Flow"
|
|
95
95
|
*/
|
|
96
96
|
async function logMessage(page, message) {
|
|
97
97
|
console.log(`📝 LOG: ${message}`);
|
|
98
98
|
}
|
|
99
99
|
/**
|
|
100
100
|
* Focuses on the currently stored (active) element.
|
|
101
|
-
* @example When I focus
|
|
101
|
+
* @example When I pw focus
|
|
102
102
|
*/
|
|
103
103
|
async function focusElement(page) {
|
|
104
104
|
const element = (0, state_1.getActiveElement)(page);
|
|
@@ -107,7 +107,7 @@ async function focusElement(page) {
|
|
|
107
107
|
}
|
|
108
108
|
/**
|
|
109
109
|
* Blurs (removes focus from) the currently stored element.
|
|
110
|
-
* @example When I blur
|
|
110
|
+
* @example When I pw blur
|
|
111
111
|
*/
|
|
112
112
|
async function blurElement(page) {
|
|
113
113
|
const element = (0, state_1.getActiveElement)(page);
|
|
@@ -119,7 +119,7 @@ async function blurElement(page) {
|
|
|
119
119
|
}
|
|
120
120
|
/**
|
|
121
121
|
* Sets a cookie for the current context/URL.
|
|
122
|
-
* @example When I set cookie "session_id" to "12345ABC"
|
|
122
|
+
* @example When I pw set cookie "session_id" to "12345ABC"
|
|
123
123
|
*/
|
|
124
124
|
async function setCookie(page, name, value) {
|
|
125
125
|
const context = page.context();
|
|
@@ -129,7 +129,7 @@ async function setCookie(page, name, value) {
|
|
|
129
129
|
}
|
|
130
130
|
/**
|
|
131
131
|
* Clears all cookies for the current browser context.
|
|
132
|
-
* @example When I clear all cookies
|
|
132
|
+
* @example When I pw clear all cookies
|
|
133
133
|
*/
|
|
134
134
|
async function clearAllCookies(page) {
|
|
135
135
|
const context = page.context();
|
|
@@ -138,7 +138,7 @@ async function clearAllCookies(page) {
|
|
|
138
138
|
}
|
|
139
139
|
/**
|
|
140
140
|
* Sets an item in Local Storage.
|
|
141
|
-
* @example When I set local storage item "theme" to "dark"
|
|
141
|
+
* @example When I pw set local storage item "theme" to "dark"
|
|
142
142
|
*/
|
|
143
143
|
async function setLocalStorageItem(page, key, value) {
|
|
144
144
|
await page.evaluate((args) => localStorage.setItem(args.k, args.v), {
|
|
@@ -149,7 +149,7 @@ async function setLocalStorageItem(page, key, value) {
|
|
|
149
149
|
}
|
|
150
150
|
/**
|
|
151
151
|
* Retrieves a Local Storage item and logs it to the console.
|
|
152
|
-
* @example When I get local storage item "authToken"
|
|
152
|
+
* @example When I pw get local storage item "authToken"
|
|
153
153
|
*/
|
|
154
154
|
async function getLocalStorageItem(page, key) {
|
|
155
155
|
const value = await page.evaluate((k) => localStorage.getItem(k), key);
|
|
@@ -157,7 +157,7 @@ async function getLocalStorageItem(page, key) {
|
|
|
157
157
|
}
|
|
158
158
|
/**
|
|
159
159
|
* Clears all data from Local Storage.
|
|
160
|
-
* @example When I clear local storage
|
|
160
|
+
* @example When I pw clear local storage
|
|
161
161
|
*/
|
|
162
162
|
async function clearLocalStorage(page) {
|
|
163
163
|
await page.evaluate(() => localStorage.clear());
|
|
@@ -165,7 +165,7 @@ async function clearLocalStorage(page) {
|
|
|
165
165
|
}
|
|
166
166
|
/**
|
|
167
167
|
* Sets an item in Session Storage.
|
|
168
|
-
* @example When I set session storage item "user_role" to "admin"
|
|
168
|
+
* @example When I pw set session storage item "user_role" to "admin"
|
|
169
169
|
*/
|
|
170
170
|
async function setSessionStorageItem(page, key, value) {
|
|
171
171
|
await page.evaluate((args) => sessionStorage.setItem(args.k, args.v), {
|
|
@@ -176,7 +176,7 @@ async function setSessionStorageItem(page, key, value) {
|
|
|
176
176
|
}
|
|
177
177
|
/**
|
|
178
178
|
* Clears all data from Session Storage.
|
|
179
|
-
* @example When I clear session storage
|
|
179
|
+
* @example When I pw clear session storage
|
|
180
180
|
*/
|
|
181
181
|
async function clearSessionStorage(page) {
|
|
182
182
|
await page.evaluate(() => sessionStorage.clear());
|
|
@@ -185,7 +185,7 @@ async function clearSessionStorage(page) {
|
|
|
185
185
|
/**
|
|
186
186
|
* Stores the text content of the currently active element in a variable.
|
|
187
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"
|
|
188
|
+
* @example When I pw store text as "extractedCode"
|
|
189
189
|
*/
|
|
190
190
|
async function storeActiveElementText(page, alias) {
|
|
191
191
|
const { getActiveElement, setVariable } = await Promise.resolve().then(() => __importStar(require("../utils/state")));
|
|
@@ -198,18 +198,18 @@ async function storeActiveElementText(page, alias) {
|
|
|
198
198
|
// ==================================================
|
|
199
199
|
// GLUE STEPS
|
|
200
200
|
// ==================================================
|
|
201
|
-
(0, registry_1.Step)("I wait {int} milliseconds", waitMilliseconds, "When");
|
|
202
|
-
(0, registry_1.Step)("I wait {int} seconds", waitSeconds, "When");
|
|
203
|
-
(0, registry_1.Step)("I pause", pauseExecution, "When");
|
|
204
|
-
(0, registry_1.Step)("I debug", debugExecution, "When");
|
|
205
|
-
(0, registry_1.Step)("I log {string}", logMessage, "When");
|
|
206
|
-
(0, registry_1.Step)("I focus", focusElement, "When");
|
|
207
|
-
(0, registry_1.Step)("I blur", blurElement, "When");
|
|
208
|
-
(0, registry_1.Step)("I set cookie {string} to {string}", setCookie, "When");
|
|
209
|
-
(0, registry_1.Step)("I clear all cookies", clearAllCookies, "When");
|
|
210
|
-
(0, registry_1.Step)("I set local storage item {string} to {string}", setLocalStorageItem, "When");
|
|
211
|
-
(0, registry_1.Step)("I get local storage item {string}", getLocalStorageItem, "When");
|
|
212
|
-
(0, registry_1.Step)("I clear local storage", clearLocalStorage, "When");
|
|
213
|
-
(0, registry_1.Step)("I set session storage item {string} to {string}", setSessionStorageItem, "When");
|
|
214
|
-
(0, registry_1.Step)("I clear session storage", clearSessionStorage, "When");
|
|
215
|
-
(0, registry_1.Step)("I store text as {string}", storeActiveElementText, "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");
|
|
@@ -1,38 +1,38 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Taps on the currently stored (active) element.
|
|
3
3
|
* Uses a "Hybrid Tap" strategy: tries to tap, falls back to click if touch is unsupported.
|
|
4
|
-
* @example When I tap
|
|
4
|
+
* @example When I pw tap
|
|
5
5
|
*/
|
|
6
6
|
export declare function tapStoredElement(page: any): Promise<void>;
|
|
7
7
|
/**
|
|
8
8
|
* Finds an element by selector and taps it.
|
|
9
9
|
* Supports fixtures for reusable selectors.
|
|
10
|
-
* @example When I tap element "menu.toggleButton"
|
|
10
|
+
* @example When I pw tap element "menu.toggleButton"
|
|
11
11
|
*/
|
|
12
12
|
export declare function tapElementBySelector(page: any, selectorKey: string): Promise<void>;
|
|
13
13
|
/**
|
|
14
14
|
* Taps at specific X, Y coordinates on the screen.
|
|
15
|
-
* @example When I tap coordinates x:50 y:200
|
|
15
|
+
* @example When I pw tap coordinates x:50 y:200
|
|
16
16
|
*/
|
|
17
17
|
export declare function tapCoordinates(page: any, x: number, y: number): Promise<void>;
|
|
18
18
|
/**
|
|
19
19
|
* Resizes the browser window/viewport to specific dimensions.
|
|
20
|
-
* @example When I resize window to width 375 and height 812
|
|
20
|
+
* @example When I pw resize window to width 375 and height 812
|
|
21
21
|
*/
|
|
22
22
|
export declare function resizeWindow(page: any, width: number, height: number): Promise<void>;
|
|
23
23
|
/**
|
|
24
24
|
* Resizes the viewport to match a specific device preset.
|
|
25
|
-
* @example When I simulate device "iPhone 12"
|
|
25
|
+
* @example When I pw simulate device "iPhone 12"
|
|
26
26
|
*/
|
|
27
27
|
export declare function simulateDevice(page: any, deviceName: string): Promise<void>;
|
|
28
28
|
/**
|
|
29
29
|
* Sets the geolocation coordinates for the browser context and auto-grants permission.
|
|
30
|
-
* @example When I set geolocation to lat: 37.7749 long: -122.4194
|
|
30
|
+
* @example When I pw set geolocation to lat: 37.7749 long: -122.4194
|
|
31
31
|
*/
|
|
32
32
|
export declare function setGeolocation(page: any, lat: number, long: number): Promise<void>;
|
|
33
33
|
/**
|
|
34
34
|
* Grants a specific browser permission to the current context.
|
|
35
|
-
* @example When I grant permission "notifications"
|
|
35
|
+
* @example When I pw grant permission "notifications"
|
|
36
36
|
*/
|
|
37
37
|
export declare function grantPermission(page: any, permission: string): Promise<void>;
|
|
38
38
|
//# sourceMappingURL=mobile.d.ts.map
|
|
@@ -39,7 +39,7 @@ async function safeTap(target) {
|
|
|
39
39
|
/**
|
|
40
40
|
* Taps on the currently stored (active) element.
|
|
41
41
|
* Uses a "Hybrid Tap" strategy: tries to tap, falls back to click if touch is unsupported.
|
|
42
|
-
* @example When I tap
|
|
42
|
+
* @example When I pw tap
|
|
43
43
|
*/
|
|
44
44
|
async function tapStoredElement(page) {
|
|
45
45
|
const element = (0, state_1.getActiveElement)(page);
|
|
@@ -49,7 +49,7 @@ async function tapStoredElement(page) {
|
|
|
49
49
|
/**
|
|
50
50
|
* Finds an element by selector and taps it.
|
|
51
51
|
* Supports fixtures for reusable selectors.
|
|
52
|
-
* @example When I tap element "menu.toggleButton"
|
|
52
|
+
* @example When I pw tap element "menu.toggleButton"
|
|
53
53
|
*/
|
|
54
54
|
async function tapElementBySelector(page, selectorKey) {
|
|
55
55
|
const selectors = (0, fixtures_1.loadFixture)("selectors.json");
|
|
@@ -60,7 +60,7 @@ async function tapElementBySelector(page, selectorKey) {
|
|
|
60
60
|
}
|
|
61
61
|
/**
|
|
62
62
|
* Taps at specific X, Y coordinates on the screen.
|
|
63
|
-
* @example When I tap coordinates x:50 y:200
|
|
63
|
+
* @example When I pw tap coordinates x:50 y:200
|
|
64
64
|
*/
|
|
65
65
|
async function tapCoordinates(page, x, y) {
|
|
66
66
|
await page.mouse.click(x, y);
|
|
@@ -68,7 +68,7 @@ async function tapCoordinates(page, x, y) {
|
|
|
68
68
|
}
|
|
69
69
|
/**
|
|
70
70
|
* Resizes the browser window/viewport to specific dimensions.
|
|
71
|
-
* @example When I resize window to width 375 and height 812
|
|
71
|
+
* @example When I pw resize window to width 375 and height 812
|
|
72
72
|
*/
|
|
73
73
|
async function resizeWindow(page, width, height) {
|
|
74
74
|
await page.setViewportSize({ width, height });
|
|
@@ -76,7 +76,7 @@ async function resizeWindow(page, width, height) {
|
|
|
76
76
|
}
|
|
77
77
|
/**
|
|
78
78
|
* Resizes the viewport to match a specific device preset.
|
|
79
|
-
* @example When I simulate device "iPhone 12"
|
|
79
|
+
* @example When I pw simulate device "iPhone 12"
|
|
80
80
|
*/
|
|
81
81
|
async function simulateDevice(page, deviceName) {
|
|
82
82
|
const devices = {
|
|
@@ -96,7 +96,7 @@ async function simulateDevice(page, deviceName) {
|
|
|
96
96
|
}
|
|
97
97
|
/**
|
|
98
98
|
* Sets the geolocation coordinates for the browser context and auto-grants permission.
|
|
99
|
-
* @example When I set geolocation to lat: 37.7749 long: -122.4194
|
|
99
|
+
* @example When I pw set geolocation to lat: 37.7749 long: -122.4194
|
|
100
100
|
*/
|
|
101
101
|
async function setGeolocation(page, lat, long) {
|
|
102
102
|
await page.context().setGeolocation({ latitude: lat, longitude: long });
|
|
@@ -105,7 +105,7 @@ async function setGeolocation(page, lat, long) {
|
|
|
105
105
|
}
|
|
106
106
|
/**
|
|
107
107
|
* Grants a specific browser permission to the current context.
|
|
108
|
-
* @example When I grant permission "notifications"
|
|
108
|
+
* @example When I pw grant permission "notifications"
|
|
109
109
|
*/
|
|
110
110
|
async function grantPermission(page, permission) {
|
|
111
111
|
await page.context().grantPermissions([permission]);
|
|
@@ -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");
|
|
@@ -1,53 +1,53 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Scrolls a specific element into the visible viewport.
|
|
3
3
|
* Supports fixtures for reusable selectors.
|
|
4
|
-
* @example When I scroll "footer.footerSection" into view
|
|
4
|
+
* @example When I pw scroll "footer.footerSection" into view
|
|
5
5
|
*/
|
|
6
6
|
export declare function scrollIntoView(page: any, selectorKey: string): Promise<void>;
|
|
7
7
|
/**
|
|
8
8
|
* Scrolls the internal content of a specific element (overflow container) to X, Y coordinates.
|
|
9
9
|
* Supports fixtures for reusable selectors.
|
|
10
|
-
* @example When I scroll "chat.chatBox" to position x:0 y:500
|
|
10
|
+
* @example When I pw scroll "chat.chatBox" to position x:0 y:500
|
|
11
11
|
*/
|
|
12
12
|
export declare function scrollElementToPosition(page: any, selectorKey: string, x: number, y: number): Promise<void>;
|
|
13
13
|
/**
|
|
14
14
|
* Scrolls the entire main browser window to specific X, Y coordinates immediately.
|
|
15
|
-
* @example When I scroll to coordinates x:0 y:0
|
|
15
|
+
* @example When I pw scroll to coordinates x:0 y:0
|
|
16
16
|
*/
|
|
17
17
|
export declare function scrollWindowToCoordinates(page: any, x: number, y: number): Promise<void>;
|
|
18
18
|
/**
|
|
19
19
|
* Scrolls the entire main browser window smoothly to specific coordinates.
|
|
20
|
-
* @example When I scroll mouse window to position top:0 left:0
|
|
20
|
+
* @example When I pw scroll mouse window to position top:0 left:0
|
|
21
21
|
*/
|
|
22
22
|
export declare function scrollWindowSmoothly(page: any, top: number, left: number): Promise<void>;
|
|
23
23
|
/**
|
|
24
24
|
* Scrolls the window to a general direction edge (top, bottom, left, right).
|
|
25
25
|
* Includes a short wait for smooth scrolling animation to complete.
|
|
26
|
-
* @example When I scroll to "bottom"
|
|
26
|
+
* @example When I pw scroll to "bottom"
|
|
27
27
|
*/
|
|
28
28
|
export declare function scrollToDirection(page: any, direction: string): Promise<void>;
|
|
29
29
|
/**
|
|
30
30
|
* Simulates a mouse hover over an element.
|
|
31
31
|
* Sets the hovered element as the "Active Element" for subsequent steps.
|
|
32
32
|
* Supports fixtures for reusable selectors.
|
|
33
|
-
* @example When I hover over the element "dropdown.toggleButton"
|
|
33
|
+
* @example When I pw hover over the element "dropdown.toggleButton"
|
|
34
34
|
*/
|
|
35
35
|
export declare function hoverElement(page: any, selectorKey: string): Promise<void>;
|
|
36
36
|
/**
|
|
37
37
|
* Moves the mouse cursor to specific absolute screen coordinates.
|
|
38
38
|
* Useful for canvas interactions or testing mouse tracking.
|
|
39
|
-
* @example When I move mouse to coordinates 100, 200
|
|
39
|
+
* @example When I pw move mouse to coordinates 100, 200
|
|
40
40
|
*/
|
|
41
41
|
export declare function moveMouseToCoordinates(page: any, x: number, y: number): Promise<void>;
|
|
42
42
|
/**
|
|
43
43
|
* Hovers over the Nth element containing the specified text.
|
|
44
|
-
* @example When I hover on 1st element "Profile"
|
|
44
|
+
* @example When I pw hover on 1st element "Profile"
|
|
45
45
|
*/
|
|
46
46
|
export declare function hoverNthElementByText(page: any, indexStr: string, text: string, table?: any): Promise<void>;
|
|
47
47
|
/**
|
|
48
48
|
* Hovers over the Nth element matching a CSS or XPath selector.
|
|
49
49
|
* Supports fixtures for reusable selectors.
|
|
50
|
-
* @example When I hover on 1st selector "user.avatar"
|
|
50
|
+
* @example When I pw hover on 1st selector "user.avatar"
|
|
51
51
|
*/
|
|
52
52
|
export declare function hoverNthElementBySelector(page: any, indexStr: string, selectorKey: string, table?: any): Promise<void>;
|
|
53
53
|
//# sourceMappingURL=mouse.d.ts.map
|
|
@@ -19,7 +19,7 @@ const fixtures_1 = require("../utils/fixtures");
|
|
|
19
19
|
/**
|
|
20
20
|
* Scrolls a specific element into the visible viewport.
|
|
21
21
|
* Supports fixtures for reusable selectors.
|
|
22
|
-
* @example When I scroll "footer.footerSection" into view
|
|
22
|
+
* @example When I pw scroll "footer.footerSection" into view
|
|
23
23
|
*/
|
|
24
24
|
async function scrollIntoView(page, selectorKey) {
|
|
25
25
|
const selectors = (0, fixtures_1.loadFixture)("selectors.json");
|
|
@@ -31,7 +31,7 @@ async function scrollIntoView(page, selectorKey) {
|
|
|
31
31
|
/**
|
|
32
32
|
* Scrolls the internal content of a specific element (overflow container) to X, Y coordinates.
|
|
33
33
|
* Supports fixtures for reusable selectors.
|
|
34
|
-
* @example When I scroll "chat.chatBox" to position x:0 y:500
|
|
34
|
+
* @example When I pw scroll "chat.chatBox" to position x:0 y:500
|
|
35
35
|
*/
|
|
36
36
|
async function scrollElementToPosition(page, selectorKey, x, y) {
|
|
37
37
|
const selectors = (0, fixtures_1.loadFixture)("selectors.json");
|
|
@@ -44,7 +44,7 @@ async function scrollElementToPosition(page, selectorKey, x, y) {
|
|
|
44
44
|
}
|
|
45
45
|
/**
|
|
46
46
|
* Scrolls the entire main browser window to specific X, Y coordinates immediately.
|
|
47
|
-
* @example When I scroll to coordinates x:0 y:0
|
|
47
|
+
* @example When I pw scroll to coordinates x:0 y:0
|
|
48
48
|
*/
|
|
49
49
|
async function scrollWindowToCoordinates(page, x, y) {
|
|
50
50
|
await page.evaluate((coords) => {
|
|
@@ -54,7 +54,7 @@ async function scrollWindowToCoordinates(page, x, y) {
|
|
|
54
54
|
}
|
|
55
55
|
/**
|
|
56
56
|
* Scrolls the entire main browser window smoothly to specific coordinates.
|
|
57
|
-
* @example When I scroll mouse window to position top:0 left:0
|
|
57
|
+
* @example When I pw scroll mouse window to position top:0 left:0
|
|
58
58
|
*/
|
|
59
59
|
async function scrollWindowSmoothly(page, top, left) {
|
|
60
60
|
await page.evaluate((coords) => {
|
|
@@ -69,7 +69,7 @@ async function scrollWindowSmoothly(page, top, left) {
|
|
|
69
69
|
/**
|
|
70
70
|
* Scrolls the window to a general direction edge (top, bottom, left, right).
|
|
71
71
|
* Includes a short wait for smooth scrolling animation to complete.
|
|
72
|
-
* @example When I scroll to "bottom"
|
|
72
|
+
* @example When I pw scroll to "bottom"
|
|
73
73
|
*/
|
|
74
74
|
async function scrollToDirection(page, direction) {
|
|
75
75
|
const validDirections = ["top", "bottom", "left", "right"];
|
|
@@ -103,7 +103,7 @@ async function scrollToDirection(page, direction) {
|
|
|
103
103
|
* Simulates a mouse hover over an element.
|
|
104
104
|
* Sets the hovered element as the "Active Element" for subsequent steps.
|
|
105
105
|
* Supports fixtures for reusable selectors.
|
|
106
|
-
* @example When I hover over the element "dropdown.toggleButton"
|
|
106
|
+
* @example When I pw hover over the element "dropdown.toggleButton"
|
|
107
107
|
*/
|
|
108
108
|
async function hoverElement(page, selectorKey) {
|
|
109
109
|
const selectors = (0, fixtures_1.loadFixture)("selectors.json");
|
|
@@ -116,7 +116,7 @@ async function hoverElement(page, selectorKey) {
|
|
|
116
116
|
/**
|
|
117
117
|
* Moves the mouse cursor to specific absolute screen coordinates.
|
|
118
118
|
* Useful for canvas interactions or testing mouse tracking.
|
|
119
|
-
* @example When I move mouse to coordinates 100, 200
|
|
119
|
+
* @example When I pw move mouse to coordinates 100, 200
|
|
120
120
|
*/
|
|
121
121
|
async function moveMouseToCoordinates(page, x, y) {
|
|
122
122
|
await page.mouse.move(x, y);
|
|
@@ -124,7 +124,7 @@ async function moveMouseToCoordinates(page, x, y) {
|
|
|
124
124
|
}
|
|
125
125
|
/**
|
|
126
126
|
* Hovers over the Nth element containing the specified text.
|
|
127
|
-
* @example When I hover on 1st element "Profile"
|
|
127
|
+
* @example When I pw hover on 1st element "Profile"
|
|
128
128
|
*/
|
|
129
129
|
async function hoverNthElementByText(page, indexStr, text, table) {
|
|
130
130
|
const index = parseInt(indexStr, 10);
|
|
@@ -138,7 +138,7 @@ async function hoverNthElementByText(page, indexStr, text, table) {
|
|
|
138
138
|
/**
|
|
139
139
|
* Hovers over the Nth element matching a CSS or XPath selector.
|
|
140
140
|
* Supports fixtures for reusable selectors.
|
|
141
|
-
* @example When I hover on 1st selector "user.avatar"
|
|
141
|
+
* @example When I pw hover on 1st selector "user.avatar"
|
|
142
142
|
*/
|
|
143
143
|
async function hoverNthElementBySelector(page, indexStr, selectorKey, table) {
|
|
144
144
|
const index = parseInt(indexStr, 10);
|
|
@@ -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");
|
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Navigates the browser to a specific absolute URL.
|
|
3
3
|
* @example
|
|
4
|
-
* Given I visit "https://www.google.com"
|
|
4
|
+
* Given I pw visit "https://www.google.com"
|
|
5
5
|
* @param url - The full URL string (must include http/https).
|
|
6
6
|
*/
|
|
7
7
|
export declare function visitUrl(page: any, url: string): Promise<void>;
|
|
8
8
|
/**
|
|
9
9
|
* Reloads the current page (simulates hitting the Refresh button).
|
|
10
10
|
* @example
|
|
11
|
-
* When I reload the page
|
|
11
|
+
* When I pw reload the page
|
|
12
12
|
*/
|
|
13
13
|
export declare function reloadPage(page: any): Promise<void>;
|
|
14
14
|
/**
|
|
15
15
|
* Navigates back one step in the browser history.
|
|
16
16
|
* Simulates clicking the browser's "Back" button.
|
|
17
17
|
* @example
|
|
18
|
-
* When I go back
|
|
18
|
+
* When I pw go back
|
|
19
19
|
*/
|
|
20
20
|
export declare function goBack(page: any): Promise<void>;
|
|
21
21
|
/**
|
|
22
22
|
* Navigates forward one step in the browser history.
|
|
23
23
|
* Simulates clicking the browser's "Forward" button.
|
|
24
24
|
* @example
|
|
25
|
-
* When I go forward
|
|
25
|
+
* When I pw go forward
|
|
26
26
|
*/
|
|
27
27
|
export declare function goForward(page: any): Promise<void>;
|
|
28
28
|
/**
|
|
@@ -30,7 +30,7 @@ export declare function goForward(page: any): Promise<void>;
|
|
|
30
30
|
* If a `baseURL` is configured in your Playwright config, this is relative to it.
|
|
31
31
|
* Otherwise, it treats the string as a direct URL.
|
|
32
32
|
* @example
|
|
33
|
-
* When I navigate to "/dashboard/login"
|
|
33
|
+
* When I pw navigate to "/dashboard/login"
|
|
34
34
|
* @param path - The relative path or URL to navigate to.
|
|
35
35
|
*/
|
|
36
36
|
export declare function navigateToPath(page: any, path: string): Promise<void>;
|
|
@@ -13,7 +13,7 @@ const registry_1 = require("../../core/registry");
|
|
|
13
13
|
/**
|
|
14
14
|
* Navigates the browser to a specific absolute URL.
|
|
15
15
|
* @example
|
|
16
|
-
* Given I visit "https://www.google.com"
|
|
16
|
+
* Given I pw visit "https://www.google.com"
|
|
17
17
|
* @param url - The full URL string (must include http/https).
|
|
18
18
|
*/
|
|
19
19
|
async function visitUrl(page, url) {
|
|
@@ -23,7 +23,7 @@ async function visitUrl(page, url) {
|
|
|
23
23
|
/**
|
|
24
24
|
* Reloads the current page (simulates hitting the Refresh button).
|
|
25
25
|
* @example
|
|
26
|
-
* When I reload the page
|
|
26
|
+
* When I pw reload the page
|
|
27
27
|
*/
|
|
28
28
|
async function reloadPage(page) {
|
|
29
29
|
await page.reload();
|
|
@@ -33,7 +33,7 @@ async function reloadPage(page) {
|
|
|
33
33
|
* Navigates back one step in the browser history.
|
|
34
34
|
* Simulates clicking the browser's "Back" button.
|
|
35
35
|
* @example
|
|
36
|
-
* When I go back
|
|
36
|
+
* When I pw go back
|
|
37
37
|
*/
|
|
38
38
|
async function goBack(page) {
|
|
39
39
|
await page.goBack();
|
|
@@ -43,7 +43,7 @@ async function goBack(page) {
|
|
|
43
43
|
* Navigates forward one step in the browser history.
|
|
44
44
|
* Simulates clicking the browser's "Forward" button.
|
|
45
45
|
* @example
|
|
46
|
-
* When I go forward
|
|
46
|
+
* When I pw go forward
|
|
47
47
|
*/
|
|
48
48
|
async function goForward(page) {
|
|
49
49
|
await page.goForward();
|
|
@@ -54,7 +54,7 @@ async function goForward(page) {
|
|
|
54
54
|
* If a `baseURL` is configured in your Playwright config, this is relative to it.
|
|
55
55
|
* Otherwise, it treats the string as a direct URL.
|
|
56
56
|
* @example
|
|
57
|
-
* When I navigate to "/dashboard/login"
|
|
57
|
+
* When I pw navigate to "/dashboard/login"
|
|
58
58
|
* @param path - The relative path or URL to navigate to.
|
|
59
59
|
*/
|
|
60
60
|
async function navigateToPath(page, path) {
|
|
@@ -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");
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Takes a screenshot of the entire page.
|
|
3
3
|
* @param page - The Playwright page object
|
|
4
4
|
* @param filename - The filename to save the screenshot as
|
|
5
|
-
* @example When I take a screenshot of the page "dashboard-view.png"
|
|
5
|
+
* @example When I pw take a screenshot of the page "dashboard-view.png"
|
|
6
6
|
*/
|
|
7
7
|
export declare function takePageScreenshot(page: any, filename: string): Promise<void>;
|
|
8
8
|
/**
|
|
@@ -10,14 +10,14 @@ export declare function takePageScreenshot(page: any, filename: string): Promise
|
|
|
10
10
|
* @param page - The Playwright page object
|
|
11
11
|
* @param selectorKey - The selector key (can be a fixture key or raw CSS selector)
|
|
12
12
|
* @param filename - The filename to save the screenshot as
|
|
13
|
-
* @example When I take a screenshot of element "header.navbar" as "navbar.png"
|
|
13
|
+
* @example When I pw take a screenshot of element "header.navbar" as "navbar.png"
|
|
14
14
|
*/
|
|
15
15
|
export declare function takeElementScreenshot(page: any, selectorKey: string, filename: string): Promise<void>;
|
|
16
16
|
/**
|
|
17
17
|
* Takes a screenshot of the viewport area.
|
|
18
18
|
* @param page - The Playwright page object
|
|
19
19
|
* @param filename - The filename to save the screenshot as
|
|
20
|
-
* @example When I take a viewport screenshot "login-area.png"
|
|
20
|
+
* @example When I pw take a viewport screenshot "login-area.png"
|
|
21
21
|
*/
|
|
22
22
|
export declare function takeViewportScreenshot(page: any, filename: string): Promise<void>;
|
|
23
23
|
/**
|
|
@@ -25,7 +25,7 @@ export declare function takeViewportScreenshot(page: any, filename: string): Pro
|
|
|
25
25
|
* @param page - The Playwright page object
|
|
26
26
|
* @param currentFilename - The filename of the current page screenshot
|
|
27
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"
|
|
28
|
+
* @example Then I pw expect page "current-view.png" to closely match "reference-view.png"
|
|
29
29
|
*/
|
|
30
30
|
export declare function expectPageToCloselyMatch(page: any, currentFilename: string, referenceFilename: string): Promise<void>;
|
|
31
31
|
/**
|
|
@@ -34,14 +34,14 @@ export declare function expectPageToCloselyMatch(page: any, currentFilename: str
|
|
|
34
34
|
* @param selectorKey - The selector key (can be a fixture key or raw CSS selector)
|
|
35
35
|
* @param currentFilename - The filename of the current element screenshot
|
|
36
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"
|
|
37
|
+
* @example Then I pw expect element "div.content" screenshot "content-current.png" to closely match "content-reference.png"
|
|
38
38
|
*/
|
|
39
39
|
export declare function expectElementToCloselyMatch(page: any, selectorKey: string, currentFilename: string, referenceFilename: string): Promise<void>;
|
|
40
40
|
/**
|
|
41
41
|
* Takes a screenshot and attaches it to the test report.
|
|
42
42
|
* @param page - The Playwright page object
|
|
43
43
|
* @param name - The name to identify the screenshot in the report
|
|
44
|
-
* @example When I capture screenshot "error-state" for the report
|
|
44
|
+
* @example When I pw capture screenshot "error-state" for the report
|
|
45
45
|
*/
|
|
46
46
|
export declare function captureScreenshotForReport(page: any, name: string): Promise<void>;
|
|
47
47
|
//# sourceMappingURL=visual.d.ts.map
|