playwright-cucumber-ts-steps 1.1.8 → 1.1.10
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/LICENSE +21 -0
- package/dist/backend/actions/click.d.ts +132 -1
- package/dist/backend/actions/click.d.ts.map +1 -1
- package/dist/backend/actions/click.js +122 -53
- package/dist/backend/actions/find.d.ts +243 -1
- package/dist/backend/actions/find.d.ts.map +1 -1
- package/dist/backend/actions/find.js +196 -72
- package/dist/backend/actions/form.d.ts +37 -1
- package/dist/backend/actions/form.d.ts.map +1 -1
- package/dist/backend/actions/form.js +55 -3
- package/dist/backend/actions/formTable.d.ts +25 -1
- package/dist/backend/actions/formTable.d.ts.map +1 -1
- package/dist/backend/actions/formTable.js +27 -5
- package/dist/backend/actions/frames.d.ts +53 -1
- package/dist/backend/actions/frames.d.ts.map +1 -1
- package/dist/backend/actions/frames.js +48 -11
- package/dist/backend/actions/inputs.d.ts +139 -1
- package/dist/backend/actions/inputs.d.ts.map +1 -1
- package/dist/backend/actions/inputs.js +113 -43
- package/dist/backend/actions/interactions.d.ts +61 -1
- package/dist/backend/actions/interactions.d.ts.map +1 -1
- package/dist/backend/actions/interactions.js +65 -10
- package/dist/backend/actions/keyboard.d.ts +70 -1
- package/dist/backend/actions/keyboard.d.ts.map +1 -1
- package/dist/backend/actions/keyboard.js +59 -23
- package/dist/backend/actions/misc.d.ts +134 -1
- package/dist/backend/actions/misc.d.ts.map +1 -1
- package/dist/backend/actions/misc.js +106 -42
- package/dist/backend/actions/mobile.d.ts +74 -1
- package/dist/backend/actions/mobile.d.ts.map +1 -1
- package/dist/backend/actions/mobile.js +74 -13
- package/dist/backend/actions/mouse.d.ts +79 -1
- package/dist/backend/actions/mouse.d.ts.map +1 -1
- package/dist/backend/actions/mouse.js +66 -21
- package/dist/backend/actions/navigation.d.ts +48 -1
- package/dist/backend/actions/navigation.d.ts.map +1 -1
- package/dist/backend/actions/navigation.js +42 -15
- package/dist/backend/actions/waits.d.ts +55 -1
- package/dist/backend/actions/waits.d.ts.map +1 -1
- package/dist/backend/actions/waits.js +49 -17
- package/dist/backend/api/assertions.d.ts +32 -1
- package/dist/backend/api/assertions.d.ts.map +1 -1
- package/dist/backend/api/assertions.js +37 -9
- package/dist/backend/api/mock.d.ts +34 -1
- package/dist/backend/api/mock.d.ts.map +1 -1
- package/dist/backend/api/mock.js +37 -10
- package/dist/backend/api/network.d.ts +60 -1
- package/dist/backend/api/network.d.ts.map +1 -1
- package/dist/backend/api/network.js +53 -21
- package/dist/backend/api/requests.d.ts +43 -1
- package/dist/backend/api/requests.d.ts.map +1 -1
- package/dist/backend/api/requests.js +49 -17
- package/dist/backend/assertions/pageState.d.ts +40 -1
- package/dist/backend/assertions/pageState.d.ts.map +1 -1
- package/dist/backend/assertions/pageState.js +33 -12
- package/dist/backend/assertions/text.d.ts +46 -1
- package/dist/backend/assertions/text.d.ts.map +1 -1
- package/dist/backend/assertions/text.js +51 -8
- package/dist/backend/assertions/visibility.d.ts +102 -1
- package/dist/backend/assertions/visibility.d.ts.map +1 -1
- package/dist/backend/assertions/visibility.js +86 -36
- package/dist/backend/auth/index.js +2 -2
- package/dist/backend/db/steps.d.ts +35 -1
- package/dist/backend/db/steps.d.ts.map +1 -1
- package/dist/backend/db/steps.js +48 -15
- package/dist/backend/elements/alerts.d.ts +35 -1
- package/dist/backend/elements/alerts.d.ts.map +1 -1
- package/dist/backend/elements/alerts.js +39 -6
- package/dist/backend/elements/forms.d.ts +44 -1
- package/dist/backend/elements/forms.d.ts.map +1 -1
- package/dist/backend/elements/forms.js +50 -11
- package/dist/backend/elements/frames.d.ts +36 -1
- package/dist/backend/elements/frames.d.ts.map +1 -1
- package/dist/backend/elements/frames.js +43 -13
- package/dist/core/runner.d.ts.map +1 -1
- package/dist/core/runner.js +3 -4
- package/package.json +51 -12
|
@@ -1,2 +1,75 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Taps on the currently stored (active) element.
|
|
3
|
+
* Uses a "Hybrid Tap" strategy: tries to tap, falls back to click if touch is unsupported.
|
|
4
|
+
*
|
|
5
|
+
* ```gherkin
|
|
6
|
+
* When I tap
|
|
7
|
+
* ```
|
|
8
|
+
*/
|
|
9
|
+
export declare const TapStoredElement: void;
|
|
10
|
+
/**
|
|
11
|
+
* Finds an element by selector and taps it.
|
|
12
|
+
* Uses a "Hybrid Tap" strategy.
|
|
13
|
+
*
|
|
14
|
+
* ```gherkin
|
|
15
|
+
* When I tap element "#menu-toggle"
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* @param selector - The CSS selector of the element.
|
|
19
|
+
*/
|
|
20
|
+
export declare const TapElementBySelector: void;
|
|
21
|
+
/**
|
|
22
|
+
* Taps at specific X, Y coordinates on the screen.
|
|
23
|
+
* Implemented via `mouse.click` which works reliably across both desktop and mobile viewports.
|
|
24
|
+
*
|
|
25
|
+
* ```gherkin
|
|
26
|
+
* When I tap coordinates x:50 y:200
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* @param x - The X-coordinate.
|
|
30
|
+
* @param y - The Y-coordinate.
|
|
31
|
+
*/
|
|
32
|
+
export declare const TapCoordinates: void;
|
|
33
|
+
/**
|
|
34
|
+
* Resizes the browser window/viewport to specific dimensions.
|
|
35
|
+
*
|
|
36
|
+
* ```gherkin
|
|
37
|
+
* When I resize window to width 375 and height 812
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* @param width - The width in pixels.
|
|
41
|
+
* @param height - The height in pixels.
|
|
42
|
+
*/
|
|
43
|
+
export declare const ResizeWindow: void;
|
|
44
|
+
/**
|
|
45
|
+
* Resizes the viewport to match a specific device preset.
|
|
46
|
+
*
|
|
47
|
+
* ```gherkin
|
|
48
|
+
* When I simulate device "iPhone 12"
|
|
49
|
+
* ```
|
|
50
|
+
*
|
|
51
|
+
* @param deviceName - The name of the device. Supported: "iPhone 12", "iPhone SE", "iPad", "Pixel 5", "Samsung Galaxy S8", "Desktop".
|
|
52
|
+
*/
|
|
53
|
+
export declare const SimulateDevice: void;
|
|
54
|
+
/**
|
|
55
|
+
* Sets the geolocation coordinates for the browser context and auto-grants permission.
|
|
56
|
+
*
|
|
57
|
+
* ```gherkin
|
|
58
|
+
* When I set geolocation to lat: 37.7749 long: -122.4194
|
|
59
|
+
* ```
|
|
60
|
+
*
|
|
61
|
+
* @param lat - The latitude (float).
|
|
62
|
+
* @param long - The longitude (float).
|
|
63
|
+
*/
|
|
64
|
+
export declare const SetGeolocation: void;
|
|
65
|
+
/**
|
|
66
|
+
* Grants a specific browser permission to the current context.
|
|
67
|
+
*
|
|
68
|
+
* ```gherkin
|
|
69
|
+
* When I grant permission "notifications"
|
|
70
|
+
* ```
|
|
71
|
+
*
|
|
72
|
+
* @param permission - The permission name (e.g., "geolocation", "notifications", "camera").
|
|
73
|
+
*/
|
|
74
|
+
export declare const GrantPermission: void;
|
|
2
75
|
//# sourceMappingURL=mobile.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mobile.d.ts","sourceRoot":"","sources":["../../../src/backend/actions/mobile.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"mobile.d.ts","sourceRoot":"","sources":["../../../src/backend/actions/mobile.ts"],"names":[],"mappings":"AA8BA;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,MAI3B,CAAC;AAEH;;;;;;;;;GASG;AACH,eAAO,MAAM,oBAAoB,MAI/B,CAAC;AAEH;;;;;;;;;;GAUG;AACH,eAAO,MAAM,cAAc,MAIzB,CAAC;AAMH;;;;;;;;;GASG;AACH,eAAO,MAAM,YAAY,MAMxB,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,MAiBzB,CAAC;AAMH;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc,MAO1B,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe,MAG1B,CAAC"}
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GrantPermission = exports.SetGeolocation = exports.SimulateDevice = exports.ResizeWindow = exports.TapCoordinates = exports.TapElementBySelector = exports.TapStoredElement = void 0;
|
|
3
4
|
const registry_1 = require("../../core/registry");
|
|
4
5
|
const state_1 = require("../utils/state");
|
|
5
6
|
/**
|
|
6
|
-
* Helper: Tries to
|
|
7
|
+
* Helper: Tries to perform a touch tap.
|
|
8
|
+
* If the current browser context does not support touch events (e.g., Desktop Chrome),
|
|
9
|
+
* it gracefully falls back to a standard mouse click.
|
|
10
|
+
*
|
|
11
|
+
* @param target - The Playwright Locator to interact with.
|
|
12
|
+
* @returns "tapped" or "clicked (fallback)" based on what occurred.
|
|
7
13
|
*/
|
|
8
14
|
async function safeTap(target) {
|
|
9
15
|
try {
|
|
@@ -24,28 +30,45 @@ async function safeTap(target) {
|
|
|
24
30
|
// 1. TOUCH INTERACTIONS
|
|
25
31
|
// ==================================================
|
|
26
32
|
/**
|
|
27
|
-
* Taps on the currently stored element.
|
|
28
|
-
*
|
|
33
|
+
* Taps on the currently stored (active) element.
|
|
34
|
+
* Uses a "Hybrid Tap" strategy: tries to tap, falls back to click if touch is unsupported.
|
|
35
|
+
*
|
|
36
|
+
* ```gherkin
|
|
37
|
+
* When I tap
|
|
38
|
+
* ```
|
|
29
39
|
*/
|
|
30
|
-
(0, registry_1.Step)("I tap", async (page) => {
|
|
40
|
+
exports.TapStoredElement = (0, registry_1.Step)("I tap", async (page) => {
|
|
31
41
|
const element = (0, state_1.getActiveElement)(page);
|
|
32
42
|
const action = await safeTap(element);
|
|
33
43
|
console.log(`👆 ${action === "tapped" ? "Tapped" : "Clicked"} stored element`);
|
|
34
44
|
});
|
|
35
45
|
/**
|
|
36
46
|
* Finds an element by selector and taps it.
|
|
37
|
-
*
|
|
47
|
+
* Uses a "Hybrid Tap" strategy.
|
|
48
|
+
*
|
|
49
|
+
* ```gherkin
|
|
50
|
+
* When I tap element "#menu-toggle"
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* @param selector - The CSS selector of the element.
|
|
38
54
|
*/
|
|
39
|
-
(0, registry_1.Step)("I tap element {string}", async (page, selector) => {
|
|
55
|
+
exports.TapElementBySelector = (0, registry_1.Step)("I tap element {string}", async (page, selector) => {
|
|
40
56
|
const element = page.locator(selector);
|
|
41
57
|
const action = await safeTap(element);
|
|
42
58
|
console.log(`👆 ${action === "tapped" ? "Tapped" : "Clicked"} element "${selector}"`);
|
|
43
59
|
});
|
|
44
60
|
/**
|
|
45
|
-
* Taps at specific coordinates.
|
|
46
|
-
*
|
|
61
|
+
* Taps at specific X, Y coordinates on the screen.
|
|
62
|
+
* Implemented via `mouse.click` which works reliably across both desktop and mobile viewports.
|
|
63
|
+
*
|
|
64
|
+
* ```gherkin
|
|
65
|
+
* When I tap coordinates x:50 y:200
|
|
66
|
+
* ```
|
|
67
|
+
*
|
|
68
|
+
* @param x - The X-coordinate.
|
|
69
|
+
* @param y - The Y-coordinate.
|
|
47
70
|
*/
|
|
48
|
-
(0, registry_1.Step)("I tap coordinates x:{int} y:{int}", async (page, x, y) => {
|
|
71
|
+
exports.TapCoordinates = (0, registry_1.Step)("I tap coordinates x:{int} y:{int}", async (page, x, y) => {
|
|
49
72
|
// page.mouse.click works for both desktop and mobile viewports
|
|
50
73
|
await page.mouse.click(x, y);
|
|
51
74
|
console.log(`👆 Tapped at (${x}, ${y})`);
|
|
@@ -53,11 +76,30 @@ async function safeTap(target) {
|
|
|
53
76
|
// ==================================================
|
|
54
77
|
// 2. VIEWPORT & EMULATION
|
|
55
78
|
// ==================================================
|
|
56
|
-
|
|
79
|
+
/**
|
|
80
|
+
* Resizes the browser window/viewport to specific dimensions.
|
|
81
|
+
*
|
|
82
|
+
* ```gherkin
|
|
83
|
+
* When I resize window to width 375 and height 812
|
|
84
|
+
* ```
|
|
85
|
+
*
|
|
86
|
+
* @param width - The width in pixels.
|
|
87
|
+
* @param height - The height in pixels.
|
|
88
|
+
*/
|
|
89
|
+
exports.ResizeWindow = (0, registry_1.Step)("I resize window to width {int} and height {int}", async (page, width, height) => {
|
|
57
90
|
await page.setViewportSize({ width, height });
|
|
58
91
|
console.log(`📱 Resized viewport to ${width}x${height}`);
|
|
59
92
|
});
|
|
60
|
-
|
|
93
|
+
/**
|
|
94
|
+
* Resizes the viewport to match a specific device preset.
|
|
95
|
+
*
|
|
96
|
+
* ```gherkin
|
|
97
|
+
* When I simulate device "iPhone 12"
|
|
98
|
+
* ```
|
|
99
|
+
*
|
|
100
|
+
* @param deviceName - The name of the device. Supported: "iPhone 12", "iPhone SE", "iPad", "Pixel 5", "Samsung Galaxy S8", "Desktop".
|
|
101
|
+
*/
|
|
102
|
+
exports.SimulateDevice = (0, registry_1.Step)("I simulate device {string}", async (page, deviceName) => {
|
|
61
103
|
const devices = {
|
|
62
104
|
"iPhone 12": { width: 390, height: 844 },
|
|
63
105
|
"iPhone SE": { width: 375, height: 667 },
|
|
@@ -76,12 +118,31 @@ async function safeTap(target) {
|
|
|
76
118
|
// ==================================================
|
|
77
119
|
// 3. GEOLOCATION & PERMISSIONS
|
|
78
120
|
// ==================================================
|
|
79
|
-
|
|
121
|
+
/**
|
|
122
|
+
* Sets the geolocation coordinates for the browser context and auto-grants permission.
|
|
123
|
+
*
|
|
124
|
+
* ```gherkin
|
|
125
|
+
* When I set geolocation to lat: 37.7749 long: -122.4194
|
|
126
|
+
* ```
|
|
127
|
+
*
|
|
128
|
+
* @param lat - The latitude (float).
|
|
129
|
+
* @param long - The longitude (float).
|
|
130
|
+
*/
|
|
131
|
+
exports.SetGeolocation = (0, registry_1.Step)("I set geolocation to lat: {float} long: {float}", async (page, lat, long) => {
|
|
80
132
|
await page.context().setGeolocation({ latitude: lat, longitude: long });
|
|
81
133
|
await page.context().grantPermissions(["geolocation"]);
|
|
82
134
|
console.log(`🌍 Geolocation set to ${lat}, ${long}`);
|
|
83
135
|
});
|
|
84
|
-
|
|
136
|
+
/**
|
|
137
|
+
* Grants a specific browser permission to the current context.
|
|
138
|
+
*
|
|
139
|
+
* ```gherkin
|
|
140
|
+
* When I grant permission "notifications"
|
|
141
|
+
* ```
|
|
142
|
+
*
|
|
143
|
+
* @param permission - The permission name (e.g., "geolocation", "notifications", "camera").
|
|
144
|
+
*/
|
|
145
|
+
exports.GrantPermission = (0, registry_1.Step)("I grant permission {string}", async (page, permission) => {
|
|
85
146
|
await page.context().grantPermissions([permission]);
|
|
86
147
|
console.log(`🛡️ Granted permission: "${permission}"`);
|
|
87
148
|
});
|
|
@@ -1,2 +1,80 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Scrolls a specific element into the visible viewport.
|
|
3
|
+
* Useful when an element is off-screen and needs to be visible before interaction.
|
|
4
|
+
*
|
|
5
|
+
* ```gherkin
|
|
6
|
+
* When I scroll ".footer-section" into view
|
|
7
|
+
* ```
|
|
8
|
+
*
|
|
9
|
+
* @param selector - The CSS selector of the element.
|
|
10
|
+
*/
|
|
11
|
+
export declare const ScrollIntoView: void;
|
|
12
|
+
/**
|
|
13
|
+
* Scrolls the internal content of a specific element (overflow container) to X, Y coordinates.
|
|
14
|
+
*
|
|
15
|
+
* ```gherkin
|
|
16
|
+
* When I scroll "#chat-box" to position x:0 y:500
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @param selector - The CSS selector of the scrollable container.
|
|
20
|
+
* @param x - The horizontal scroll position (pixels).
|
|
21
|
+
* @param y - The vertical scroll position (pixels).
|
|
22
|
+
*/
|
|
23
|
+
export declare const ScrollElementToPosition: void;
|
|
24
|
+
/**
|
|
25
|
+
* Scrolls the entire main browser window to specific X, Y coordinates immediately.
|
|
26
|
+
*
|
|
27
|
+
* ```gherkin
|
|
28
|
+
* When I scroll to coordinates x:0 y:0
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @param x - The absolute horizontal position.
|
|
32
|
+
* @param y - The absolute vertical position.
|
|
33
|
+
*/
|
|
34
|
+
export declare const ScrollWindowToCoordinates: void;
|
|
35
|
+
/**
|
|
36
|
+
* Scrolls the entire main browser window smoothly to specific coordinates.
|
|
37
|
+
*
|
|
38
|
+
* ```gherkin
|
|
39
|
+
* When I scroll mouse window to position top:0 left:0
|
|
40
|
+
* ```
|
|
41
|
+
*
|
|
42
|
+
* @param top - The vertical position (Y).
|
|
43
|
+
* @param left - The horizontal position (X).
|
|
44
|
+
*/
|
|
45
|
+
export declare const ScrollWindowSmoothly: void;
|
|
46
|
+
/**
|
|
47
|
+
* Scrolls the window to a general direction edge (top, bottom, left, right).
|
|
48
|
+
* Includes a short wait for smooth scrolling animation to complete.
|
|
49
|
+
*
|
|
50
|
+
* ```gherkin
|
|
51
|
+
* When I scroll to "bottom"
|
|
52
|
+
* ```
|
|
53
|
+
*
|
|
54
|
+
* @param direction - One of: "top", "bottom", "left", "right".
|
|
55
|
+
*/
|
|
56
|
+
export declare const ScrollToDirection: void;
|
|
57
|
+
/**
|
|
58
|
+
* Simulates a mouse hover over an element.
|
|
59
|
+
* **Important:** Sets the hovered element as the "Active Element" for subsequent steps.
|
|
60
|
+
*
|
|
61
|
+
* ```gherkin
|
|
62
|
+
* When I hover over the element ".dropdown-toggle"
|
|
63
|
+
* ```
|
|
64
|
+
*
|
|
65
|
+
* @param selector - The CSS selector to hover over.
|
|
66
|
+
*/
|
|
67
|
+
export declare const HoverElement: void;
|
|
68
|
+
/**
|
|
69
|
+
* Moves the mouse cursor to specific absolute screen coordinates.
|
|
70
|
+
* Useful for canvas interactions or testing mouse tracking.
|
|
71
|
+
*
|
|
72
|
+
* ```gherkin
|
|
73
|
+
* When I move mouse to coordinates 100, 200
|
|
74
|
+
* ```
|
|
75
|
+
*
|
|
76
|
+
* @param x - The X-coordinate.
|
|
77
|
+
* @param y - The Y-coordinate.
|
|
78
|
+
*/
|
|
79
|
+
export declare const MoveMouseToCoordinates: void;
|
|
2
80
|
//# sourceMappingURL=mouse.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mouse.d.ts","sourceRoot":"","sources":["../../../src/backend/actions/mouse.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"mouse.d.ts","sourceRoot":"","sources":["../../../src/backend/actions/mouse.ts"],"names":[],"mappings":"AAOA;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc,MAIzB,CAAC;AAEH;;;;;;;;;;GAUG;AACH,eAAO,MAAM,uBAAuB,MAYnC,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,yBAAyB,MAWrC,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,oBAAoB,MAehC,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB,MAgC5B,CAAC;AAMH;;;;;;;;;GASG;AACH,eAAO,MAAM,YAAY,MAQvB,CAAC;AAEH;;;;;;;;;;GAUG;AACH,eAAO,MAAM,sBAAsB,MAMlC,CAAC"}
|
|
@@ -1,24 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MoveMouseToCoordinates = exports.HoverElement = exports.ScrollToDirection = exports.ScrollWindowSmoothly = exports.ScrollWindowToCoordinates = exports.ScrollElementToPosition = exports.ScrollIntoView = void 0;
|
|
3
4
|
const registry_1 = require("../../core/registry");
|
|
4
5
|
const state_1 = require("../utils/state");
|
|
5
6
|
// ===================================================================================
|
|
6
7
|
// MOUSE ACTIONS: SCROLLING
|
|
7
8
|
// ===================================================================================
|
|
8
9
|
/**
|
|
9
|
-
* Scrolls
|
|
10
|
-
*
|
|
10
|
+
* Scrolls a specific element into the visible viewport.
|
|
11
|
+
* Useful when an element is off-screen and needs to be visible before interaction.
|
|
12
|
+
*
|
|
13
|
+
* ```gherkin
|
|
14
|
+
* When I scroll ".footer-section" into view
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* @param selector - The CSS selector of the element.
|
|
11
18
|
*/
|
|
12
|
-
(0, registry_1.Step)("I scroll {string} into view", async (page, selector) => {
|
|
19
|
+
exports.ScrollIntoView = (0, registry_1.Step)("I scroll {string} into view", async (page, selector) => {
|
|
13
20
|
const locator = page.locator(selector);
|
|
14
21
|
await locator.scrollIntoViewIfNeeded();
|
|
15
22
|
console.log(`🖱️ Scrolled element "${selector}" into view.`);
|
|
16
23
|
});
|
|
17
24
|
/**
|
|
18
|
-
* Scrolls a specific element to
|
|
19
|
-
*
|
|
25
|
+
* Scrolls the internal content of a specific element (overflow container) to X, Y coordinates.
|
|
26
|
+
*
|
|
27
|
+
* ```gherkin
|
|
28
|
+
* When I scroll "#chat-box" to position x:0 y:500
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @param selector - The CSS selector of the scrollable container.
|
|
32
|
+
* @param x - The horizontal scroll position (pixels).
|
|
33
|
+
* @param y - The vertical scroll position (pixels).
|
|
20
34
|
*/
|
|
21
|
-
(0, registry_1.Step)("I scroll {string} to position x:{int} y:{int}", async (page, selector, x, y) => {
|
|
35
|
+
exports.ScrollElementToPosition = (0, registry_1.Step)("I scroll {string} to position x:{int} y:{int}", async (page, selector, x, y) => {
|
|
22
36
|
const locator = page.locator(selector);
|
|
23
37
|
await locator.evaluate((el, coords) => {
|
|
24
38
|
el.scrollTo(coords.x, coords.y);
|
|
@@ -26,20 +40,32 @@ const state_1 = require("../utils/state");
|
|
|
26
40
|
console.log(`🖱️ Scrolled element "${selector}" to position x:${x} y:${y}.`);
|
|
27
41
|
});
|
|
28
42
|
/**
|
|
29
|
-
* Scrolls the entire window to specific coordinates.
|
|
30
|
-
*
|
|
43
|
+
* Scrolls the entire main browser window to specific X, Y coordinates immediately.
|
|
44
|
+
*
|
|
45
|
+
* ```gherkin
|
|
46
|
+
* When I scroll to coordinates x:0 y:0
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* @param x - The absolute horizontal position.
|
|
50
|
+
* @param y - The absolute vertical position.
|
|
31
51
|
*/
|
|
32
|
-
(0, registry_1.Step)("I scroll to coordinates x:{int} y:{int}", async (page, x, y) => {
|
|
52
|
+
exports.ScrollWindowToCoordinates = (0, registry_1.Step)("I scroll to coordinates x:{int} y:{int}", async (page, x, y) => {
|
|
33
53
|
await page.evaluate((coords) => {
|
|
34
54
|
window.scrollTo(coords.x, coords.y);
|
|
35
55
|
}, { x, y });
|
|
36
56
|
console.log(`🖱️ Scrolled window to coordinates x:${x} y:${y}.`);
|
|
37
57
|
});
|
|
38
58
|
/**
|
|
39
|
-
* Scrolls the window smoothly to specific coordinates.
|
|
40
|
-
*
|
|
59
|
+
* Scrolls the entire main browser window smoothly to specific coordinates.
|
|
60
|
+
*
|
|
61
|
+
* ```gherkin
|
|
62
|
+
* When I scroll mouse window to position top:0 left:0
|
|
63
|
+
* ```
|
|
64
|
+
*
|
|
65
|
+
* @param top - The vertical position (Y).
|
|
66
|
+
* @param left - The horizontal position (X).
|
|
41
67
|
*/
|
|
42
|
-
(0, registry_1.Step)("I scroll mouse window to position top:{int} left:{int}", async (page, top, left) => {
|
|
68
|
+
exports.ScrollWindowSmoothly = (0, registry_1.Step)("I scroll mouse window to position top:{int} left:{int}", async (page, top, left) => {
|
|
43
69
|
await page.evaluate((coords) => {
|
|
44
70
|
window.scrollTo({
|
|
45
71
|
top: coords.top,
|
|
@@ -50,10 +76,16 @@ const state_1 = require("../utils/state");
|
|
|
50
76
|
console.log(`🖱️ Scrolled window to position top:${top} left:${left} (smooth).`);
|
|
51
77
|
});
|
|
52
78
|
/**
|
|
53
|
-
* Scrolls to a general direction (top, bottom, left, right).
|
|
54
|
-
*
|
|
79
|
+
* Scrolls the window to a general direction edge (top, bottom, left, right).
|
|
80
|
+
* Includes a short wait for smooth scrolling animation to complete.
|
|
81
|
+
*
|
|
82
|
+
* ```gherkin
|
|
83
|
+
* When I scroll to "bottom"
|
|
84
|
+
* ```
|
|
85
|
+
*
|
|
86
|
+
* @param direction - One of: "top", "bottom", "left", "right".
|
|
55
87
|
*/
|
|
56
|
-
(0, registry_1.Step)("I scroll to {string}", async (page, direction) => {
|
|
88
|
+
exports.ScrollToDirection = (0, registry_1.Step)("I scroll to {string}", async (page, direction) => {
|
|
57
89
|
const validDirections = ["top", "bottom", "left", "right"];
|
|
58
90
|
const dir = direction.toLowerCase();
|
|
59
91
|
if (!validDirections.includes(dir)) {
|
|
@@ -85,10 +117,16 @@ const state_1 = require("../utils/state");
|
|
|
85
117
|
// MOUSE ACTIONS: HOVERING / MOVEMENT
|
|
86
118
|
// ===================================================================================
|
|
87
119
|
/**
|
|
88
|
-
*
|
|
89
|
-
*
|
|
120
|
+
* Simulates a mouse hover over an element.
|
|
121
|
+
* **Important:** Sets the hovered element as the "Active Element" for subsequent steps.
|
|
122
|
+
*
|
|
123
|
+
* ```gherkin
|
|
124
|
+
* When I hover over the element ".dropdown-toggle"
|
|
125
|
+
* ```
|
|
126
|
+
*
|
|
127
|
+
* @param selector - The CSS selector to hover over.
|
|
90
128
|
*/
|
|
91
|
-
(0, registry_1.Step)("I hover over the element {string}", async (page, selector) => {
|
|
129
|
+
exports.HoverElement = (0, registry_1.Step)("I hover over the element {string}", async (page, selector) => {
|
|
92
130
|
const element = page.locator(selector);
|
|
93
131
|
await element.hover();
|
|
94
132
|
// 🔥 Store the hovered element so we can click/assert on it immediately after
|
|
@@ -96,10 +134,17 @@ const state_1 = require("../utils/state");
|
|
|
96
134
|
console.log(`🖱️ Hovered over: "${selector}".`);
|
|
97
135
|
});
|
|
98
136
|
/**
|
|
99
|
-
* Moves mouse to absolute coordinates.
|
|
100
|
-
*
|
|
137
|
+
* Moves the mouse cursor to specific absolute screen coordinates.
|
|
138
|
+
* Useful for canvas interactions or testing mouse tracking.
|
|
139
|
+
*
|
|
140
|
+
* ```gherkin
|
|
141
|
+
* When I move mouse to coordinates 100, 200
|
|
142
|
+
* ```
|
|
143
|
+
*
|
|
144
|
+
* @param x - The X-coordinate.
|
|
145
|
+
* @param y - The Y-coordinate.
|
|
101
146
|
*/
|
|
102
|
-
(0, registry_1.Step)("I move mouse to coordinates {int}, {int}", async (page, x, y) => {
|
|
147
|
+
exports.MoveMouseToCoordinates = (0, registry_1.Step)("I move mouse to coordinates {int}, {int}", async (page, x, y) => {
|
|
103
148
|
await page.mouse.move(x, y);
|
|
104
149
|
console.log(`🧭 Mouse moved to (${x}, ${y}).`);
|
|
105
150
|
});
|
|
@@ -1,2 +1,49 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Navigates the browser to a specific absolute URL.
|
|
3
|
+
*
|
|
4
|
+
* ```gherkin
|
|
5
|
+
* Given I visit "[https://www.google.com](https://www.google.com)"
|
|
6
|
+
* ```
|
|
7
|
+
*
|
|
8
|
+
* @param url - The full URL string (must include http/https).
|
|
9
|
+
*/
|
|
10
|
+
export declare const VisitUrl: void;
|
|
11
|
+
/**
|
|
12
|
+
* Reloads the current page (simulates hitting the Refresh button).
|
|
13
|
+
*
|
|
14
|
+
* ```gherkin
|
|
15
|
+
* When I reload the page
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare const ReloadPage: void;
|
|
19
|
+
/**
|
|
20
|
+
* Navigates back one step in the browser history.
|
|
21
|
+
* Simulates clicking the browser's "Back" button.
|
|
22
|
+
*
|
|
23
|
+
* ```gherkin
|
|
24
|
+
* When I go back
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare const GoBack: void;
|
|
28
|
+
/**
|
|
29
|
+
* Navigates forward one step in the browser history.
|
|
30
|
+
* Simulates clicking the browser's "Forward" button.
|
|
31
|
+
*
|
|
32
|
+
* ```gherkin
|
|
33
|
+
* When I go forward
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare const GoForward: void;
|
|
37
|
+
/**
|
|
38
|
+
* Navigates to a specific path.
|
|
39
|
+
* If a `baseURL` is configured in your Playwright config, this is relative to it.
|
|
40
|
+
* Otherwise, it treats the string as a direct URL.
|
|
41
|
+
*
|
|
42
|
+
* ```gherkin
|
|
43
|
+
* When I navigate to "/dashboard/login"
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
* @param path - The relative path or URL to navigate to.
|
|
47
|
+
*/
|
|
48
|
+
export declare const NavigateToPath: void;
|
|
2
49
|
//# sourceMappingURL=navigation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"navigation.d.ts","sourceRoot":"","sources":["../../../src/backend/actions/navigation.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"navigation.d.ts","sourceRoot":"","sources":["../../../src/backend/actions/navigation.ts"],"names":[],"mappings":"AAMA;;;;;;;;GAQG;AACH,eAAO,MAAM,QAAQ,MAGnB,CAAC;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,MAGrB,CAAC;AAEH;;;;;;;GAOG;AACH,eAAO,MAAM,MAAM,MAGjB,CAAC;AAEH;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS,MAGpB,CAAC;AAEH;;;;;;;;;;GAUG;AACH,eAAO,MAAM,cAAc,MAGzB,CAAC"}
|
|
@@ -1,43 +1,70 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NavigateToPath = exports.GoForward = exports.GoBack = exports.ReloadPage = exports.VisitUrl = void 0;
|
|
3
4
|
const registry_1 = require("../../core/registry");
|
|
5
|
+
// =============================
|
|
6
|
+
// NAVIGATION STEPS
|
|
7
|
+
// =============================
|
|
4
8
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
9
|
+
* Navigates the browser to a specific absolute URL.
|
|
10
|
+
*
|
|
11
|
+
* ```gherkin
|
|
12
|
+
* Given I visit "[https://www.google.com](https://www.google.com)"
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* @param url - The full URL string (must include http/https).
|
|
7
16
|
*/
|
|
8
|
-
(0, registry_1.Step)("I visit {string}", async (page, url) => {
|
|
17
|
+
exports.VisitUrl = (0, registry_1.Step)("I visit {string}", async (page, url) => {
|
|
9
18
|
await page.goto(url);
|
|
10
19
|
console.log(`🌍 Visiting: ${url}`);
|
|
11
20
|
});
|
|
12
21
|
/**
|
|
13
|
-
* Reloads the current page.
|
|
14
|
-
*
|
|
22
|
+
* Reloads the current page (simulates hitting the Refresh button).
|
|
23
|
+
*
|
|
24
|
+
* ```gherkin
|
|
25
|
+
* When I reload the page
|
|
26
|
+
* ```
|
|
15
27
|
*/
|
|
16
|
-
(0, registry_1.Step)("I reload the page", async (page) => {
|
|
28
|
+
exports.ReloadPage = (0, registry_1.Step)("I reload the page", async (page) => {
|
|
17
29
|
await page.reload();
|
|
18
30
|
console.log("🔄 Page reloaded");
|
|
19
31
|
});
|
|
20
32
|
/**
|
|
21
|
-
* Navigates back in browser history.
|
|
22
|
-
*
|
|
33
|
+
* Navigates back one step in the browser history.
|
|
34
|
+
* Simulates clicking the browser's "Back" button.
|
|
35
|
+
*
|
|
36
|
+
* ```gherkin
|
|
37
|
+
* When I go back
|
|
38
|
+
* ```
|
|
23
39
|
*/
|
|
24
|
-
(0, registry_1.Step)("I go back", async (page) => {
|
|
40
|
+
exports.GoBack = (0, registry_1.Step)("I go back", async (page) => {
|
|
25
41
|
await page.goBack();
|
|
26
42
|
console.log("⬅️ Went back");
|
|
27
43
|
});
|
|
28
44
|
/**
|
|
29
|
-
* Navigates forward in browser history.
|
|
30
|
-
*
|
|
45
|
+
* Navigates forward one step in the browser history.
|
|
46
|
+
* Simulates clicking the browser's "Forward" button.
|
|
47
|
+
*
|
|
48
|
+
* ```gherkin
|
|
49
|
+
* When I go forward
|
|
50
|
+
* ```
|
|
31
51
|
*/
|
|
32
|
-
(0, registry_1.Step)("I go forward", async (page) => {
|
|
52
|
+
exports.GoForward = (0, registry_1.Step)("I go forward", async (page) => {
|
|
33
53
|
await page.goForward();
|
|
34
54
|
console.log("➡️ Went forward");
|
|
35
55
|
});
|
|
36
56
|
/**
|
|
37
|
-
* Navigates to a specific path
|
|
38
|
-
*
|
|
57
|
+
* Navigates to a specific path.
|
|
58
|
+
* If a `baseURL` is configured in your Playwright config, this is relative to it.
|
|
59
|
+
* Otherwise, it treats the string as a direct URL.
|
|
60
|
+
*
|
|
61
|
+
* ```gherkin
|
|
62
|
+
* When I navigate to "/dashboard/login"
|
|
63
|
+
* ```
|
|
64
|
+
*
|
|
65
|
+
* @param path - The relative path or URL to navigate to.
|
|
39
66
|
*/
|
|
40
|
-
(0, registry_1.Step)("I navigate to {string}", async (page, path) => {
|
|
67
|
+
exports.NavigateToPath = (0, registry_1.Step)("I navigate to {string}", async (page, path) => {
|
|
41
68
|
await page.goto(path);
|
|
42
69
|
console.log(`🌍 Navigated to path: ${path}`);
|
|
43
70
|
});
|
|
@@ -1,2 +1,56 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Waits for the network to reach an "idle" state.
|
|
3
|
+
* In Playwright terms, this means there are no new network connections for at least 500ms.
|
|
4
|
+
*
|
|
5
|
+
* ```gherkin
|
|
6
|
+
* When I wait for network idle
|
|
7
|
+
* ```
|
|
8
|
+
*
|
|
9
|
+
* @remarks
|
|
10
|
+
* **Warning:** This can be flaky on pages that have constant background polling (e.g., real-time chats, analytics).
|
|
11
|
+
* If the test times out here, consider using `I wait for element to be visible` instead.
|
|
12
|
+
*/
|
|
13
|
+
export declare const WaitForNetworkIdle: void;
|
|
14
|
+
/**
|
|
15
|
+
* Waits for the page to reach a specific load lifecycle event.
|
|
16
|
+
*
|
|
17
|
+
* ```gherkin
|
|
18
|
+
* When I wait for load state "domcontentloaded"
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* @param state - The state to wait for. Options:
|
|
22
|
+
* - `"load"`: Window load event fired.
|
|
23
|
+
* - `"domcontentloaded"`: DOM is ready (scripts might still be loading).
|
|
24
|
+
* - `"networkidle"`: No network connections for 500ms.
|
|
25
|
+
*/
|
|
26
|
+
export declare const WaitForLoadState: void;
|
|
27
|
+
/**
|
|
28
|
+
* Explicitly waits for the currently stored (active) element to become visible.
|
|
29
|
+
* Useful for ensuring animations complete or modals appear before proceeding.
|
|
30
|
+
*
|
|
31
|
+
* ```gherkin
|
|
32
|
+
* When I wait for element to be visible
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export declare const WaitForElementVisible: void;
|
|
36
|
+
/**
|
|
37
|
+
* Explicitly waits for the currently stored (active) element to become hidden or detached from the DOM.
|
|
38
|
+
* Useful for verifying that loading spinners have disappeared.
|
|
39
|
+
*
|
|
40
|
+
* ```gherkin
|
|
41
|
+
* When I wait for element to be hidden
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export declare const WaitForElementHidden: void;
|
|
45
|
+
/**
|
|
46
|
+
* Waits until the page URL contains the specified substring (Regex match).
|
|
47
|
+
* Useful for verifying redirects (e.g., after login).
|
|
48
|
+
*
|
|
49
|
+
* ```gherkin
|
|
50
|
+
* When I wait for URL to contain "dashboard"
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* @param urlPart - The substring to look for in the current URL.
|
|
54
|
+
*/
|
|
55
|
+
export declare const WaitForUrlContain: void;
|
|
2
56
|
//# sourceMappingURL=waits.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"waits.d.ts","sourceRoot":"","sources":["../../../src/backend/actions/waits.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"waits.d.ts","sourceRoot":"","sources":["../../../src/backend/actions/waits.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,kBAAkB,MAG7B,CAAC;AAEH;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,gBAAgB,MAQ3B,CAAC;AAEH;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB,MAIhC,CAAC;AAEH;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB,MAI/B,CAAC;AAEH;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB,MAM7B,CAAC"}
|