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
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Chetachi (Paschal) Enyimiri
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Clicks on the currently stored (active) element.
|
|
3
|
+
*
|
|
4
|
+
* ```gherkin
|
|
5
|
+
* When I click
|
|
6
|
+
* ```
|
|
7
|
+
*/
|
|
8
|
+
export declare const ClickStoredElement: void;
|
|
9
|
+
/**
|
|
10
|
+
* Clicks on an element matching the given CSS/XPath selector.
|
|
11
|
+
*
|
|
12
|
+
* ```gherkin
|
|
13
|
+
* When I click on element {string}
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @param selector - The CSS or XPath selector of the element.
|
|
17
|
+
*/
|
|
18
|
+
export declare const ClickElementBySelector: void;
|
|
19
|
+
/**
|
|
20
|
+
* Clicks on a button role element with the specified label.
|
|
21
|
+
*
|
|
22
|
+
* ```gherkin
|
|
23
|
+
* When I click on button {string}
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @param label - The visible text or accessible name of the button.
|
|
27
|
+
*/
|
|
28
|
+
export declare const ClickButtonByLabel: void;
|
|
29
|
+
/**
|
|
30
|
+
* Clicks on a link role element with the specified text.
|
|
31
|
+
*
|
|
32
|
+
* ```gherkin
|
|
33
|
+
* When I click on link {string}
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @param text - The visible text of the link.
|
|
37
|
+
*/
|
|
38
|
+
export declare const ClickLinkByText: void;
|
|
39
|
+
/**
|
|
40
|
+
* Clicks on a form label element.
|
|
41
|
+
*
|
|
42
|
+
* ```gherkin
|
|
43
|
+
* When I click on label {string}
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
* @param labelText - The text content of the label element.
|
|
47
|
+
*/
|
|
48
|
+
export declare const ClickLabelByText: void;
|
|
49
|
+
/**
|
|
50
|
+
* Clicks on the first visible element containing the specified text (partial match).
|
|
51
|
+
*
|
|
52
|
+
* ```gherkin
|
|
53
|
+
* When I click on text {string}
|
|
54
|
+
* ```
|
|
55
|
+
*
|
|
56
|
+
* @param rawText - The text to look for. Use "@alias" to reference a stored variable.
|
|
57
|
+
*/
|
|
58
|
+
export declare const ClickByText: void;
|
|
59
|
+
/**
|
|
60
|
+
* Clicks on an element containing the EXACT specified text.
|
|
61
|
+
*
|
|
62
|
+
* ```gherkin
|
|
63
|
+
* When I click on exact text {string}
|
|
64
|
+
* ```
|
|
65
|
+
*
|
|
66
|
+
* @param exactText - The exact text content to match.
|
|
67
|
+
*/
|
|
68
|
+
export declare const ClickByExactText: void;
|
|
69
|
+
/**
|
|
70
|
+
* Clicks on a selector provided via Regex match.
|
|
71
|
+
*
|
|
72
|
+
* ```gherkin
|
|
73
|
+
* I click on selector "#btn-id"
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
export declare const ClickByRegexSelector: void;
|
|
77
|
+
/**
|
|
78
|
+
* Iterates through ALL currently stored active elements and clicks them one by one.
|
|
79
|
+
*
|
|
80
|
+
* ```gherkin
|
|
81
|
+
* When I click all
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
export declare const ClickAllStoredElements: void;
|
|
85
|
+
/**
|
|
86
|
+
* Double-clicks on the currently stored (active) element.
|
|
87
|
+
*
|
|
88
|
+
* ```gherkin
|
|
89
|
+
* When I double click
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
export declare const DoubleClickStoredElement: void;
|
|
93
|
+
/**
|
|
94
|
+
* Double-clicks on the first element containing the specified text.
|
|
95
|
+
*
|
|
96
|
+
* ```gherkin
|
|
97
|
+
* When I double click on text {string}
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
export declare const DoubleClickByText: void;
|
|
101
|
+
/**
|
|
102
|
+
* Double-clicks at specific X, Y coordinates on the page.
|
|
103
|
+
*
|
|
104
|
+
* ```gherkin
|
|
105
|
+
* When I double click position {int} {int}
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
export declare const DoubleClickPosition: void;
|
|
109
|
+
/**
|
|
110
|
+
* Right-clicks (Context Click) on the currently stored element.
|
|
111
|
+
*
|
|
112
|
+
* ```gherkin
|
|
113
|
+
* When I right click
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
export declare const RightClickStoredElement: void;
|
|
117
|
+
/**
|
|
118
|
+
* Right-clicks on the first element containing the specified text.
|
|
119
|
+
*
|
|
120
|
+
* ```gherkin
|
|
121
|
+
* When I right click on text {string}
|
|
122
|
+
* ```
|
|
123
|
+
*/
|
|
124
|
+
export declare const RightClickByText: void;
|
|
125
|
+
/**
|
|
126
|
+
* Right-clicks at specific X, Y coordinates on the page.
|
|
127
|
+
*
|
|
128
|
+
* ```gherkin
|
|
129
|
+
* When I right click position {int} {int}
|
|
130
|
+
* ```
|
|
131
|
+
*/
|
|
132
|
+
export declare const RightClickPosition: void;
|
|
133
|
+
//# sourceMappingURL=click.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"click.d.ts","sourceRoot":"","sources":["../../../src/backend/actions/click.ts"],"names":[],"mappings":"AAaA;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,MAK7B,CAAC;AAEH;;;;;;;;GAQG;AACH,eAAO,MAAM,sBAAsB,MASlC,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,MAM7B,CAAC;AAEH;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe,MAM1B,CAAC;AAEH;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB,MAS5B,CAAC;AAMF;;;;;;;;GAQG;AACH,eAAO,MAAM,WAAW,MAoBtB,CAAC;AAEH;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB,MAW5B,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,MAQhC,CAAC;AAMF;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,MAcjC,CAAC;AAMH;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB,MAKnC,CAAC;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,MAQ7B,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,MAO/B,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,uBAAuB,MAKlC,CAAC;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,MAQ5B,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,MAO9B,CAAC"}
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RightClickPosition = exports.RightClickByText = exports.RightClickStoredElement = exports.DoubleClickPosition = exports.DoubleClickByText = exports.DoubleClickStoredElement = exports.ClickAllStoredElements = exports.ClickByRegexSelector = exports.ClickByExactText = exports.ClickByText = exports.ClickLabelByText = exports.ClickLinkByText = exports.ClickButtonByLabel = exports.ClickElementBySelector = exports.ClickStoredElement = void 0;
|
|
4
|
+
const registry_1 = require("../../core/registry");
|
|
5
|
+
const state_1 = require("../utils/state");
|
|
6
|
+
// ==================================================
|
|
7
|
+
// 1. STANDARD CLICKS
|
|
8
|
+
// ==================================================
|
|
9
|
+
/**
|
|
10
|
+
* Clicks on the currently stored (active) element.
|
|
11
|
+
*
|
|
12
|
+
* ```gherkin
|
|
13
|
+
* When I click
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
exports.ClickStoredElement = (0, registry_1.Step)("I click", async (page, table) => {
|
|
17
|
+
const options = (0, state_1.parseClickOptions)(table);
|
|
18
|
+
const element = (0, state_1.getActiveElement)(page);
|
|
19
|
+
await element.click(options);
|
|
20
|
+
console.log("🖱️ Clicked on stored element");
|
|
21
|
+
});
|
|
22
|
+
/**
|
|
23
|
+
* Clicks on an element matching the given CSS/XPath selector.
|
|
24
|
+
*
|
|
25
|
+
* ```gherkin
|
|
26
|
+
* When I click on element {string}
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* @param selector - The CSS or XPath selector of the element.
|
|
30
|
+
*/
|
|
31
|
+
exports.ClickElementBySelector = (0, registry_1.Step)("I click on element {string}", async (page, selector, table) => {
|
|
32
|
+
const options = (0, state_1.parseClickOptions)(table);
|
|
33
|
+
const element = page.locator(selector);
|
|
34
|
+
await element.click(options);
|
|
35
|
+
(0, state_1.setActiveElement)(page, element);
|
|
36
|
+
console.log(`🖱️ Clicked on element "${selector}"`);
|
|
37
|
+
});
|
|
38
|
+
/**
|
|
39
|
+
* Clicks on a button role element with the specified label.
|
|
40
|
+
*
|
|
41
|
+
* ```gherkin
|
|
42
|
+
* When I click on button {string}
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* @param label - The visible text or accessible name of the button.
|
|
46
|
+
*/
|
|
47
|
+
exports.ClickButtonByLabel = (0, registry_1.Step)("I click on button {string}", async (page, label, table) => {
|
|
48
|
+
const options = (0, state_1.parseClickOptions)(table);
|
|
49
|
+
const button = page.getByRole("button", { name: label });
|
|
50
|
+
await button.click(options);
|
|
51
|
+
(0, state_1.setActiveElement)(page, button);
|
|
52
|
+
console.log(`🖱️ Clicked on button "${label}"`);
|
|
53
|
+
});
|
|
54
|
+
/**
|
|
55
|
+
* Clicks on a link role element with the specified text.
|
|
56
|
+
*
|
|
57
|
+
* ```gherkin
|
|
58
|
+
* When I click on link {string}
|
|
59
|
+
* ```
|
|
60
|
+
*
|
|
61
|
+
* @param text - The visible text of the link.
|
|
62
|
+
*/
|
|
63
|
+
exports.ClickLinkByText = (0, registry_1.Step)("I click on link {string}", async (page, text, table) => {
|
|
64
|
+
const options = (0, state_1.parseClickOptions)(table);
|
|
65
|
+
const link = page.getByRole("link", { name: text });
|
|
66
|
+
await link.click(options);
|
|
67
|
+
(0, state_1.setActiveElement)(page, link);
|
|
68
|
+
console.log(`✅ Clicked on link "${text}"`);
|
|
69
|
+
});
|
|
70
|
+
/**
|
|
71
|
+
* Clicks on a form label element.
|
|
72
|
+
*
|
|
73
|
+
* ```gherkin
|
|
74
|
+
* When I click on label {string}
|
|
75
|
+
* ```
|
|
76
|
+
*
|
|
77
|
+
* @param labelText - The text content of the label element.
|
|
78
|
+
*/
|
|
79
|
+
exports.ClickLabelByText = (0, registry_1.Step)("I click on label {string}", async (page, labelText, table) => {
|
|
80
|
+
const options = (0, state_1.parseClickOptions)(table);
|
|
81
|
+
const label = page.getByLabel(labelText);
|
|
82
|
+
await label.click(options);
|
|
83
|
+
(0, state_1.setActiveElement)(page, label);
|
|
84
|
+
console.log(`🏷️ Clicked on label "${labelText}"`);
|
|
85
|
+
});
|
|
86
|
+
// ==================================================
|
|
87
|
+
// 2. TEXT-BASED CLICKS
|
|
88
|
+
// ==================================================
|
|
89
|
+
/**
|
|
90
|
+
* Clicks on the first visible element containing the specified text (partial match).
|
|
91
|
+
*
|
|
92
|
+
* ```gherkin
|
|
93
|
+
* When I click on text {string}
|
|
94
|
+
* ```
|
|
95
|
+
*
|
|
96
|
+
* @param rawText - The text to look for. Use "@alias" to reference a stored variable.
|
|
97
|
+
*/
|
|
98
|
+
exports.ClickByText = (0, registry_1.Step)("I click on text {string}", async (page, rawText, table) => {
|
|
99
|
+
const options = (0, state_1.parseClickOptions)(table);
|
|
100
|
+
let text = rawText;
|
|
101
|
+
// Handle Alias (e.g., "@username")
|
|
102
|
+
if (rawText.startsWith("@")) {
|
|
103
|
+
const aliasKey = rawText.slice(1);
|
|
104
|
+
const storedValue = (0, state_1.getVariable)(page, aliasKey);
|
|
105
|
+
if (!storedValue) {
|
|
106
|
+
throw new Error(`❌ No value found for alias "@${aliasKey}"`);
|
|
107
|
+
}
|
|
108
|
+
text = storedValue;
|
|
109
|
+
}
|
|
110
|
+
const locator = page.getByText(text, { exact: false }).first();
|
|
111
|
+
await locator.waitFor({ state: "visible", timeout: 5000 });
|
|
112
|
+
await locator.click(options);
|
|
113
|
+
(0, state_1.setActiveElement)(page, locator);
|
|
114
|
+
console.log(`🖱️ Clicked on text "${text}"`);
|
|
115
|
+
});
|
|
116
|
+
/**
|
|
117
|
+
* Clicks on an element containing the EXACT specified text.
|
|
118
|
+
*
|
|
119
|
+
* ```gherkin
|
|
120
|
+
* When I click on exact text {string}
|
|
121
|
+
* ```
|
|
122
|
+
*
|
|
123
|
+
* @param exactText - The exact text content to match.
|
|
124
|
+
*/
|
|
125
|
+
exports.ClickByExactText = (0, registry_1.Step)("I click on exact text {string}", async (page, exactText, table) => {
|
|
126
|
+
const options = (0, state_1.parseClickOptions)(table);
|
|
127
|
+
const locator = page.getByText(exactText, { exact: true });
|
|
128
|
+
await locator.waitFor({ state: "visible", timeout: 5000 });
|
|
129
|
+
await locator.click(options);
|
|
130
|
+
(0, state_1.setActiveElement)(page, locator);
|
|
131
|
+
console.log(`🖱️ Clicked on exact text "${exactText}"`);
|
|
132
|
+
});
|
|
133
|
+
/**
|
|
134
|
+
* Clicks on a selector provided via Regex match.
|
|
135
|
+
*
|
|
136
|
+
* ```gherkin
|
|
137
|
+
* I click on selector "#btn-id"
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
140
|
+
exports.ClickByRegexSelector = (0, registry_1.Step)(/^I click on selector "([^"]+)"$/, async (page, selector) => {
|
|
141
|
+
const locator = page.locator(selector);
|
|
142
|
+
await locator.click();
|
|
143
|
+
(0, state_1.setActiveElement)(page, locator);
|
|
144
|
+
console.log(`🖱️ Clicked on selector: ${selector}`);
|
|
145
|
+
});
|
|
146
|
+
// ==================================================
|
|
147
|
+
// 3. BULK CLICKS
|
|
148
|
+
// ==================================================
|
|
149
|
+
/**
|
|
150
|
+
* Iterates through ALL currently stored active elements and clicks them one by one.
|
|
151
|
+
*
|
|
152
|
+
* ```gherkin
|
|
153
|
+
* When I click all
|
|
154
|
+
* ```
|
|
155
|
+
*/
|
|
156
|
+
exports.ClickAllStoredElements = (0, registry_1.Step)("I click all", async (page, table) => {
|
|
157
|
+
const options = (0, state_1.parseClickOptions)(table);
|
|
158
|
+
const elements = (0, state_1.getActiveElements)(page);
|
|
159
|
+
const count = await elements.count();
|
|
160
|
+
if (count === 0)
|
|
161
|
+
throw new Error("⚠️ No elements found to click.");
|
|
162
|
+
for (let i = 0; i < count; i++) {
|
|
163
|
+
const el = elements.nth(i);
|
|
164
|
+
await el.waitFor({ state: "visible", timeout: 5000 });
|
|
165
|
+
await el.click(options);
|
|
166
|
+
console.log(`🖱️ Clicked element #${i + 1}`);
|
|
167
|
+
}
|
|
168
|
+
console.log(`✅ Clicked all ${count} elements.`);
|
|
169
|
+
});
|
|
170
|
+
// ==================================================
|
|
171
|
+
// 4. MOUSE INTERACTIONS (Double & Right Click)
|
|
172
|
+
// ==================================================
|
|
173
|
+
/**
|
|
174
|
+
* Double-clicks on the currently stored (active) element.
|
|
175
|
+
*
|
|
176
|
+
* ```gherkin
|
|
177
|
+
* When I double click
|
|
178
|
+
* ```
|
|
179
|
+
*/
|
|
180
|
+
exports.DoubleClickStoredElement = (0, registry_1.Step)("I double click", async (page, table) => {
|
|
181
|
+
const options = (0, state_1.parseClickOptions)(table);
|
|
182
|
+
const element = (0, state_1.getActiveElement)(page);
|
|
183
|
+
await element.dblclick(options);
|
|
184
|
+
console.log("🖱️ Double-clicked on stored element");
|
|
185
|
+
});
|
|
186
|
+
/**
|
|
187
|
+
* Double-clicks on the first element containing the specified text.
|
|
188
|
+
*
|
|
189
|
+
* ```gherkin
|
|
190
|
+
* When I double click on text {string}
|
|
191
|
+
* ```
|
|
192
|
+
*/
|
|
193
|
+
exports.DoubleClickByText = (0, registry_1.Step)("I double click on text {string}", async (page, text, table) => {
|
|
194
|
+
const options = (0, state_1.parseClickOptions)(table);
|
|
195
|
+
const element = page.getByText(text).first();
|
|
196
|
+
await element.dblclick(options);
|
|
197
|
+
console.log(`🖱️ Double-clicked on text "${text}"`);
|
|
198
|
+
});
|
|
199
|
+
/**
|
|
200
|
+
* Double-clicks at specific X, Y coordinates on the page.
|
|
201
|
+
*
|
|
202
|
+
* ```gherkin
|
|
203
|
+
* When I double click position {int} {int}
|
|
204
|
+
* ```
|
|
205
|
+
*/
|
|
206
|
+
exports.DoubleClickPosition = (0, registry_1.Step)("I double click position {int} {int}", async (page, x, y, table) => {
|
|
207
|
+
const options = (0, state_1.parseClickOptions)(table);
|
|
208
|
+
await page.mouse.dblclick(x, y, options);
|
|
209
|
+
console.log(`🖱️ Double-clicked at (${x}, ${y})`);
|
|
210
|
+
});
|
|
211
|
+
/**
|
|
212
|
+
* Right-clicks (Context Click) on the currently stored element.
|
|
213
|
+
*
|
|
214
|
+
* ```gherkin
|
|
215
|
+
* When I right click
|
|
216
|
+
* ```
|
|
217
|
+
*/
|
|
218
|
+
exports.RightClickStoredElement = (0, registry_1.Step)("I right click", async (page, table) => {
|
|
219
|
+
const options = (0, state_1.parseClickOptions)(table);
|
|
220
|
+
const element = (0, state_1.getActiveElement)(page);
|
|
221
|
+
await element.click({ button: "right", ...options });
|
|
222
|
+
console.log("🖱️ Right-clicked on stored element");
|
|
223
|
+
});
|
|
224
|
+
/**
|
|
225
|
+
* Right-clicks on the first element containing the specified text.
|
|
226
|
+
*
|
|
227
|
+
* ```gherkin
|
|
228
|
+
* When I right click on text {string}
|
|
229
|
+
* ```
|
|
230
|
+
*/
|
|
231
|
+
exports.RightClickByText = (0, registry_1.Step)("I right click on text {string}", async (page, text, table) => {
|
|
232
|
+
const options = (0, state_1.parseClickOptions)(table);
|
|
233
|
+
const element = page.getByText(text).first();
|
|
234
|
+
await element.click({ button: "right", ...options });
|
|
235
|
+
console.log(`🖱️ Right-clicked on text "${text}"`);
|
|
236
|
+
});
|
|
237
|
+
/**
|
|
238
|
+
* Right-clicks at specific X, Y coordinates on the page.
|
|
239
|
+
*
|
|
240
|
+
* ```gherkin
|
|
241
|
+
* When I right click position {int} {int}
|
|
242
|
+
* ```
|
|
243
|
+
*/
|
|
244
|
+
exports.RightClickPosition = (0, registry_1.Step)("I right click position {int} {int}", async (page, x, y, table) => {
|
|
245
|
+
const options = (0, state_1.parseClickOptions)(table);
|
|
246
|
+
await page.mouse.click(x, y, { button: "right", ...options });
|
|
247
|
+
console.log(`🖱️ Right-clicked at (${x}, ${y})`);
|
|
248
|
+
});
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Finds a single element using a CSS or XPath selector.
|
|
3
|
+
* Asserts that exactly one element is found.
|
|
4
|
+
*
|
|
5
|
+
* ```gherkin
|
|
6
|
+
* When I find element by selector ".nav-bar"
|
|
7
|
+
* ```
|
|
8
|
+
*
|
|
9
|
+
* @param selector - The CSS or XPath selector string.
|
|
10
|
+
*/
|
|
11
|
+
export declare const FindElementBySelector: void;
|
|
12
|
+
/**
|
|
13
|
+
* Finds an element containing the exact text provided.
|
|
14
|
+
*
|
|
15
|
+
* ```gherkin
|
|
16
|
+
* When I find element by text "Submit Order"
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @param text - The exact text content to match.
|
|
20
|
+
*/
|
|
21
|
+
export declare const FindElementByText: void;
|
|
22
|
+
/**
|
|
23
|
+
* Finds an element by its `title` attribute.
|
|
24
|
+
*
|
|
25
|
+
* ```gherkin
|
|
26
|
+
* When I find element by title "Close Modal"
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* @param title - The value of the title attribute.
|
|
30
|
+
*/
|
|
31
|
+
export declare const FindElementByTitle: void;
|
|
32
|
+
/**
|
|
33
|
+
* Finds an element by its test ID (usually `data-testid`).
|
|
34
|
+
*
|
|
35
|
+
* ```gherkin
|
|
36
|
+
* When I find element by testid "login-form"
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* @param testid - The data-testid attribute value.
|
|
40
|
+
*/
|
|
41
|
+
export declare const FindElementByTestId: void;
|
|
42
|
+
/**
|
|
43
|
+
* Finds an element by its ARIA role.
|
|
44
|
+
*
|
|
45
|
+
* ```gherkin
|
|
46
|
+
* When I find element by role "button"
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* @param role - The ARIA role (e.g., "button", "link", "heading").
|
|
50
|
+
*/
|
|
51
|
+
export declare const FindElementByRole: void;
|
|
52
|
+
/**
|
|
53
|
+
* Finds an input element by its placeholder text.
|
|
54
|
+
*
|
|
55
|
+
* ```gherkin
|
|
56
|
+
* When I find element by placeholder text "Enter your email"
|
|
57
|
+
* ```
|
|
58
|
+
*
|
|
59
|
+
* @param text - The placeholder text value.
|
|
60
|
+
*/
|
|
61
|
+
export declare const FindElementByPlaceholder: void;
|
|
62
|
+
/**
|
|
63
|
+
* Finds a form control associated with a specific label text.
|
|
64
|
+
*
|
|
65
|
+
* ```gherkin
|
|
66
|
+
* When I find element by label text "Password"
|
|
67
|
+
* ```
|
|
68
|
+
*
|
|
69
|
+
* @param label - The visible text of the label.
|
|
70
|
+
*/
|
|
71
|
+
export declare const FindElementByLabel: void;
|
|
72
|
+
/**
|
|
73
|
+
* Finds an element (usually an image) by its alt text.
|
|
74
|
+
*
|
|
75
|
+
* ```gherkin
|
|
76
|
+
* When I find element by alt text "Company Logo"
|
|
77
|
+
* ```
|
|
78
|
+
*
|
|
79
|
+
* @param alt - The value of the alt attribute.
|
|
80
|
+
*/
|
|
81
|
+
export declare const FindElementByAltText: void;
|
|
82
|
+
/**
|
|
83
|
+
* Finds a specific link by its visible text.
|
|
84
|
+
* If multiple links match, selects the first one.
|
|
85
|
+
*
|
|
86
|
+
* ```gherkin
|
|
87
|
+
* When I find link by text "Read More"
|
|
88
|
+
* ```
|
|
89
|
+
*
|
|
90
|
+
* @param text - The visible text of the link.
|
|
91
|
+
*/
|
|
92
|
+
export declare const FindLinkByText: void;
|
|
93
|
+
/**
|
|
94
|
+
* Finds a heading (h1-h6) by its text content.
|
|
95
|
+
* If multiple headings match, selects the first one.
|
|
96
|
+
*
|
|
97
|
+
* ```gherkin
|
|
98
|
+
* When I find heading by text "Dashboard"
|
|
99
|
+
* ```
|
|
100
|
+
*
|
|
101
|
+
* @param text - The text content of the heading.
|
|
102
|
+
*/
|
|
103
|
+
export declare const FindHeadingByText: void;
|
|
104
|
+
/**
|
|
105
|
+
* Finds an element by its `name` attribute.
|
|
106
|
+
* Useful for form fields not easily accessible by label.
|
|
107
|
+
*
|
|
108
|
+
* ```gherkin
|
|
109
|
+
* When I find element by name "csrf_token"
|
|
110
|
+
* ```
|
|
111
|
+
*
|
|
112
|
+
* @param name - The value of the name attribute.
|
|
113
|
+
*/
|
|
114
|
+
export declare const FindElementByName: void;
|
|
115
|
+
/**
|
|
116
|
+
* Finds all elements matching a CSS selector and stores them as a list.
|
|
117
|
+
*
|
|
118
|
+
* ```gherkin
|
|
119
|
+
* When I find elements by selector "ul > li"
|
|
120
|
+
* ```
|
|
121
|
+
*
|
|
122
|
+
* @param selector - The CSS selector.
|
|
123
|
+
*/
|
|
124
|
+
export declare const FindElementsBySelector: void;
|
|
125
|
+
/**
|
|
126
|
+
* Finds all headings matching specific text.
|
|
127
|
+
*
|
|
128
|
+
* ```gherkin
|
|
129
|
+
* When I find headings by text "Article Title"
|
|
130
|
+
* ```
|
|
131
|
+
*
|
|
132
|
+
* @param text - The text to match headings against.
|
|
133
|
+
*/
|
|
134
|
+
export declare const FindHeadingsByText: void;
|
|
135
|
+
/**
|
|
136
|
+
* Finds all buttons matching specific text.
|
|
137
|
+
* Supports variable aliasing (e.g., "@buttonName").
|
|
138
|
+
*
|
|
139
|
+
* ```gherkin
|
|
140
|
+
* When I find buttons by text "Add to Cart"
|
|
141
|
+
* ```
|
|
142
|
+
*
|
|
143
|
+
* @param text - The button text or an alias (e.g., "@myBtn").
|
|
144
|
+
*/
|
|
145
|
+
export declare const FindButtonsByText: void;
|
|
146
|
+
/**
|
|
147
|
+
* Selects the first element from the currently stored list of elements.
|
|
148
|
+
*
|
|
149
|
+
* ```gherkin
|
|
150
|
+
* When I get first element
|
|
151
|
+
* ```
|
|
152
|
+
*/
|
|
153
|
+
export declare const GetFirstElement: void;
|
|
154
|
+
/**
|
|
155
|
+
* Selects the last element from the currently stored list of elements.
|
|
156
|
+
*
|
|
157
|
+
* ```gherkin
|
|
158
|
+
* When I get last element
|
|
159
|
+
* ```
|
|
160
|
+
*/
|
|
161
|
+
export declare const GetLastElement: void;
|
|
162
|
+
/**
|
|
163
|
+
* Selects the nth element from the currently stored list.
|
|
164
|
+
* Uses 1-based indexing (e.g., 1st, 2nd, 3rd).
|
|
165
|
+
*
|
|
166
|
+
* ```gherkin
|
|
167
|
+
* When I get 2nd element
|
|
168
|
+
* When I get 10th element
|
|
169
|
+
* ```
|
|
170
|
+
*
|
|
171
|
+
* @param indexStr - The number captured from the regex (e.g., "2").
|
|
172
|
+
*/
|
|
173
|
+
export declare const GetNthElement: void;
|
|
174
|
+
/**
|
|
175
|
+
* Selects the element that currently has browser focus.
|
|
176
|
+
*
|
|
177
|
+
* ```gherkin
|
|
178
|
+
* When I get focused element
|
|
179
|
+
* ```
|
|
180
|
+
*/
|
|
181
|
+
export declare const GetFocusedElement: void;
|
|
182
|
+
/**
|
|
183
|
+
* Finds an input field by its ID attribute.
|
|
184
|
+
*
|
|
185
|
+
* ```gherkin
|
|
186
|
+
* When I find input by ID "user_email"
|
|
187
|
+
* ```
|
|
188
|
+
*
|
|
189
|
+
* @param id - The ID string.
|
|
190
|
+
*/
|
|
191
|
+
export declare const FindInputById: void;
|
|
192
|
+
/**
|
|
193
|
+
* Finds an input field by its name attribute.
|
|
194
|
+
*
|
|
195
|
+
* ```gherkin
|
|
196
|
+
* When I find input by name "password"
|
|
197
|
+
* ```
|
|
198
|
+
*
|
|
199
|
+
* @param name - The name attribute value.
|
|
200
|
+
*/
|
|
201
|
+
export declare const FindInputByName: void;
|
|
202
|
+
/**
|
|
203
|
+
* Finds an input field by its placeholder text.
|
|
204
|
+
*
|
|
205
|
+
* ```gherkin
|
|
206
|
+
* When I find input by placeholder text "Search products..."
|
|
207
|
+
* ```
|
|
208
|
+
*
|
|
209
|
+
* @param placeholder - The placeholder text.
|
|
210
|
+
*/
|
|
211
|
+
export declare const FindInputByPlaceholder: void;
|
|
212
|
+
/**
|
|
213
|
+
* Finds an input field that currently has a specific value.
|
|
214
|
+
* Supports variable aliasing (e.g., "@storedValue").
|
|
215
|
+
*
|
|
216
|
+
* ```gherkin
|
|
217
|
+
* When I find input by display value "John"
|
|
218
|
+
* ```
|
|
219
|
+
*
|
|
220
|
+
* @param value - The value to match.
|
|
221
|
+
*/
|
|
222
|
+
export declare const FindInputByValue: void;
|
|
223
|
+
/**
|
|
224
|
+
* Finds a textarea associated with a specific label.
|
|
225
|
+
* Fallback mechanism attempts to find the textarea via label if the standard getByLabel returns a generic element.
|
|
226
|
+
*
|
|
227
|
+
* ```gherkin
|
|
228
|
+
* When I find textarea by label text "Description"
|
|
229
|
+
* ```
|
|
230
|
+
*
|
|
231
|
+
* @param label - The visible text of the label.
|
|
232
|
+
*/
|
|
233
|
+
export declare const FindTextareaByLabel: void;
|
|
234
|
+
/**
|
|
235
|
+
* Reads the text content of the currently active element and stores it in a variable.
|
|
236
|
+
*
|
|
237
|
+
* ```gherkin
|
|
238
|
+
* When I store element text as "confirmationCode"
|
|
239
|
+
* ```
|
|
240
|
+
*
|
|
241
|
+
* @param alias - The name of the variable to store the text in (without "@").
|
|
242
|
+
*/
|
|
243
|
+
export declare const StoreElementText: void;
|
|
244
|
+
//# sourceMappingURL=find.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../../../src/backend/actions/find.ts"],"names":[],"mappings":"AAeA;;;;;;;;;GASG;AACH,eAAO,MAAM,qBAAqB,MAQjC,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,MAK5B,CAAC;AAEH;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,MAK7B,CAAC;AAEH;;;;;;;;GAQG;AACH,eAAO,MAAM,mBAAmB,MAQ/B,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,MAK5B,CAAC;AAEH;;;;;;;;GAQG;AACH,eAAO,MAAM,wBAAwB,MAQpC,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,MAQ9B,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,oBAAoB,MAQhC,CAAC;AAMF;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc,MAMzB,CAAC;AAEH;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB,MAI5B,CAAC;AAEH;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB,MAM5B,CAAC;AAMH;;;;;;;;GAQG;AACH,eAAO,MAAM,sBAAsB,MAQlC,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,MAI7B,CAAC;AAEH;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB,MAc5B,CAAC;AAMH;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,MAK1B,CAAC;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,MAKzB,CAAC;AAEH;;;;;;;;;;GAUG;AACH,eAAO,MAAM,aAAa,MAgBzB,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,MAK5B,CAAC;AAMH;;;;;;;;GAQG;AACH,eAAO,MAAM,aAAa,MAIxB,CAAC;AAEH;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe,MAI1B,CAAC;AAEH;;;;;;;;GAQG;AACH,eAAO,MAAM,sBAAsB,MAOlC,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,gBAAgB,MAiB5B,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,mBAAmB,MAe/B,CAAC;AAMF;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB,MAO3B,CAAC"}
|