playwright-cucumber-ts-steps 1.1.7 → 1.1.9
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 +133 -0
- package/dist/backend/actions/click.d.ts.map +1 -0
- package/dist/backend/actions/click.js +248 -0
- package/dist/backend/actions/find.d.ts +244 -0
- package/dist/backend/actions/find.d.ts.map +1 -0
- package/dist/backend/actions/find.js +415 -0
- package/dist/backend/actions/form.d.ts +38 -0
- package/dist/backend/actions/form.d.ts.map +1 -0
- package/dist/backend/actions/form.js +237 -0
- 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 +54 -0
- package/dist/backend/actions/frames.d.ts.map +1 -0
- package/dist/backend/actions/frames.js +97 -0
- package/dist/backend/actions/index.d.ts +10 -0
- package/dist/backend/actions/index.d.ts.map +1 -1
- package/dist/backend/actions/index.js +10 -0
- package/dist/backend/actions/inputs.d.ts +140 -0
- package/dist/backend/actions/inputs.d.ts.map +1 -0
- package/dist/backend/actions/inputs.js +247 -0
- 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 +71 -0
- package/dist/backend/actions/keyboard.d.ts.map +1 -0
- package/dist/backend/actions/keyboard.js +98 -0
- package/dist/backend/actions/misc.d.ts +135 -0
- package/dist/backend/actions/misc.d.ts.map +1 -0
- package/dist/backend/actions/misc.js +208 -0
- package/dist/backend/actions/mobile.d.ts +75 -0
- package/dist/backend/actions/mobile.d.ts.map +1 -0
- package/dist/backend/actions/mobile.js +148 -0
- package/dist/backend/actions/mouse.d.ts +80 -0
- package/dist/backend/actions/mouse.d.ts.map +1 -0
- package/dist/backend/actions/mouse.js +150 -0
- 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 +61 -10
- package/dist/backend/actions/waits.d.ts +56 -0
- package/dist/backend/actions/waits.d.ts.map +1 -0
- package/dist/backend/actions/waits.js +83 -0
- 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/index.d.ts +1 -0
- package/dist/backend/api/index.d.ts.map +1 -1
- package/dist/backend/api/index.js +1 -0
- 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 +61 -0
- package/dist/backend/api/network.d.ts.map +1 -0
- package/dist/backend/api/network.js +177 -0
- 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 +48 -16
- 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 +166 -12
- 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/backend/utils/state.d.ts +18 -0
- package/dist/backend/utils/state.d.ts.map +1 -0
- package/dist/backend/utils/state.js +84 -0
- package/dist/core/registry.d.ts +14 -14
- package/dist/core/registry.d.ts.map +1 -1
- package/dist/core/registry.js +13 -4
- package/dist/core/runner.d.ts.map +1 -1
- package/dist/core/runner.js +91 -38
- package/package.json +52 -12
|
@@ -1,2 +1,62 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Performs a standard click on the element matching the selector.
|
|
3
|
+
*
|
|
4
|
+
* ```gherkin
|
|
5
|
+
* When I click "#submit-button"
|
|
6
|
+
* ```
|
|
7
|
+
*
|
|
8
|
+
* @param selector - The CSS or XPath selector of the element to click.
|
|
9
|
+
*/
|
|
10
|
+
export declare const ClickElement: void;
|
|
11
|
+
/**
|
|
12
|
+
* Performs a forced click on the element, bypassing visibility checks.
|
|
13
|
+
* Useful for elements obscured by overlays or technically "hidden" but interactable.
|
|
14
|
+
*
|
|
15
|
+
* ```gherkin
|
|
16
|
+
* When I force click "#hidden-checkbox"
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @param selector - The CSS or XPath selector.
|
|
20
|
+
* @remarks
|
|
21
|
+
* **Warning:** Use this sparingly. It disables Playwright's "actionability" checks,
|
|
22
|
+
* meaning it might click an element that a real user technically cannot click.
|
|
23
|
+
*/
|
|
24
|
+
export declare const ForceClickElement: void;
|
|
25
|
+
/**
|
|
26
|
+
* Fills an input field with the specified value.
|
|
27
|
+
*
|
|
28
|
+
* ```gherkin
|
|
29
|
+
* When I fill "#username" with "testuser"
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* @param selector - The CSS selector of the input field.
|
|
33
|
+
* @param value - The text value to type/fill.
|
|
34
|
+
*/
|
|
35
|
+
export declare const FillElement: void;
|
|
36
|
+
/**
|
|
37
|
+
* Presses a specific key on the keyboard globally.
|
|
38
|
+
* Useful for submitting forms (Enter) or closing modals (Escape).
|
|
39
|
+
*
|
|
40
|
+
* ```gherkin
|
|
41
|
+
* When I press "Enter"
|
|
42
|
+
* When I press "Escape"
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* @param key - The name of the key (e.g., "Enter", "Tab", "ArrowDown").
|
|
46
|
+
*/
|
|
47
|
+
export declare const PressKeyGlobal: void;
|
|
48
|
+
/**
|
|
49
|
+
* Pauses the test execution for a fixed amount of time.
|
|
50
|
+
*
|
|
51
|
+
* ```gherkin
|
|
52
|
+
* When I wait for 5000 milliseconds
|
|
53
|
+
* ```
|
|
54
|
+
*
|
|
55
|
+
* @param ms - The duration to wait in milliseconds.
|
|
56
|
+
* @remarks
|
|
57
|
+
* **Anti-Pattern Warning:** Avoid using hard waits whenever possible.
|
|
58
|
+
* They make tests slower and flaky. Prefer `I wait for element to be visible`
|
|
59
|
+
* or `I wait for network idle` instead.
|
|
60
|
+
*/
|
|
61
|
+
export declare const HardWait: void;
|
|
2
62
|
//# sourceMappingURL=interactions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interactions.d.ts","sourceRoot":"","sources":["../../../src/backend/actions/interactions.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"interactions.d.ts","sourceRoot":"","sources":["../../../src/backend/actions/interactions.ts"],"names":[],"mappings":"AAMA;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY,MAEvB,CAAC;AAEH;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,iBAAiB,MAE5B,CAAC;AAEH;;;;;;;;;GASG;AACH,eAAO,MAAM,WAAW,MAEtB,CAAC;AAEH;;;;;;;;;;GAUG;AACH,eAAO,MAAM,cAAc,MAEzB,CAAC;AAEH;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,QAAQ,MAEnB,CAAC"}
|
|
@@ -1,23 +1,78 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HardWait = exports.PressKeyGlobal = exports.FillElement = exports.ForceClickElement = exports.ClickElement = void 0;
|
|
3
4
|
const registry_1 = require("../../core/registry");
|
|
4
|
-
//
|
|
5
|
-
|
|
5
|
+
// =============================
|
|
6
|
+
// BASIC INTERACTIONS (Direct)
|
|
7
|
+
// =============================
|
|
8
|
+
/**
|
|
9
|
+
* Performs a standard click on the element matching the selector.
|
|
10
|
+
*
|
|
11
|
+
* ```gherkin
|
|
12
|
+
* When I click "#submit-button"
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* @param selector - The CSS or XPath selector of the element to click.
|
|
16
|
+
*/
|
|
17
|
+
exports.ClickElement = (0, registry_1.Step)("I click {string}", async (page, selector) => {
|
|
6
18
|
await page.click(selector);
|
|
7
19
|
});
|
|
8
|
-
|
|
9
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Performs a forced click on the element, bypassing visibility checks.
|
|
22
|
+
* Useful for elements obscured by overlays or technically "hidden" but interactable.
|
|
23
|
+
*
|
|
24
|
+
* ```gherkin
|
|
25
|
+
* When I force click "#hidden-checkbox"
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* @param selector - The CSS or XPath selector.
|
|
29
|
+
* @remarks
|
|
30
|
+
* **Warning:** Use this sparingly. It disables Playwright's "actionability" checks,
|
|
31
|
+
* meaning it might click an element that a real user technically cannot click.
|
|
32
|
+
*/
|
|
33
|
+
exports.ForceClickElement = (0, registry_1.Step)("I force click {string}", async (page, selector) => {
|
|
10
34
|
await page.click(selector, { force: true });
|
|
11
35
|
});
|
|
12
|
-
|
|
13
|
-
|
|
36
|
+
/**
|
|
37
|
+
* Fills an input field with the specified value.
|
|
38
|
+
*
|
|
39
|
+
* ```gherkin
|
|
40
|
+
* When I fill "#username" with "testuser"
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* @param selector - The CSS selector of the input field.
|
|
44
|
+
* @param value - The text value to type/fill.
|
|
45
|
+
*/
|
|
46
|
+
exports.FillElement = (0, registry_1.Step)("I fill {string} with {string}", async (page, selector, value) => {
|
|
14
47
|
await page.fill(selector, value);
|
|
15
48
|
});
|
|
16
|
-
|
|
17
|
-
|
|
49
|
+
/**
|
|
50
|
+
* Presses a specific key on the keyboard globally.
|
|
51
|
+
* Useful for submitting forms (Enter) or closing modals (Escape).
|
|
52
|
+
*
|
|
53
|
+
* ```gherkin
|
|
54
|
+
* When I press "Enter"
|
|
55
|
+
* When I press "Escape"
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
58
|
+
* @param key - The name of the key (e.g., "Enter", "Tab", "ArrowDown").
|
|
59
|
+
*/
|
|
60
|
+
exports.PressKeyGlobal = (0, registry_1.Step)("I press {string}", async (page, key) => {
|
|
18
61
|
await page.keyboard.press(key);
|
|
19
62
|
});
|
|
20
|
-
|
|
21
|
-
|
|
63
|
+
/**
|
|
64
|
+
* Pauses the test execution for a fixed amount of time.
|
|
65
|
+
*
|
|
66
|
+
* ```gherkin
|
|
67
|
+
* When I wait for 5000 milliseconds
|
|
68
|
+
* ```
|
|
69
|
+
*
|
|
70
|
+
* @param ms - The duration to wait in milliseconds.
|
|
71
|
+
* @remarks
|
|
72
|
+
* **Anti-Pattern Warning:** Avoid using hard waits whenever possible.
|
|
73
|
+
* They make tests slower and flaky. Prefer `I wait for element to be visible`
|
|
74
|
+
* or `I wait for network idle` instead.
|
|
75
|
+
*/
|
|
76
|
+
exports.HardWait = (0, registry_1.Step)("I wait for {int} milliseconds", async (page, ms) => {
|
|
22
77
|
await page.waitForTimeout(ms);
|
|
23
78
|
});
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Presses a specific key globally on the page.
|
|
3
|
+
* This simulates a user pressing a key without targeting any specific element,
|
|
4
|
+
* although the event will be delivered to the currently focused element.
|
|
5
|
+
*
|
|
6
|
+
* ```gherkin
|
|
7
|
+
* When I press key "Enter"
|
|
8
|
+
* When I press key "Escape"
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
11
|
+
* @param key - The name of the key (e.g., "Enter", "Tab", "ArrowDown").
|
|
12
|
+
*/
|
|
13
|
+
export declare const PressKey: void;
|
|
14
|
+
/**
|
|
15
|
+
* Presses a specific key targeted at the currently stored (active) element.
|
|
16
|
+
* This ensures the element is focused before the key is pressed.
|
|
17
|
+
*
|
|
18
|
+
* ```gherkin
|
|
19
|
+
* When I press key "Enter" on element
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @param key - The name of the key to press.
|
|
23
|
+
*/
|
|
24
|
+
export declare const PressKeyOnElement: void;
|
|
25
|
+
/**
|
|
26
|
+
* Types text globally using the keyboard, character by character.
|
|
27
|
+
* This acts like a real user typing on a physical keyboard, sending
|
|
28
|
+
* `keydown`, `keypress`, and `keyup` events for each character.
|
|
29
|
+
*
|
|
30
|
+
* ```gherkin
|
|
31
|
+
* When I press keys "Hello World"
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* @param text - The string of text to type.
|
|
35
|
+
*/
|
|
36
|
+
export declare const TypeKeysGlobal: void;
|
|
37
|
+
/**
|
|
38
|
+
* Performs a specific keyboard shortcut or combination.
|
|
39
|
+
* Playwright supports combinations using the "+" delimiter.
|
|
40
|
+
*
|
|
41
|
+
* ```gherkin
|
|
42
|
+
* When I press shortcut "Control+C"
|
|
43
|
+
* When I press shortcut "Meta+Shift+P"
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
* @param shortcut - The key combination string (e.g., "Control+V").
|
|
47
|
+
*/
|
|
48
|
+
export declare const PressShortcut: void;
|
|
49
|
+
/**
|
|
50
|
+
* Holds down a specific key.
|
|
51
|
+
* Useful for operations like multiple selections (holding Shift) or drag-and-drop.
|
|
52
|
+
* **Important:** You must release the key later using `I release key`.
|
|
53
|
+
*
|
|
54
|
+
* ```gherkin
|
|
55
|
+
* When I hold down key "Shift"
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
58
|
+
* @param key - The name of the key to hold down.
|
|
59
|
+
*/
|
|
60
|
+
export declare const HoldDownKey: void;
|
|
61
|
+
/**
|
|
62
|
+
* Releases a specific key that was previously held down.
|
|
63
|
+
*
|
|
64
|
+
* ```gherkin
|
|
65
|
+
* When I release key "Shift"
|
|
66
|
+
* ```
|
|
67
|
+
*
|
|
68
|
+
* @param key - The name of the key to release.
|
|
69
|
+
*/
|
|
70
|
+
export declare const ReleaseKey: void;
|
|
71
|
+
//# sourceMappingURL=keyboard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keyboard.d.ts","sourceRoot":"","sources":["../../../src/backend/actions/keyboard.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,QAAQ,MAGnB,CAAC;AAEH;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB,MAI5B,CAAC;AAEH;;;;;;;;;;GAUG;AACH,eAAO,MAAM,cAAc,MAGzB,CAAC;AAEH;;;;;;;;;;GAUG;AACH,eAAO,MAAM,aAAa,MAIxB,CAAC;AAEH;;;;;;;;;;GAUG;AACH,eAAO,MAAM,WAAW,MAGtB,CAAC;AAEH;;;;;;;;GAQG;AACH,eAAO,MAAM,UAAU,MAGrB,CAAC"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ReleaseKey = exports.HoldDownKey = exports.PressShortcut = exports.TypeKeysGlobal = exports.PressKeyOnElement = exports.PressKey = void 0;
|
|
4
|
+
const registry_1 = require("../../core/registry");
|
|
5
|
+
const state_1 = require("../utils/state");
|
|
6
|
+
// ==================================================
|
|
7
|
+
// KEYBOARD INTERACTIONS
|
|
8
|
+
// ==================================================
|
|
9
|
+
/**
|
|
10
|
+
* Presses a specific key globally on the page.
|
|
11
|
+
* This simulates a user pressing a key without targeting any specific element,
|
|
12
|
+
* although the event will be delivered to the currently focused element.
|
|
13
|
+
*
|
|
14
|
+
* ```gherkin
|
|
15
|
+
* When I press key "Enter"
|
|
16
|
+
* When I press key "Escape"
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @param key - The name of the key (e.g., "Enter", "Tab", "ArrowDown").
|
|
20
|
+
*/
|
|
21
|
+
exports.PressKey = (0, registry_1.Step)("I press key {string}", async (page, key) => {
|
|
22
|
+
await page.keyboard.press(key);
|
|
23
|
+
console.log(`⌨️ Pressed key: "${key}"`);
|
|
24
|
+
});
|
|
25
|
+
/**
|
|
26
|
+
* Presses a specific key targeted at the currently stored (active) element.
|
|
27
|
+
* This ensures the element is focused before the key is pressed.
|
|
28
|
+
*
|
|
29
|
+
* ```gherkin
|
|
30
|
+
* When I press key "Enter" on element
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* @param key - The name of the key to press.
|
|
34
|
+
*/
|
|
35
|
+
exports.PressKeyOnElement = (0, registry_1.Step)("I press key {string} on element", async (page, key) => {
|
|
36
|
+
const element = (0, state_1.getActiveElement)(page);
|
|
37
|
+
await element.press(key);
|
|
38
|
+
console.log(`⌨️ Pressed key "${key}" on stored element`);
|
|
39
|
+
});
|
|
40
|
+
/**
|
|
41
|
+
* Types text globally using the keyboard, character by character.
|
|
42
|
+
* This acts like a real user typing on a physical keyboard, sending
|
|
43
|
+
* `keydown`, `keypress`, and `keyup` events for each character.
|
|
44
|
+
*
|
|
45
|
+
* ```gherkin
|
|
46
|
+
* When I press keys "Hello World"
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* @param text - The string of text to type.
|
|
50
|
+
*/
|
|
51
|
+
exports.TypeKeysGlobal = (0, registry_1.Step)("I press keys {string}", async (page, text) => {
|
|
52
|
+
await page.keyboard.type(text);
|
|
53
|
+
console.log(`⌨️ Typed keys: "${text}"`);
|
|
54
|
+
});
|
|
55
|
+
/**
|
|
56
|
+
* Performs a specific keyboard shortcut or combination.
|
|
57
|
+
* Playwright supports combinations using the "+" delimiter.
|
|
58
|
+
*
|
|
59
|
+
* ```gherkin
|
|
60
|
+
* When I press shortcut "Control+C"
|
|
61
|
+
* When I press shortcut "Meta+Shift+P"
|
|
62
|
+
* ```
|
|
63
|
+
*
|
|
64
|
+
* @param shortcut - The key combination string (e.g., "Control+V").
|
|
65
|
+
*/
|
|
66
|
+
exports.PressShortcut = (0, registry_1.Step)("I press shortcut {string}", async (page, shortcut) => {
|
|
67
|
+
// Playwright's keyboard.press supports combinations like "Control+KeyC"
|
|
68
|
+
await page.keyboard.press(shortcut);
|
|
69
|
+
console.log(`⌨️ Performed shortcut: "${shortcut}"`);
|
|
70
|
+
});
|
|
71
|
+
/**
|
|
72
|
+
* Holds down a specific key.
|
|
73
|
+
* Useful for operations like multiple selections (holding Shift) or drag-and-drop.
|
|
74
|
+
* **Important:** You must release the key later using `I release key`.
|
|
75
|
+
*
|
|
76
|
+
* ```gherkin
|
|
77
|
+
* When I hold down key "Shift"
|
|
78
|
+
* ```
|
|
79
|
+
*
|
|
80
|
+
* @param key - The name of the key to hold down.
|
|
81
|
+
*/
|
|
82
|
+
exports.HoldDownKey = (0, registry_1.Step)("I hold down key {string}", async (page, key) => {
|
|
83
|
+
await page.keyboard.down(key);
|
|
84
|
+
console.log(`⬇️ Holding down key: "${key}"`);
|
|
85
|
+
});
|
|
86
|
+
/**
|
|
87
|
+
* Releases a specific key that was previously held down.
|
|
88
|
+
*
|
|
89
|
+
* ```gherkin
|
|
90
|
+
* When I release key "Shift"
|
|
91
|
+
* ```
|
|
92
|
+
*
|
|
93
|
+
* @param key - The name of the key to release.
|
|
94
|
+
*/
|
|
95
|
+
exports.ReleaseKey = (0, registry_1.Step)("I release key {string}", async (page, key) => {
|
|
96
|
+
await page.keyboard.up(key);
|
|
97
|
+
console.log(`⬆️ Released key: "${key}"`);
|
|
98
|
+
});
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pauses execution for a specified number of milliseconds.
|
|
3
|
+
*
|
|
4
|
+
* ```gherkin
|
|
5
|
+
* When I wait for 1000 milliseconds
|
|
6
|
+
* ```
|
|
7
|
+
*
|
|
8
|
+
* @param ms - The duration to wait in milliseconds.
|
|
9
|
+
* @remarks
|
|
10
|
+
* **Note:** Use sparse waits to avoid flaky tests. Prefer explicit waits like `I wait for element to be visible`.
|
|
11
|
+
*/
|
|
12
|
+
export declare const WaitMilliseconds: void;
|
|
13
|
+
/**
|
|
14
|
+
* Pauses execution for a specified number of seconds.
|
|
15
|
+
*
|
|
16
|
+
* ```gherkin
|
|
17
|
+
* When I wait for 5 seconds
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @param seconds - The duration to wait in seconds.
|
|
21
|
+
*/
|
|
22
|
+
export declare const WaitSeconds: void;
|
|
23
|
+
/**
|
|
24
|
+
* Pauses the test execution and opens the Playwright Inspector.
|
|
25
|
+
* This is incredibly useful for manual debugging during a test run.
|
|
26
|
+
* You can inspect elements, view console logs, and step through execution.
|
|
27
|
+
*
|
|
28
|
+
* ```gherkin
|
|
29
|
+
* When I pause
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare const PauseExecution: void;
|
|
33
|
+
/**
|
|
34
|
+
* Alias for `I pause`. Pauses execution for debugging.
|
|
35
|
+
*
|
|
36
|
+
* ```gherkin
|
|
37
|
+
* When I debug
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export declare const DebugExecution: void;
|
|
41
|
+
/**
|
|
42
|
+
* Prints a custom message to the console logs.
|
|
43
|
+
* Useful for marking sections of a test output or debugging variable states.
|
|
44
|
+
*
|
|
45
|
+
* ```gherkin
|
|
46
|
+
* When I log "Starting Login Flow"
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* @param message - The string to log.
|
|
50
|
+
*/
|
|
51
|
+
export declare const LogMessage: void;
|
|
52
|
+
/**
|
|
53
|
+
* Focuses on the currently stored (active) element.
|
|
54
|
+
*
|
|
55
|
+
* ```gherkin
|
|
56
|
+
* When I focus
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export declare const FocusElement: void;
|
|
60
|
+
/**
|
|
61
|
+
* Blurs (removes focus from) the currently stored element.
|
|
62
|
+
*
|
|
63
|
+
* ```gherkin
|
|
64
|
+
* When I blur
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
export declare const BlurElement: void;
|
|
68
|
+
/**
|
|
69
|
+
* Sets a cookie for the current context/URL.
|
|
70
|
+
*
|
|
71
|
+
* ```gherkin
|
|
72
|
+
* When I set cookie "session_id" to "12345ABC"
|
|
73
|
+
* ```
|
|
74
|
+
*
|
|
75
|
+
* @param name - The name of the cookie.
|
|
76
|
+
* @param value - The value of the cookie.
|
|
77
|
+
*/
|
|
78
|
+
export declare const SetCookie: void;
|
|
79
|
+
/**
|
|
80
|
+
* Clears all cookies for the current browser context.
|
|
81
|
+
*
|
|
82
|
+
* ```gherkin
|
|
83
|
+
* When I clear all cookies
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
export declare const ClearAllCookies: void;
|
|
87
|
+
/**
|
|
88
|
+
* Sets an item in Local Storage.
|
|
89
|
+
*
|
|
90
|
+
* ```gherkin
|
|
91
|
+
* When I set local storage item "theme" to "dark"
|
|
92
|
+
* ```
|
|
93
|
+
*
|
|
94
|
+
* @param key - The local storage key.
|
|
95
|
+
* @param value - The value to store.
|
|
96
|
+
*/
|
|
97
|
+
export declare const SetLocalStorageItem: void;
|
|
98
|
+
/**
|
|
99
|
+
* Retrieves a Local Storage item and logs it to the console.
|
|
100
|
+
*
|
|
101
|
+
* ```gherkin
|
|
102
|
+
* When I get local storage item "authToken"
|
|
103
|
+
* ```
|
|
104
|
+
*
|
|
105
|
+
* @param key - The key of the item to retrieve.
|
|
106
|
+
*/
|
|
107
|
+
export declare const GetLocalStorageItem: void;
|
|
108
|
+
/**
|
|
109
|
+
* Clears all data from Local Storage.
|
|
110
|
+
*
|
|
111
|
+
* ```gherkin
|
|
112
|
+
* When I clear local storage
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
115
|
+
export declare const ClearLocalStorage: void;
|
|
116
|
+
/**
|
|
117
|
+
* Sets an item in Session Storage.
|
|
118
|
+
*
|
|
119
|
+
* ```gherkin
|
|
120
|
+
* When I set session storage item "user_role" to "admin"
|
|
121
|
+
* ```
|
|
122
|
+
*
|
|
123
|
+
* @param key - The session storage key.
|
|
124
|
+
* @param value - The value to store.
|
|
125
|
+
*/
|
|
126
|
+
export declare const SetSessionStorageItem: void;
|
|
127
|
+
/**
|
|
128
|
+
* Clears all data from Session Storage.
|
|
129
|
+
*
|
|
130
|
+
* ```gherkin
|
|
131
|
+
* When I clear session storage
|
|
132
|
+
* ```
|
|
133
|
+
*/
|
|
134
|
+
export declare const ClearSessionStorage: void;
|
|
135
|
+
//# sourceMappingURL=misc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"misc.d.ts","sourceRoot":"","sources":["../../../src/backend/actions/misc.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,gBAAgB,MAG3B,CAAC;AAEH;;;;;;;;GAQG;AACH,eAAO,MAAM,WAAW,MAGtB,CAAC;AAMH;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,MAGzB,CAAC;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,MAGzB,CAAC;AAEH;;;;;;;;;GASG;AACH,eAAO,MAAM,UAAU,MAErB,CAAC;AAMH;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,MAIvB,CAAC;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,MAOtB,CAAC;AAMH;;;;;;;;;GASG;AACH,eAAO,MAAM,SAAS,MAMpB,CAAC;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,MAI1B,CAAC;AAEH;;;;;;;;;GASG;AACH,eAAO,MAAM,mBAAmB,MAS/B,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,mBAAmB,MAG9B,CAAC;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,MAG5B,CAAC;AAEH;;;;;;;;;GASG;AACH,eAAO,MAAM,qBAAqB,MASjC,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,MAG9B,CAAC"}
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ClearSessionStorage = exports.SetSessionStorageItem = exports.ClearLocalStorage = exports.GetLocalStorageItem = exports.SetLocalStorageItem = exports.ClearAllCookies = exports.SetCookie = exports.BlurElement = exports.FocusElement = exports.LogMessage = exports.DebugExecution = exports.PauseExecution = exports.WaitSeconds = exports.WaitMilliseconds = void 0;
|
|
4
|
+
const registry_1 = require("../../core/registry");
|
|
5
|
+
const state_1 = require("../utils/state");
|
|
6
|
+
// ==================================================
|
|
7
|
+
// 1. TIMING & WAITS
|
|
8
|
+
// ==================================================
|
|
9
|
+
/**
|
|
10
|
+
* Pauses execution for a specified number of milliseconds.
|
|
11
|
+
*
|
|
12
|
+
* ```gherkin
|
|
13
|
+
* When I wait for 1000 milliseconds
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @param ms - The duration to wait in milliseconds.
|
|
17
|
+
* @remarks
|
|
18
|
+
* **Note:** Use sparse waits to avoid flaky tests. Prefer explicit waits like `I wait for element to be visible`.
|
|
19
|
+
*/
|
|
20
|
+
exports.WaitMilliseconds = (0, registry_1.Step)("I wait for {int} milliseconds", async (page, ms) => {
|
|
21
|
+
await page.waitForTimeout(ms);
|
|
22
|
+
console.log(`⏳ Waited for ${ms}ms`);
|
|
23
|
+
});
|
|
24
|
+
/**
|
|
25
|
+
* Pauses execution for a specified number of seconds.
|
|
26
|
+
*
|
|
27
|
+
* ```gherkin
|
|
28
|
+
* When I wait for 5 seconds
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @param seconds - The duration to wait in seconds.
|
|
32
|
+
*/
|
|
33
|
+
exports.WaitSeconds = (0, registry_1.Step)("I wait for {int} seconds", async (page, seconds) => {
|
|
34
|
+
await page.waitForTimeout(seconds * 1000);
|
|
35
|
+
console.log(`⏳ Waited for ${seconds}s`);
|
|
36
|
+
});
|
|
37
|
+
// ==================================================
|
|
38
|
+
// 2. DEBUGGING
|
|
39
|
+
// ==================================================
|
|
40
|
+
/**
|
|
41
|
+
* Pauses the test execution and opens the Playwright Inspector.
|
|
42
|
+
* This is incredibly useful for manual debugging during a test run.
|
|
43
|
+
* You can inspect elements, view console logs, and step through execution.
|
|
44
|
+
*
|
|
45
|
+
* ```gherkin
|
|
46
|
+
* When I pause
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
exports.PauseExecution = (0, registry_1.Step)("I pause", async (page) => {
|
|
50
|
+
console.log("⏸️ Pausing test execution...");
|
|
51
|
+
await page.pause();
|
|
52
|
+
});
|
|
53
|
+
/**
|
|
54
|
+
* Alias for `I pause`. Pauses execution for debugging.
|
|
55
|
+
*
|
|
56
|
+
* ```gherkin
|
|
57
|
+
* When I debug
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
exports.DebugExecution = (0, registry_1.Step)("I debug", async (page) => {
|
|
61
|
+
console.log("🐞 Debugging...");
|
|
62
|
+
await page.pause();
|
|
63
|
+
});
|
|
64
|
+
/**
|
|
65
|
+
* Prints a custom message to the console logs.
|
|
66
|
+
* Useful for marking sections of a test output or debugging variable states.
|
|
67
|
+
*
|
|
68
|
+
* ```gherkin
|
|
69
|
+
* When I log "Starting Login Flow"
|
|
70
|
+
* ```
|
|
71
|
+
*
|
|
72
|
+
* @param message - The string to log.
|
|
73
|
+
*/
|
|
74
|
+
exports.LogMessage = (0, registry_1.Step)("I log {string}", async (page, message) => {
|
|
75
|
+
console.log(`📝 LOG: ${message}`);
|
|
76
|
+
});
|
|
77
|
+
// ==================================================
|
|
78
|
+
// 3. FOCUS & BLUR
|
|
79
|
+
// ==================================================
|
|
80
|
+
/**
|
|
81
|
+
* Focuses on the currently stored (active) element.
|
|
82
|
+
*
|
|
83
|
+
* ```gherkin
|
|
84
|
+
* When I focus
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
exports.FocusElement = (0, registry_1.Step)("I focus", async (page) => {
|
|
88
|
+
const element = (0, state_1.getActiveElement)(page);
|
|
89
|
+
await element.focus();
|
|
90
|
+
console.log("👀 Focused on stored element");
|
|
91
|
+
});
|
|
92
|
+
/**
|
|
93
|
+
* Blurs (removes focus from) the currently stored element.
|
|
94
|
+
*
|
|
95
|
+
* ```gherkin
|
|
96
|
+
* When I blur
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
|
+
exports.BlurElement = (0, registry_1.Step)("I blur", async (page) => {
|
|
100
|
+
const element = (0, state_1.getActiveElement)(page);
|
|
101
|
+
// Playwright doesn't have a direct .blur(), so we use JS evaluation
|
|
102
|
+
await element.evaluate((el) => {
|
|
103
|
+
if (el instanceof HTMLElement)
|
|
104
|
+
el.blur();
|
|
105
|
+
});
|
|
106
|
+
console.log("🌫️ Blurred stored element");
|
|
107
|
+
});
|
|
108
|
+
// ==================================================
|
|
109
|
+
// 4. BROWSER STORAGE (Cookies / Local Storage)
|
|
110
|
+
// ==================================================
|
|
111
|
+
/**
|
|
112
|
+
* Sets a cookie for the current context/URL.
|
|
113
|
+
*
|
|
114
|
+
* ```gherkin
|
|
115
|
+
* When I set cookie "session_id" to "12345ABC"
|
|
116
|
+
* ```
|
|
117
|
+
*
|
|
118
|
+
* @param name - The name of the cookie.
|
|
119
|
+
* @param value - The value of the cookie.
|
|
120
|
+
*/
|
|
121
|
+
exports.SetCookie = (0, registry_1.Step)("I set cookie {string} to {string}", async (page, name, value) => {
|
|
122
|
+
const context = page.context();
|
|
123
|
+
const url = page.url();
|
|
124
|
+
// We need a domain or url to set cookies. We use the current page URL.
|
|
125
|
+
await context.addCookies([{ name, value, url }]);
|
|
126
|
+
console.log(`🍪 Set cookie "${name}"`);
|
|
127
|
+
});
|
|
128
|
+
/**
|
|
129
|
+
* Clears all cookies for the current browser context.
|
|
130
|
+
*
|
|
131
|
+
* ```gherkin
|
|
132
|
+
* When I clear all cookies
|
|
133
|
+
* ```
|
|
134
|
+
*/
|
|
135
|
+
exports.ClearAllCookies = (0, registry_1.Step)("I clear all cookies", async (page) => {
|
|
136
|
+
const context = page.context();
|
|
137
|
+
await context.clearCookies();
|
|
138
|
+
console.log("🍪 Cleared all cookies");
|
|
139
|
+
});
|
|
140
|
+
/**
|
|
141
|
+
* Sets an item in Local Storage.
|
|
142
|
+
*
|
|
143
|
+
* ```gherkin
|
|
144
|
+
* When I set local storage item "theme" to "dark"
|
|
145
|
+
* ```
|
|
146
|
+
*
|
|
147
|
+
* @param key - The local storage key.
|
|
148
|
+
* @param value - The value to store.
|
|
149
|
+
*/
|
|
150
|
+
exports.SetLocalStorageItem = (0, registry_1.Step)("I set local storage item {string} to {string}", async (page, key, value) => {
|
|
151
|
+
await page.evaluate(({ k, v }) => localStorage.setItem(k, v), {
|
|
152
|
+
k: key,
|
|
153
|
+
v: value,
|
|
154
|
+
});
|
|
155
|
+
console.log(`📦 Set local storage "${key}" = "${value}"`);
|
|
156
|
+
});
|
|
157
|
+
/**
|
|
158
|
+
* Retrieves a Local Storage item and logs it to the console.
|
|
159
|
+
*
|
|
160
|
+
* ```gherkin
|
|
161
|
+
* When I get local storage item "authToken"
|
|
162
|
+
* ```
|
|
163
|
+
*
|
|
164
|
+
* @param key - The key of the item to retrieve.
|
|
165
|
+
*/
|
|
166
|
+
exports.GetLocalStorageItem = (0, registry_1.Step)("I get local storage item {string}", async (page, key) => {
|
|
167
|
+
const value = await page.evaluate((k) => localStorage.getItem(k), key);
|
|
168
|
+
console.log(`📦 Local Storage "${key}": ${value}`);
|
|
169
|
+
});
|
|
170
|
+
/**
|
|
171
|
+
* Clears all data from Local Storage.
|
|
172
|
+
*
|
|
173
|
+
* ```gherkin
|
|
174
|
+
* When I clear local storage
|
|
175
|
+
* ```
|
|
176
|
+
*/
|
|
177
|
+
exports.ClearLocalStorage = (0, registry_1.Step)("I clear local storage", async (page) => {
|
|
178
|
+
await page.evaluate(() => localStorage.clear());
|
|
179
|
+
console.log("📦 Cleared local storage");
|
|
180
|
+
});
|
|
181
|
+
/**
|
|
182
|
+
* Sets an item in Session Storage.
|
|
183
|
+
*
|
|
184
|
+
* ```gherkin
|
|
185
|
+
* When I set session storage item "user_role" to "admin"
|
|
186
|
+
* ```
|
|
187
|
+
*
|
|
188
|
+
* @param key - The session storage key.
|
|
189
|
+
* @param value - The value to store.
|
|
190
|
+
*/
|
|
191
|
+
exports.SetSessionStorageItem = (0, registry_1.Step)("I set session storage item {string} to {string}", async (page, key, value) => {
|
|
192
|
+
await page.evaluate(({ k, v }) => sessionStorage.setItem(k, v), {
|
|
193
|
+
k: key,
|
|
194
|
+
v: value,
|
|
195
|
+
});
|
|
196
|
+
console.log(`📦 Set session storage "${key}" = "${value}"`);
|
|
197
|
+
});
|
|
198
|
+
/**
|
|
199
|
+
* Clears all data from Session Storage.
|
|
200
|
+
*
|
|
201
|
+
* ```gherkin
|
|
202
|
+
* When I clear session storage
|
|
203
|
+
* ```
|
|
204
|
+
*/
|
|
205
|
+
exports.ClearSessionStorage = (0, registry_1.Step)("I clear session storage", async (page) => {
|
|
206
|
+
await page.evaluate(() => sessionStorage.clear());
|
|
207
|
+
console.log("📦 Cleared session storage");
|
|
208
|
+
});
|