playwright-cucumber-ts-steps 1.1.12 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1697 -2
- package/dist/backend/actions/click.d.ts +55 -77
- package/dist/backend/actions/click.d.ts.map +1 -1
- package/dist/backend/actions/click.js +125 -103
- package/dist/backend/actions/find.d.ts +48 -121
- package/dist/backend/actions/find.d.ts.map +1 -1
- package/dist/backend/actions/find.js +126 -172
- package/dist/backend/actions/form.d.ts +18 -26
- package/dist/backend/actions/form.d.ts.map +1 -1
- package/dist/backend/actions/form.js +30 -35
- package/dist/backend/actions/formTable.d.ts +4 -9
- package/dist/backend/actions/formTable.d.ts.map +1 -1
- package/dist/backend/actions/formTable.js +13 -11
- package/dist/backend/actions/frames.d.ts +7 -35
- package/dist/backend/actions/frames.d.ts.map +1 -1
- package/dist/backend/actions/frames.js +22 -61
- package/dist/backend/actions/index.d.ts +0 -1
- package/dist/backend/actions/index.d.ts.map +1 -1
- package/dist/backend/actions/index.js +0 -1
- package/dist/backend/actions/inputs.d.ts +33 -77
- package/dist/backend/actions/inputs.d.ts.map +1 -1
- package/dist/backend/actions/inputs.js +92 -116
- package/dist/backend/actions/interactions.d.ts +10 -32
- package/dist/backend/actions/interactions.d.ts.map +1 -1
- package/dist/backend/actions/interactions.js +31 -41
- package/dist/backend/actions/keyboard.d.ts +13 -37
- package/dist/backend/actions/keyboard.d.ts.map +1 -1
- package/dist/backend/actions/keyboard.js +35 -46
- package/dist/backend/actions/misc.d.ts +29 -69
- package/dist/backend/actions/misc.d.ts.map +1 -1
- package/dist/backend/actions/misc.js +77 -98
- package/dist/backend/actions/mobile.d.ts +14 -36
- package/dist/backend/actions/mobile.d.ts.map +1 -1
- package/dist/backend/actions/mobile.js +42 -55
- package/dist/backend/actions/mouse.d.ts +29 -36
- package/dist/backend/actions/mouse.d.ts.map +1 -1
- package/dist/backend/actions/mouse.js +76 -51
- package/dist/backend/actions/navigation.d.ts +11 -23
- package/dist/backend/actions/navigation.d.ts.map +1 -1
- package/dist/backend/actions/navigation.js +32 -32
- package/dist/backend/actions/waits.d.ts +11 -30
- package/dist/backend/actions/waits.d.ts.map +1 -1
- package/dist/backend/actions/waits.js +32 -39
- package/dist/backend/api/assertions.d.ts +6 -15
- package/dist/backend/api/assertions.d.ts.map +1 -1
- package/dist/backend/api/assertions.js +21 -23
- package/dist/backend/api/mock.d.ts +9 -18
- package/dist/backend/api/mock.d.ts.map +1 -1
- package/dist/backend/api/mock.js +24 -22
- package/dist/backend/api/network.d.ts +13 -25
- package/dist/backend/api/network.d.ts.map +1 -1
- package/dist/backend/api/network.js +40 -39
- package/dist/backend/api/requests.d.ts +13 -24
- package/dist/backend/api/requests.d.ts.map +1 -1
- package/dist/backend/api/requests.js +31 -30
- package/dist/backend/assertions/pageState.d.ts +13 -24
- package/dist/backend/assertions/pageState.d.ts.map +1 -1
- package/dist/backend/assertions/pageState.js +31 -29
- package/dist/backend/assertions/text.d.ts +12 -23
- package/dist/backend/assertions/text.d.ts.map +1 -1
- package/dist/backend/assertions/text.js +30 -28
- package/dist/backend/assertions/visibility.d.ts +24 -51
- package/dist/backend/assertions/visibility.d.ts.map +1 -1
- package/dist/backend/assertions/visibility.js +74 -79
- package/dist/backend/auth/index.d.ts +14 -1
- package/dist/backend/auth/index.d.ts.map +1 -1
- package/dist/backend/auth/index.js +26 -8
- package/dist/backend/db/steps.d.ts +58 -18
- package/dist/backend/db/steps.d.ts.map +1 -1
- package/dist/backend/db/steps.js +180 -26
- package/dist/backend/elements/alerts.d.ts +10 -19
- package/dist/backend/elements/alerts.d.ts.map +1 -1
- package/dist/backend/elements/alerts.js +25 -23
- package/dist/backend/elements/forms.d.ts +12 -23
- package/dist/backend/elements/forms.d.ts.map +1 -1
- package/dist/backend/elements/forms.js +30 -29
- package/dist/backend/elements/frames.d.ts +9 -18
- package/dist/backend/elements/frames.d.ts.map +1 -1
- package/dist/backend/elements/frames.js +24 -23
- package/dist/backend/index.d.ts +14 -0
- package/dist/backend/index.d.ts.map +1 -0
- package/dist/backend/index.js +31 -0
- package/dist/metadata.json +1016 -0
- package/package.json +8 -4
|
@@ -1,26 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.typeText = typeText;
|
|
4
|
+
exports.typeStoredText = typeStoredText;
|
|
5
|
+
exports.typeSlowly = typeSlowly;
|
|
6
|
+
exports.setInputValue = setInputValue;
|
|
7
|
+
exports.clearInput = clearInput;
|
|
8
|
+
exports.pressKeyOnInput = pressKeyOnInput;
|
|
9
|
+
exports.checkElement = checkElement;
|
|
10
|
+
exports.uncheckElement = uncheckElement;
|
|
11
|
+
exports.checkNthElementBySelector = checkNthElementBySelector;
|
|
12
|
+
exports.selectOption = selectOption;
|
|
13
|
+
exports.submitForm = submitForm;
|
|
14
|
+
exports.selectFile = selectFile;
|
|
15
|
+
exports.uploadFile = uploadFile;
|
|
4
16
|
const registry_1 = require("../../core/registry");
|
|
5
17
|
const state_1 = require("../utils/state");
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
18
|
+
// ==================================================
|
|
19
|
+
// CORE FUNCTIONS
|
|
20
|
+
// ==================================================
|
|
9
21
|
/**
|
|
10
22
|
* Fills the currently stored (active) input element with specific text.
|
|
11
23
|
* Supports variable aliases using the "@" prefix.
|
|
12
|
-
*
|
|
13
|
-
* ```gherkin
|
|
24
|
+
* @example
|
|
14
25
|
* When I type "hello world"
|
|
15
26
|
* When I type "@storedPassword"
|
|
16
|
-
*
|
|
17
|
-
*
|
|
27
|
+
* @param page - Playwright page object
|
|
18
28
|
* @param textOrAlias - The text to type OR a variable key prefixed with "@".
|
|
19
29
|
* @param table - Optional data table for options (e.g., force: true).
|
|
20
30
|
*/
|
|
21
|
-
|
|
31
|
+
async function typeText(page, textOrAlias, table) {
|
|
22
32
|
const element = (0, state_1.getActiveElement)(page);
|
|
23
|
-
const options = (0, state_1.parseClickOptions)(table);
|
|
33
|
+
const options = (0, state_1.parseClickOptions)(table);
|
|
24
34
|
let text = textOrAlias;
|
|
25
35
|
// Handle Alias
|
|
26
36
|
if (textOrAlias.startsWith("@")) {
|
|
@@ -32,18 +42,14 @@ exports.TypeText = (0, registry_1.Step)("I type {string}", async (page, textOrAl
|
|
|
32
42
|
}
|
|
33
43
|
await element.fill(text, options);
|
|
34
44
|
console.log(`⌨️ Filled element with: "${text}"`);
|
|
35
|
-
}
|
|
45
|
+
}
|
|
36
46
|
/**
|
|
37
47
|
* Fills the active input with a value explicitly retrieved from the variable store.
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
* ```gherkin
|
|
48
|
+
* @example
|
|
41
49
|
* When I type stored "userEmail"
|
|
42
|
-
* ```
|
|
43
|
-
*
|
|
44
50
|
* @param alias - The key of the stored variable.
|
|
45
51
|
*/
|
|
46
|
-
|
|
52
|
+
async function typeStoredText(page, alias, table) {
|
|
47
53
|
const element = (0, state_1.getActiveElement)(page);
|
|
48
54
|
const options = (0, state_1.parseClickOptions)(table);
|
|
49
55
|
const val = (0, state_1.getVariable)(page, alias);
|
|
@@ -51,197 +57,167 @@ exports.TypeStoredText = (0, registry_1.Step)("I type stored {string}", async (p
|
|
|
51
57
|
throw new Error(`❌ Alias "${alias}" not found.`);
|
|
52
58
|
await element.fill(val, options);
|
|
53
59
|
console.log(`⌨️ Typed stored value from "${alias}"`);
|
|
54
|
-
}
|
|
60
|
+
}
|
|
55
61
|
/**
|
|
56
62
|
* Types text character-by-character with a 100ms delay.
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
* ```gherkin
|
|
63
|
+
* @example
|
|
60
64
|
* When I slowly type "Playwright"
|
|
61
|
-
* ```
|
|
62
|
-
*
|
|
63
65
|
* @param text - The text to type sequentially.
|
|
64
66
|
*/
|
|
65
|
-
|
|
67
|
+
async function typeSlowly(page, text) {
|
|
66
68
|
const element = (0, state_1.getActiveElement)(page);
|
|
67
69
|
await element.pressSequentially(text, { delay: 100 });
|
|
68
70
|
console.log(`⌨️ Slowly typed: "${text}"`);
|
|
69
|
-
}
|
|
71
|
+
}
|
|
70
72
|
/**
|
|
71
73
|
* Sets the value of an input directly (alias for filling).
|
|
72
|
-
*
|
|
73
|
-
* ```gherkin
|
|
74
|
+
* @example
|
|
74
75
|
* When I set value "12345"
|
|
75
|
-
* ```
|
|
76
|
-
*
|
|
77
76
|
* @param value - The value to set.
|
|
78
77
|
*/
|
|
79
|
-
|
|
78
|
+
async function setInputValue(page, value, table) {
|
|
80
79
|
const element = (0, state_1.getActiveElement)(page);
|
|
81
80
|
const options = (0, state_1.parseClickOptions)(table);
|
|
82
81
|
await element.fill(value, options);
|
|
83
82
|
console.log(`📝 Set value to: "${value}"`);
|
|
84
|
-
}
|
|
83
|
+
}
|
|
85
84
|
/**
|
|
86
85
|
* Clears the text content of the active input field.
|
|
87
|
-
*
|
|
88
|
-
* ```gherkin
|
|
86
|
+
* @example
|
|
89
87
|
* When I clear
|
|
90
|
-
* ```
|
|
91
88
|
*/
|
|
92
|
-
|
|
89
|
+
async function clearInput(page) {
|
|
93
90
|
const element = (0, state_1.getActiveElement)(page);
|
|
94
91
|
await element.fill("");
|
|
95
92
|
console.log("🧹 Cleared input");
|
|
96
|
-
}
|
|
93
|
+
}
|
|
97
94
|
/**
|
|
98
95
|
* Simulates pressing a specific keyboard key on the active element.
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
* ```gherkin
|
|
96
|
+
* @example
|
|
102
97
|
* When I press "Enter"
|
|
103
98
|
* When I press "Tab"
|
|
104
|
-
* ```
|
|
105
|
-
*
|
|
106
99
|
* @param key - The key name (e.g., "Enter", "Escape", "ArrowDown").
|
|
107
100
|
*/
|
|
108
|
-
|
|
101
|
+
async function pressKeyOnInput(page, key) {
|
|
109
102
|
const element = (0, state_1.getActiveElement)(page);
|
|
110
103
|
await element.press(key);
|
|
111
104
|
console.log(`🎹 Pressed key: "${key}"`);
|
|
112
|
-
}
|
|
113
|
-
// =============================
|
|
114
|
-
// 2. CHECKBOXES & RADIOS
|
|
115
|
-
// =============================
|
|
105
|
+
}
|
|
116
106
|
/**
|
|
117
107
|
* Checks the currently active checkbox or radio button.
|
|
118
|
-
*
|
|
119
|
-
* ```gherkin
|
|
108
|
+
* @example
|
|
120
109
|
* When I check
|
|
121
|
-
* ```
|
|
122
110
|
*/
|
|
123
|
-
|
|
111
|
+
async function checkElement(page, table) {
|
|
124
112
|
const element = (0, state_1.getActiveElement)(page);
|
|
125
113
|
const options = (0, state_1.parseClickOptions)(table);
|
|
126
114
|
await element.check(options);
|
|
127
115
|
console.log("✅ Checked element");
|
|
128
|
-
}
|
|
116
|
+
}
|
|
129
117
|
/**
|
|
130
118
|
* Unchecks the currently active checkbox.
|
|
131
|
-
*
|
|
132
|
-
* ```gherkin
|
|
119
|
+
* @example
|
|
133
120
|
* When I uncheck
|
|
134
|
-
* ```
|
|
135
121
|
*/
|
|
136
|
-
|
|
122
|
+
async function uncheckElement(page, table) {
|
|
137
123
|
const element = (0, state_1.getActiveElement)(page);
|
|
138
124
|
const options = (0, state_1.parseClickOptions)(table);
|
|
139
125
|
await element.uncheck(options);
|
|
140
126
|
console.log("⬜ Unchecked element");
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* Legacy alias for `I check`.
|
|
144
|
-
*
|
|
145
|
-
* ```gherkin
|
|
146
|
-
* When I check input
|
|
147
|
-
* ```
|
|
148
|
-
*/
|
|
149
|
-
exports.CheckInputAlias = (0, registry_1.Step)("I check input", async (page, table) => {
|
|
150
|
-
const element = (0, state_1.getActiveElement)(page);
|
|
151
|
-
const options = (0, state_1.parseClickOptions)(table);
|
|
152
|
-
await element.check(options);
|
|
153
|
-
console.log("✅ Checked input");
|
|
154
|
-
});
|
|
127
|
+
}
|
|
155
128
|
/**
|
|
156
|
-
*
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
* When I uncheck
|
|
160
|
-
* ```
|
|
129
|
+
* Checks/Unchecks the Nth checkbox or radio button matching a selector.
|
|
130
|
+
* @example
|
|
131
|
+
* When I check 1st selector "input[type='checkbox']"
|
|
132
|
+
* When I uncheck 2nd selector ".terms-check"
|
|
161
133
|
*/
|
|
162
|
-
|
|
163
|
-
const
|
|
134
|
+
async function checkNthElementBySelector(page, action, indexStr, selector, table) {
|
|
135
|
+
const index = parseInt(indexStr, 10);
|
|
164
136
|
const options = (0, state_1.parseClickOptions)(table);
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
137
|
+
const locator = page.locator(selector).nth(index - 1);
|
|
138
|
+
await locator.waitFor({ state: "visible", timeout: options.timeout || 5000 });
|
|
139
|
+
if (action === "check") {
|
|
140
|
+
await locator.check(options);
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
await locator.uncheck(options);
|
|
144
|
+
}
|
|
145
|
+
(0, state_1.setActiveElement)(page, locator);
|
|
146
|
+
console.log(`✅ ${action === "check" ? "Checked" : "Unchecked"} ${indexStr} selector "${selector}"`);
|
|
147
|
+
}
|
|
171
148
|
/**
|
|
172
149
|
* Selects an option in a `<select>` dropdown by its visible label.
|
|
173
|
-
*
|
|
174
|
-
* ```gherkin
|
|
150
|
+
* @example
|
|
175
151
|
* When I select option "California"
|
|
176
|
-
* ```
|
|
177
|
-
*
|
|
178
152
|
* @param option - The visible text label of the option to select.
|
|
179
153
|
*/
|
|
180
|
-
|
|
154
|
+
async function selectOption(page, option, table) {
|
|
181
155
|
const element = (0, state_1.getActiveElement)(page);
|
|
182
156
|
const options = (0, state_1.parseClickOptions)(table);
|
|
183
|
-
// Playwright selects by value or label automatically
|
|
184
157
|
await element.selectOption({ label: option }, options);
|
|
185
158
|
console.log(`🔽 Selected option: "${option}"`);
|
|
186
|
-
}
|
|
187
|
-
// =============================
|
|
188
|
-
// 4. FORMS & FILES
|
|
189
|
-
// =============================
|
|
159
|
+
}
|
|
190
160
|
/**
|
|
191
161
|
* Submits the form related to the active element.
|
|
192
|
-
*
|
|
193
|
-
* **Logic:**
|
|
162
|
+
* Logic:
|
|
194
163
|
* 1. Tries to find the parent `<form>` of the currently stored element.
|
|
195
|
-
* 2. If no parent form is found
|
|
196
|
-
*
|
|
197
|
-
* ```gherkin
|
|
164
|
+
* 2. If no parent form is found, finds the first form on the page.
|
|
165
|
+
* @example
|
|
198
166
|
* When I submit
|
|
199
|
-
* ```
|
|
200
167
|
*/
|
|
201
|
-
|
|
168
|
+
async function submitForm(page) {
|
|
202
169
|
let formLocator;
|
|
203
170
|
try {
|
|
204
171
|
const element = (0, state_1.getActiveElement)(page);
|
|
205
|
-
// Try to find the parent form of the stored element
|
|
206
172
|
formLocator = element.locator("xpath=ancestor-or-self::form");
|
|
207
173
|
}
|
|
208
174
|
catch (_e) {
|
|
209
|
-
// If no element stored, find first form on page
|
|
210
175
|
formLocator = page.locator("form").first();
|
|
211
176
|
}
|
|
212
177
|
const count = await formLocator.count();
|
|
213
178
|
if (count === 0) {
|
|
214
179
|
throw new Error("❌ No form found to submit.");
|
|
215
180
|
}
|
|
216
|
-
// Native HTML submit (bypasses some validation, extremely reliable)
|
|
217
181
|
await formLocator.evaluate((f) => f.submit());
|
|
218
182
|
console.log("📨 Submitted form");
|
|
219
|
-
}
|
|
183
|
+
}
|
|
220
184
|
/**
|
|
221
185
|
* Uploads a file to the active file input element.
|
|
222
|
-
*
|
|
223
|
-
* ```gherkin
|
|
186
|
+
* @example
|
|
224
187
|
* When I select file "data/invoice.pdf"
|
|
225
|
-
* ```
|
|
226
|
-
*
|
|
227
188
|
* @param filePath - The path to the file (relative to the project root).
|
|
228
189
|
*/
|
|
229
|
-
|
|
190
|
+
async function selectFile(page, filePath) {
|
|
230
191
|
const element = (0, state_1.getActiveElement)(page);
|
|
231
192
|
await element.setInputFiles(filePath);
|
|
232
193
|
console.log(`📂 Selected file: "${filePath}"`);
|
|
233
|
-
}
|
|
194
|
+
}
|
|
234
195
|
/**
|
|
235
|
-
*
|
|
236
|
-
*
|
|
237
|
-
* ```gherkin
|
|
196
|
+
* Uploads a file to the active file input element (alias for selectFile).
|
|
197
|
+
* @example
|
|
238
198
|
* When I upload file "images/logo.png"
|
|
239
|
-
* ```
|
|
240
|
-
*
|
|
241
199
|
* @param filePath - The path to the file.
|
|
242
200
|
*/
|
|
243
|
-
|
|
201
|
+
async function uploadFile(page, filePath) {
|
|
244
202
|
const element = (0, state_1.getActiveElement)(page);
|
|
245
203
|
await element.setInputFiles(filePath);
|
|
246
204
|
console.log(`📂 Uploaded file: "${filePath}"`);
|
|
247
|
-
}
|
|
205
|
+
}
|
|
206
|
+
// ==================================================
|
|
207
|
+
// GLUE STEPS
|
|
208
|
+
// ==================================================
|
|
209
|
+
(0, registry_1.Step)("I type {string}", typeText);
|
|
210
|
+
(0, registry_1.Step)("I type stored {string}", typeStoredText);
|
|
211
|
+
(0, registry_1.Step)("I slowly type {string}", typeSlowly);
|
|
212
|
+
(0, registry_1.Step)("I set value {string}", setInputValue);
|
|
213
|
+
(0, registry_1.Step)("I clear", clearInput);
|
|
214
|
+
(0, registry_1.Step)("I press {string}", pressKeyOnInput);
|
|
215
|
+
(0, registry_1.Step)("I check", checkElement);
|
|
216
|
+
(0, registry_1.Step)("I uncheck", uncheckElement);
|
|
217
|
+
(0, registry_1.Step)("I check input", checkElement);
|
|
218
|
+
(0, registry_1.Step)("I uncheck input", uncheckElement);
|
|
219
|
+
(0, registry_1.Step)(/^I (check|uncheck) (\d+)(?:st|nd|rd|th) selector "([^"]+)"$/, checkNthElementBySelector);
|
|
220
|
+
(0, registry_1.Step)("I select option {string}", selectOption);
|
|
221
|
+
(0, registry_1.Step)("I submit", submitForm);
|
|
222
|
+
(0, registry_1.Step)("I select file {string}", selectFile);
|
|
223
|
+
(0, registry_1.Step)("I upload file {string}", uploadFile);
|
|
@@ -1,62 +1,40 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Performs a standard click on the element matching the selector.
|
|
3
|
-
*
|
|
4
|
-
* ```gherkin
|
|
3
|
+
* @example
|
|
5
4
|
* When I click "#submit-button"
|
|
6
|
-
* ```
|
|
7
|
-
*
|
|
8
5
|
* @param selector - The CSS or XPath selector of the element to click.
|
|
9
6
|
*/
|
|
10
|
-
export declare
|
|
7
|
+
export declare function clickElement(page: any, selector: string): Promise<void>;
|
|
11
8
|
/**
|
|
12
9
|
* Performs a forced click on the element, bypassing visibility checks.
|
|
13
10
|
* Useful for elements obscured by overlays or technically "hidden" but interactable.
|
|
14
|
-
*
|
|
15
|
-
* ```gherkin
|
|
11
|
+
* @example
|
|
16
12
|
* When I force click "#hidden-checkbox"
|
|
17
|
-
* ```
|
|
18
|
-
*
|
|
19
13
|
* @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
14
|
*/
|
|
24
|
-
export declare
|
|
15
|
+
export declare function forceClickElement(page: any, selector: string): Promise<void>;
|
|
25
16
|
/**
|
|
26
17
|
* Fills an input field with the specified value.
|
|
27
|
-
*
|
|
28
|
-
* ```gherkin
|
|
18
|
+
* @example
|
|
29
19
|
* When I fill "#username" with "testuser"
|
|
30
|
-
* ```
|
|
31
|
-
*
|
|
32
20
|
* @param selector - The CSS selector of the input field.
|
|
33
21
|
* @param value - The text value to type/fill.
|
|
34
22
|
*/
|
|
35
|
-
export declare
|
|
23
|
+
export declare function fillElement(page: any, selector: string, value: string): Promise<void>;
|
|
36
24
|
/**
|
|
37
25
|
* Presses a specific key on the keyboard globally.
|
|
38
26
|
* Useful for submitting forms (Enter) or closing modals (Escape).
|
|
39
|
-
*
|
|
40
|
-
* ```gherkin
|
|
27
|
+
* @example
|
|
41
28
|
* When I press "Enter"
|
|
42
29
|
* When I press "Escape"
|
|
43
|
-
* ```
|
|
44
|
-
*
|
|
45
30
|
* @param key - The name of the key (e.g., "Enter", "Tab", "ArrowDown").
|
|
46
31
|
*/
|
|
47
|
-
export declare
|
|
32
|
+
export declare function pressKeyGlobal(page: any, key: string): Promise<void>;
|
|
48
33
|
/**
|
|
49
34
|
* Pauses the test execution for a fixed amount of time.
|
|
50
|
-
*
|
|
51
|
-
* ```gherkin
|
|
35
|
+
* @example
|
|
52
36
|
* When I wait for 5000 milliseconds
|
|
53
|
-
* ```
|
|
54
|
-
*
|
|
55
37
|
* @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
38
|
*/
|
|
61
|
-
export declare
|
|
39
|
+
export declare function hardWait(page: any, ms: number): Promise<void>;
|
|
62
40
|
//# sourceMappingURL=interactions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interactions.d.ts","sourceRoot":"","sources":["../../../src/backend/actions/interactions.ts"],"names":[],"mappings":"AAMA
|
|
1
|
+
{"version":3,"file":"interactions.d.ts","sourceRoot":"","sources":["../../../src/backend/actions/interactions.ts"],"names":[],"mappings":"AAMA;;;;;GAKG;AACH,wBAAsB,YAAY,CAAC,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE7E;AAED;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAElF;AAED;;;;;;GAMG;AACH,wBAAsB,WAAW,CAAC,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE3F;AAED;;;;;;;GAOG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE1E;AAED;;;;;GAKG;AACH,wBAAsB,QAAQ,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEnE"}
|
|
@@ -1,78 +1,68 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.clickElement = clickElement;
|
|
4
|
+
exports.forceClickElement = forceClickElement;
|
|
5
|
+
exports.fillElement = fillElement;
|
|
6
|
+
exports.pressKeyGlobal = pressKeyGlobal;
|
|
7
|
+
exports.hardWait = hardWait;
|
|
4
8
|
const registry_1 = require("../../core/registry");
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
9
|
+
// ==================================================
|
|
10
|
+
// CORE FUNCTIONS
|
|
11
|
+
// ==================================================
|
|
8
12
|
/**
|
|
9
13
|
* Performs a standard click on the element matching the selector.
|
|
10
|
-
*
|
|
11
|
-
* ```gherkin
|
|
14
|
+
* @example
|
|
12
15
|
* When I click "#submit-button"
|
|
13
|
-
* ```
|
|
14
|
-
*
|
|
15
16
|
* @param selector - The CSS or XPath selector of the element to click.
|
|
16
17
|
*/
|
|
17
|
-
|
|
18
|
+
async function clickElement(page, selector) {
|
|
18
19
|
await page.click(selector);
|
|
19
|
-
}
|
|
20
|
+
}
|
|
20
21
|
/**
|
|
21
22
|
* Performs a forced click on the element, bypassing visibility checks.
|
|
22
23
|
* Useful for elements obscured by overlays or technically "hidden" but interactable.
|
|
23
|
-
*
|
|
24
|
-
* ```gherkin
|
|
24
|
+
* @example
|
|
25
25
|
* When I force click "#hidden-checkbox"
|
|
26
|
-
* ```
|
|
27
|
-
*
|
|
28
26
|
* @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
27
|
*/
|
|
33
|
-
|
|
28
|
+
async function forceClickElement(page, selector) {
|
|
34
29
|
await page.click(selector, { force: true });
|
|
35
|
-
}
|
|
30
|
+
}
|
|
36
31
|
/**
|
|
37
32
|
* Fills an input field with the specified value.
|
|
38
|
-
*
|
|
39
|
-
* ```gherkin
|
|
33
|
+
* @example
|
|
40
34
|
* When I fill "#username" with "testuser"
|
|
41
|
-
* ```
|
|
42
|
-
*
|
|
43
35
|
* @param selector - The CSS selector of the input field.
|
|
44
36
|
* @param value - The text value to type/fill.
|
|
45
37
|
*/
|
|
46
|
-
|
|
38
|
+
async function fillElement(page, selector, value) {
|
|
47
39
|
await page.fill(selector, value);
|
|
48
|
-
}
|
|
40
|
+
}
|
|
49
41
|
/**
|
|
50
42
|
* Presses a specific key on the keyboard globally.
|
|
51
43
|
* Useful for submitting forms (Enter) or closing modals (Escape).
|
|
52
|
-
*
|
|
53
|
-
* ```gherkin
|
|
44
|
+
* @example
|
|
54
45
|
* When I press "Enter"
|
|
55
46
|
* When I press "Escape"
|
|
56
|
-
* ```
|
|
57
|
-
*
|
|
58
47
|
* @param key - The name of the key (e.g., "Enter", "Tab", "ArrowDown").
|
|
59
48
|
*/
|
|
60
|
-
|
|
49
|
+
async function pressKeyGlobal(page, key) {
|
|
61
50
|
await page.keyboard.press(key);
|
|
62
|
-
}
|
|
51
|
+
}
|
|
63
52
|
/**
|
|
64
53
|
* Pauses the test execution for a fixed amount of time.
|
|
65
|
-
*
|
|
66
|
-
* ```gherkin
|
|
54
|
+
* @example
|
|
67
55
|
* When I wait for 5000 milliseconds
|
|
68
|
-
* ```
|
|
69
|
-
*
|
|
70
56
|
* @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
57
|
*/
|
|
76
|
-
|
|
58
|
+
async function hardWait(page, ms) {
|
|
77
59
|
await page.waitForTimeout(ms);
|
|
78
|
-
}
|
|
60
|
+
}
|
|
61
|
+
// ==================================================
|
|
62
|
+
// GLUE STEPS
|
|
63
|
+
// ==================================================
|
|
64
|
+
(0, registry_1.Step)("I click {string}", clickElement);
|
|
65
|
+
(0, registry_1.Step)("I force click {string}", forceClickElement);
|
|
66
|
+
(0, registry_1.Step)("I fill {string} with {string}", fillElement);
|
|
67
|
+
(0, registry_1.Step)("I press {string}", pressKeyGlobal);
|
|
68
|
+
(0, registry_1.Step)("I wait for {int} milliseconds", hardWait);
|
|
@@ -1,71 +1,47 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Presses a specific key globally on the page.
|
|
3
|
-
* This simulates a user pressing a key without targeting any specific element
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* ```gherkin
|
|
3
|
+
* This simulates a user pressing a key without targeting any specific element.
|
|
4
|
+
* @example
|
|
7
5
|
* When I press key "Enter"
|
|
8
6
|
* When I press key "Escape"
|
|
9
|
-
* ```
|
|
10
|
-
*
|
|
11
7
|
* @param key - The name of the key (e.g., "Enter", "Tab", "ArrowDown").
|
|
12
8
|
*/
|
|
13
|
-
export declare
|
|
9
|
+
export declare function pressKey(page: any, key: string): Promise<void>;
|
|
14
10
|
/**
|
|
15
11
|
* Presses a specific key targeted at the currently stored (active) element.
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* ```gherkin
|
|
12
|
+
* @example
|
|
19
13
|
* When I press key "Enter" on element
|
|
20
|
-
* ```
|
|
21
|
-
*
|
|
22
14
|
* @param key - The name of the key to press.
|
|
23
15
|
*/
|
|
24
|
-
export declare
|
|
16
|
+
export declare function pressKeyOnElement(page: any, key: string): Promise<void>;
|
|
25
17
|
/**
|
|
26
18
|
* Types text globally using the keyboard, character by character.
|
|
27
|
-
*
|
|
28
|
-
* `keydown`, `keypress`, and `keyup` events for each character.
|
|
29
|
-
*
|
|
30
|
-
* ```gherkin
|
|
19
|
+
* @example
|
|
31
20
|
* When I press keys "Hello World"
|
|
32
|
-
* ```
|
|
33
|
-
*
|
|
34
21
|
* @param text - The string of text to type.
|
|
35
22
|
*/
|
|
36
|
-
export declare
|
|
23
|
+
export declare function typeKeysGlobal(page: any, text: string): Promise<void>;
|
|
37
24
|
/**
|
|
38
25
|
* Performs a specific keyboard shortcut or combination.
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* ```gherkin
|
|
26
|
+
* @example
|
|
42
27
|
* When I press shortcut "Control+C"
|
|
43
28
|
* When I press shortcut "Meta+Shift+P"
|
|
44
|
-
* ```
|
|
45
|
-
*
|
|
46
29
|
* @param shortcut - The key combination string (e.g., "Control+V").
|
|
47
30
|
*/
|
|
48
|
-
export declare
|
|
31
|
+
export declare function pressShortcut(page: any, shortcut: string): Promise<void>;
|
|
49
32
|
/**
|
|
50
33
|
* Holds down a specific key.
|
|
51
34
|
* Useful for operations like multiple selections (holding Shift) or drag-and-drop.
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
* ```gherkin
|
|
35
|
+
* @example
|
|
55
36
|
* When I hold down key "Shift"
|
|
56
|
-
* ```
|
|
57
|
-
*
|
|
58
37
|
* @param key - The name of the key to hold down.
|
|
59
38
|
*/
|
|
60
|
-
export declare
|
|
39
|
+
export declare function holdDownKey(page: any, key: string): Promise<void>;
|
|
61
40
|
/**
|
|
62
41
|
* Releases a specific key that was previously held down.
|
|
63
|
-
*
|
|
64
|
-
* ```gherkin
|
|
42
|
+
* @example
|
|
65
43
|
* When I release key "Shift"
|
|
66
|
-
* ```
|
|
67
|
-
*
|
|
68
44
|
* @param key - The name of the key to release.
|
|
69
45
|
*/
|
|
70
|
-
export declare
|
|
46
|
+
export declare function releaseKey(page: any, key: string): Promise<void>;
|
|
71
47
|
//# sourceMappingURL=keyboard.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keyboard.d.ts","sourceRoot":"","sources":["../../../src/backend/actions/keyboard.ts"],"names":[],"mappings":"AAOA
|
|
1
|
+
{"version":3,"file":"keyboard.d.ts","sourceRoot":"","sources":["../../../src/backend/actions/keyboard.ts"],"names":[],"mappings":"AAOA;;;;;;;GAOG;AACH,wBAAsB,QAAQ,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAGpE;AAED;;;;;GAKG;AACH,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAI7E;AAED;;;;;GAKG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAG3E;AAED;;;;;;GAMG;AACH,wBAAsB,aAAa,CAAC,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAG9E;AAED;;;;;;GAMG;AACH,wBAAsB,WAAW,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAGvE;AAED;;;;;GAKG;AACH,wBAAsB,UAAU,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAGtE"}
|