playwright-cucumber-ts-steps 1.0.0 → 1.0.1

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.
Files changed (73) hide show
  1. package/lib/actions/clickSteps.d.ts +251 -0
  2. package/lib/actions/clickSteps.js +415 -0
  3. package/lib/actions/cookieSteps.d.ts +18 -0
  4. package/lib/actions/cookieSteps.js +93 -0
  5. package/lib/actions/debugSteps.d.ts +14 -0
  6. package/lib/actions/debugSteps.js +23 -0
  7. package/lib/actions/elementFindSteps.d.ts +668 -0
  8. package/lib/actions/elementFindSteps.js +931 -0
  9. package/lib/actions/fillFormSteps.d.ts +69 -0
  10. package/lib/actions/fillFormSteps.js +237 -0
  11. package/lib/actions/index.d.ts +11 -0
  12. package/lib/actions/index.js +28 -0
  13. package/lib/actions/inputSteps.d.ts +218 -0
  14. package/lib/actions/inputSteps.js +343 -0
  15. package/lib/actions/interceptionSteps.d.ts +169 -0
  16. package/lib/actions/interceptionSteps.js +291 -0
  17. package/lib/actions/miscSteps.d.ts +645 -0
  18. package/lib/actions/miscSteps.js +1061 -0
  19. package/lib/actions/mouseSteps.d.ts +143 -0
  20. package/lib/actions/mouseSteps.js +234 -0
  21. package/lib/actions/scrollSteps.d.ts +82 -0
  22. package/lib/actions/scrollSteps.js +123 -0
  23. package/lib/actions/storageSteps.d.ts +174 -0
  24. package/lib/actions/storageSteps.js +292 -0
  25. package/lib/assertions/buttonAndTextVisibilitySteps.d.ts +245 -0
  26. package/lib/assertions/buttonAndTextVisibilitySteps.js +401 -0
  27. package/lib/assertions/cookieSteps.d.ts +75 -0
  28. package/lib/assertions/cookieSteps.js +113 -0
  29. package/lib/assertions/elementSteps.d.ts +264 -0
  30. package/lib/assertions/elementSteps.js +388 -0
  31. package/lib/assertions/formInputSteps.d.ts +248 -0
  32. package/lib/assertions/formInputSteps.js +350 -0
  33. package/lib/assertions/index.d.ts +10 -0
  34. package/lib/assertions/index.js +27 -0
  35. package/lib/assertions/interceptionRequestsSteps.d.ts +353 -0
  36. package/lib/assertions/interceptionRequestsSteps.js +593 -0
  37. package/lib/assertions/locationSteps.d.ts +217 -0
  38. package/lib/assertions/locationSteps.js +310 -0
  39. package/lib/assertions/roleTestIdSteps.d.ts +159 -0
  40. package/lib/assertions/roleTestIdSteps.js +221 -0
  41. package/lib/assertions/semanticSteps.d.ts +176 -0
  42. package/lib/assertions/semanticSteps.js +252 -0
  43. package/lib/assertions/storageSteps.d.ts +149 -0
  44. package/lib/assertions/storageSteps.js +210 -0
  45. package/lib/assertions/visualSteps.d.ts +74 -0
  46. package/lib/assertions/visualSteps.js +209 -0
  47. package/lib/custom_setups/loginHooks.d.ts +1 -0
  48. package/lib/custom_setups/loginHooks.js +130 -0
  49. package/lib/helpers/checkPeerDeps.d.ts +1 -0
  50. package/lib/helpers/checkPeerDeps.js +19 -0
  51. package/lib/helpers/compareSnapshots.d.ts +6 -0
  52. package/lib/helpers/compareSnapshots.js +20 -0
  53. package/lib/helpers/hooks.d.ts +1 -0
  54. package/lib/helpers/hooks.js +210 -0
  55. package/lib/helpers/utils/fakerUtils.d.ts +1 -0
  56. package/lib/helpers/utils/fakerUtils.js +60 -0
  57. package/lib/helpers/utils/index.d.ts +4 -0
  58. package/lib/helpers/utils/index.js +20 -0
  59. package/lib/helpers/utils/optionsUtils.d.ts +24 -0
  60. package/lib/helpers/utils/optionsUtils.js +88 -0
  61. package/lib/helpers/utils/resolveUtils.d.ts +6 -0
  62. package/lib/helpers/utils/resolveUtils.js +72 -0
  63. package/lib/helpers/utils/sessionUtils.d.ts +3 -0
  64. package/lib/helpers/utils/sessionUtils.js +40 -0
  65. package/lib/helpers/world.d.ts +34 -0
  66. package/lib/helpers/world.js +110 -0
  67. package/lib/iframes/frames.d.ts +1 -0
  68. package/lib/iframes/frames.js +11 -0
  69. package/lib/index.d.ts +10 -0
  70. package/lib/index.js +28 -0
  71. package/lib/register.d.ts +1 -0
  72. package/lib/register.js +6 -0
  73. package/package.json +1 -1
@@ -0,0 +1,251 @@
1
+ import { DataTable } from "@cucumber/cucumber";
2
+ import { CustomWorld } from "../helpers/world";
3
+ /**
4
+ * Clicks on the previously stored element.
5
+ *
6
+ * ```gherkin
7
+ * When I click
8
+ * ```
9
+ *
10
+ * @example
11
+ * ```gherkin
12
+ * When I click
13
+ * ```
14
+ * @remarks
15
+ * Requires a previous step that stores an element.
16
+ * @category Click Steps
17
+ */
18
+ export declare function When_I_click(this: CustomWorld, ...rest: any[]): Promise<void>;
19
+ /**
20
+ * Clicks on an element matching the given selector.
21
+ *
22
+ * ```gherkin
23
+ * When I click on element {string}
24
+ * ```
25
+ *
26
+ * @example
27
+ * ```gherkin
28
+ * When I click on element ".my-class"
29
+ * ```
30
+ * @remarks
31
+ * Stores the clicked element for later use.
32
+ * @category Click Steps
33
+ */
34
+ export declare function When_I_click_on_element(this: CustomWorld, selector: string, ...rest: any[]): Promise<void>;
35
+ /**
36
+ * Clicks on a button with the given label.
37
+ *
38
+ * ```gherkin
39
+ * When I click on button {string}
40
+ * ```
41
+ *
42
+ * @example
43
+ * ```gherkin
44
+ * When I click on button "Submit"
45
+ * ```
46
+ * @remarks
47
+ * Stores the clicked button for later use.
48
+ * @category Click Steps
49
+ */
50
+ export declare function When_I_click_on_button(this: CustomWorld, label: string, ...rest: any[]): Promise<void>;
51
+ /**
52
+ * Clicks on a link with the given text.
53
+ *
54
+ * ```gherkin
55
+ * When I click on link {string}
56
+ * ```
57
+ *
58
+ * @example
59
+ * ```gherkin
60
+ * When I click on link "Home"
61
+ * ```
62
+ * @remarks
63
+ * Stores the clicked link for later use.
64
+ * @category Click Steps
65
+ */
66
+ export declare function When_I_click_on_link(this: CustomWorld, text: string, ...rest: any[]): Promise<void>;
67
+ /**
68
+ * Clicks on a label with the given text.
69
+ *
70
+ * ```gherkin
71
+ * When I click on label {string}
72
+ * ```
73
+ *
74
+ * @example
75
+ * ```gherkin
76
+ * When I click on label "Username"
77
+ * ```
78
+ * @remarks
79
+ * Stores the clicked label for later use.
80
+ * @category Click Steps
81
+ */
82
+ export declare function When_I_click_on_label(this: CustomWorld, labelText: string, ...rest: any[]): Promise<void>;
83
+ /**
84
+ * Clicks on an element containing the given text (not exact match). Supports aliasing with @alias.
85
+ *
86
+ * ```gherkin
87
+ * When I click on text {string}
88
+ * ```
89
+ *
90
+ * @example
91
+ * ```gherkin
92
+ * When I click on text "Welcome"
93
+ * When I click on text "@username"
94
+ * ```
95
+ * @remarks
96
+ * Stores the clicked element for later use.
97
+ * @category Click Steps
98
+ */
99
+ export declare function When_I_click_on_text(this: CustomWorld, rawText: string, ...rest: any[]): Promise<void>;
100
+ /**
101
+ * Clicks on an element containing the exact given text.
102
+ *
103
+ * ```gherkin
104
+ * When I click on exact text {string}
105
+ * ```
106
+ *
107
+ * @example
108
+ * ```gherkin
109
+ * When I click on exact text "Log out"
110
+ * ```
111
+ * @remarks
112
+ * Stores the clicked element for later use.
113
+ * @category Click Steps
114
+ */
115
+ export declare function When_I_click_on_exact_text(this: CustomWorld, exactText: string, ...rest: any[]): Promise<void>;
116
+ /**
117
+ * Clicks all previously stored elements.
118
+ *
119
+ * ```gherkin
120
+ * When I click all
121
+ * ```
122
+ *
123
+ * @example
124
+ * ```gherkin
125
+ * When I click all
126
+ * ```
127
+ * @remarks
128
+ * Requires a previous step that stores elements.
129
+ * @category Click Steps
130
+ */
131
+ export declare function When_I_click_all(this: CustomWorld, ...rest: any[]): Promise<void>;
132
+ /**
133
+ * Double-clicks on an element containing the given text.
134
+ *
135
+ * ```gherkin
136
+ * When I double click on text {string}
137
+ * ```
138
+ *
139
+ * @example
140
+ * ```gherkin
141
+ * When I double click on text "Edit"
142
+ * ```
143
+ * @remarks
144
+ * Uses the previously stored element if available.
145
+ * @category Click Steps
146
+ */
147
+ export declare function When_I_double_click_on_text(this: CustomWorld, text: string, ...rest: any[]): Promise<void>;
148
+ /**
149
+ * Double-clicks at the given page coordinates.
150
+ *
151
+ * ```gherkin
152
+ * When I double click position {int} {int}
153
+ * ```
154
+ *
155
+ * @example
156
+ * ```gherkin
157
+ * When I double click position 100 200
158
+ * ```
159
+ * @category Click Steps
160
+ */
161
+ export declare function When_I_double_click_position(this: CustomWorld, x: number, y: number, ...rest: any[]): Promise<void>;
162
+ /**
163
+ * Double-clicks on the previously stored element.
164
+ *
165
+ * ```gherkin
166
+ * When I double click
167
+ * ```
168
+ *
169
+ * @example
170
+ * ```gherkin
171
+ * When I double click
172
+ * ```
173
+ * @remarks
174
+ * Requires a previous step that stores an element.
175
+ * @category Click Steps
176
+ */
177
+ export declare function When_I_double_click(this: CustomWorld, ...rest: any[]): Promise<void>;
178
+ /**
179
+ * Right-clicks on the previously stored element.
180
+ *
181
+ * ```gherkin
182
+ * When I right click
183
+ * ```
184
+ *
185
+ * @example
186
+ * ```gherkin
187
+ * When I right click
188
+ * ```
189
+ * @remarks
190
+ * Requires a previous step that stores an element.
191
+ * @category Click Steps
192
+ */
193
+ export declare function When_I_right_click(this: CustomWorld, ...rest: any[]): Promise<void>;
194
+ /**
195
+ * Right-clicks on an element containing the given text.
196
+ *
197
+ * ```gherkin
198
+ * When I right click on text {string}
199
+ * ```
200
+ *
201
+ * @example
202
+ * ```gherkin
203
+ * When I right click on text "Options"
204
+ * ```
205
+ * @category Click Steps
206
+ */
207
+ export declare function When_I_right_click_on_text(this: CustomWorld, text: string, ...rest: any[]): Promise<void>;
208
+ /**
209
+ * Right-clicks at the given page coordinates.
210
+ *
211
+ * ```gherkin
212
+ * When I right click position {int} {int}
213
+ * ```
214
+ *
215
+ * @example
216
+ * ```gherkin
217
+ * When I right click position 50 50
218
+ * ```
219
+ * @category Click Steps
220
+ */
221
+ export declare function When_I_right_click_position(this: CustomWorld, x: number, y: number, ...rest: any[]): Promise<void>;
222
+ /**
223
+ * Clicks all stored elements (alternative signature).
224
+ *
225
+ * ```gherkin
226
+ * When I click all
227
+ * ```
228
+ *
229
+ * @example
230
+ * ```gherkin
231
+ * When I click all
232
+ * ```
233
+ * @remarks
234
+ * Requires a previous step that stores elements.
235
+ * @category Click Steps
236
+ */
237
+ export declare function When_I_click_all_alt(this: CustomWorld, dataTable?: DataTable): Promise<void>;
238
+ /**
239
+ * Clicks on an element matching the given selector (regex step).
240
+ *
241
+ * ```gherkin
242
+ * When I click on selector {string}
243
+ * ```
244
+ *
245
+ * @example
246
+ * ```gherkin
247
+ * When I click on selector ".my-selector"
248
+ * ```
249
+ * @category Click Steps
250
+ */
251
+ export declare function When_I_click_on_selector(this: CustomWorld, selector: string): Promise<void>;
@@ -0,0 +1,415 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.When_I_click = When_I_click;
4
+ exports.When_I_click_on_element = When_I_click_on_element;
5
+ exports.When_I_click_on_button = When_I_click_on_button;
6
+ exports.When_I_click_on_link = When_I_click_on_link;
7
+ exports.When_I_click_on_label = When_I_click_on_label;
8
+ exports.When_I_click_on_text = When_I_click_on_text;
9
+ exports.When_I_click_on_exact_text = When_I_click_on_exact_text;
10
+ exports.When_I_click_all = When_I_click_all;
11
+ exports.When_I_double_click_on_text = When_I_double_click_on_text;
12
+ exports.When_I_double_click_position = When_I_double_click_position;
13
+ exports.When_I_double_click = When_I_double_click;
14
+ exports.When_I_right_click = When_I_right_click;
15
+ exports.When_I_right_click_on_text = When_I_right_click_on_text;
16
+ exports.When_I_right_click_position = When_I_right_click_position;
17
+ exports.When_I_click_all_alt = When_I_click_all_alt;
18
+ exports.When_I_click_on_selector = When_I_click_on_selector;
19
+ // e2e/step_definitions/common/actions/clickSteps.ts
20
+ const cucumber_1 = require("@cucumber/cucumber");
21
+ const optionsUtils_1 = require("../helpers/utils/optionsUtils");
22
+ /**
23
+ * Clicks on the previously stored element.
24
+ *
25
+ * ```gherkin
26
+ * When I click
27
+ * ```
28
+ *
29
+ * @example
30
+ * ```gherkin
31
+ * When I click
32
+ * ```
33
+ * @remarks
34
+ * Requires a previous step that stores an element.
35
+ * @category Click Steps
36
+ */
37
+ async function When_I_click(...rest) {
38
+ const maybeTable = rest[0];
39
+ const options = maybeTable?.rowsHash ? (0, optionsUtils_1.parseClickOptions)(maybeTable) : {};
40
+ if (!this.element)
41
+ throw new Error("❌ No stored element to click.");
42
+ await this.element.click(options);
43
+ this.log?.("🖱️ Clicked on stored element");
44
+ }
45
+ (0, cucumber_1.When)("I click", When_I_click);
46
+ /**
47
+ * Clicks on an element matching the given selector.
48
+ *
49
+ * ```gherkin
50
+ * When I click on element {string}
51
+ * ```
52
+ *
53
+ * @example
54
+ * ```gherkin
55
+ * When I click on element ".my-class"
56
+ * ```
57
+ * @remarks
58
+ * Stores the clicked element for later use.
59
+ * @category Click Steps
60
+ */
61
+ async function When_I_click_on_element(selector, ...rest) {
62
+ const maybeTable = rest[0];
63
+ const options = maybeTable?.rowsHash ? (0, optionsUtils_1.parseClickOptions)(maybeTable) : {};
64
+ const element = this.getLocator(selector);
65
+ await element.click(options);
66
+ this.element = element;
67
+ this.log?.(`🖱️ Clicked on element "${selector}"`);
68
+ }
69
+ (0, cucumber_1.When)("I click on element {string}", When_I_click_on_element);
70
+ /**
71
+ * Clicks on a button with the given label.
72
+ *
73
+ * ```gherkin
74
+ * When I click on button {string}
75
+ * ```
76
+ *
77
+ * @example
78
+ * ```gherkin
79
+ * When I click on button "Submit"
80
+ * ```
81
+ * @remarks
82
+ * Stores the clicked button for later use.
83
+ * @category Click Steps
84
+ */
85
+ async function When_I_click_on_button(label, ...rest) {
86
+ const maybeTable = rest[0];
87
+ const options = maybeTable?.rowsHash ? (0, optionsUtils_1.parseClickOptions)(maybeTable) : {};
88
+ const button = await this.page.getByRole("button", { name: label });
89
+ await button.click(options);
90
+ this.element = button;
91
+ this.log?.(`🖱️ Clicked on button "${label}"`);
92
+ }
93
+ (0, cucumber_1.When)("I click on button {string}", When_I_click_on_button);
94
+ /**
95
+ * Clicks on a link with the given text.
96
+ *
97
+ * ```gherkin
98
+ * When I click on link {string}
99
+ * ```
100
+ *
101
+ * @example
102
+ * ```gherkin
103
+ * When I click on link "Home"
104
+ * ```
105
+ * @remarks
106
+ * Stores the clicked link for later use.
107
+ * @category Click Steps
108
+ */
109
+ async function When_I_click_on_link(text, ...rest) {
110
+ const maybeTable = rest[0];
111
+ const options = maybeTable?.rowsHash ? (0, optionsUtils_1.parseClickOptions)(maybeTable) : {};
112
+ const link = await this.page.getByRole("link", { name: text });
113
+ await link.click(options);
114
+ this.element = link;
115
+ this.log?.(`✅ Clicked on link "${text}"`);
116
+ }
117
+ (0, cucumber_1.When)("I click on link {string}", When_I_click_on_link);
118
+ /**
119
+ * Clicks on a label with the given text.
120
+ *
121
+ * ```gherkin
122
+ * When I click on label {string}
123
+ * ```
124
+ *
125
+ * @example
126
+ * ```gherkin
127
+ * When I click on label "Username"
128
+ * ```
129
+ * @remarks
130
+ * Stores the clicked label for later use.
131
+ * @category Click Steps
132
+ */
133
+ async function When_I_click_on_label(labelText, ...rest) {
134
+ const maybeTable = rest[0];
135
+ const options = maybeTable?.rowsHash ? (0, optionsUtils_1.parseClickOptions)(maybeTable) : {};
136
+ const label = await this.page.getByLabel(labelText);
137
+ await label.click(options);
138
+ this.element = label;
139
+ this.log?.(`🏷️ Clicked on label "${labelText}"`);
140
+ }
141
+ (0, cucumber_1.When)("I click on label {string}", When_I_click_on_label);
142
+ /**
143
+ * Clicks on an element containing the given text (not exact match). Supports aliasing with @alias.
144
+ *
145
+ * ```gherkin
146
+ * When I click on text {string}
147
+ * ```
148
+ *
149
+ * @example
150
+ * ```gherkin
151
+ * When I click on text "Welcome"
152
+ * When I click on text "@username"
153
+ * ```
154
+ * @remarks
155
+ * Stores the clicked element for later use.
156
+ * @category Click Steps
157
+ */
158
+ async function When_I_click_on_text(rawText, ...rest) {
159
+ const maybeTable = rest[0];
160
+ const options = maybeTable?.rowsHash ? (0, optionsUtils_1.parseClickOptions)(maybeTable) : {};
161
+ let text = rawText;
162
+ if (rawText.startsWith("@")) {
163
+ const alias = rawText.slice(1);
164
+ text = this.data[alias];
165
+ if (!text)
166
+ throw new Error(`❌ No value found for alias "@${alias}"`);
167
+ }
168
+ const locator = this.page.getByText(text, { exact: false });
169
+ await locator.first().waitFor({ state: "visible", timeout: 5000 });
170
+ await locator.first().click(options);
171
+ this.element = locator.first();
172
+ this.log?.(`🖱️ Clicked on text "${text}"`);
173
+ }
174
+ (0, cucumber_1.When)("I click on text {string}", When_I_click_on_text);
175
+ /**
176
+ * Clicks on an element containing the exact given text.
177
+ *
178
+ * ```gherkin
179
+ * When I click on exact text {string}
180
+ * ```
181
+ *
182
+ * @example
183
+ * ```gherkin
184
+ * When I click on exact text "Log out"
185
+ * ```
186
+ * @remarks
187
+ * Stores the clicked element for later use.
188
+ * @category Click Steps
189
+ */
190
+ async function When_I_click_on_exact_text(exactText, ...rest) {
191
+ const maybeTable = rest[0];
192
+ const options = maybeTable?.rowsHash ? (0, optionsUtils_1.parseClickOptions)(maybeTable) : {};
193
+ const locator = this.page.getByText(exactText, { exact: true });
194
+ await locator.waitFor({ state: "visible", timeout: 5000 });
195
+ await locator.click(options);
196
+ this.element = locator;
197
+ this.log?.(`🖱️ Clicked on exact text "${exactText}"`);
198
+ }
199
+ (0, cucumber_1.When)("I click on exact text {string}", When_I_click_on_exact_text);
200
+ /**
201
+ * Clicks all previously stored elements.
202
+ *
203
+ * ```gherkin
204
+ * When I click all
205
+ * ```
206
+ *
207
+ * @example
208
+ * ```gherkin
209
+ * When I click all
210
+ * ```
211
+ * @remarks
212
+ * Requires a previous step that stores elements.
213
+ * @category Click Steps
214
+ */
215
+ async function When_I_click_all(...rest) {
216
+ const maybeTable = rest[0];
217
+ const options = maybeTable?.rowsHash ? (0, optionsUtils_1.parseClickOptions)(maybeTable) : {};
218
+ if (!this.elements)
219
+ throw new Error("❌ No stored elements to click.");
220
+ const count = await this.elements.count();
221
+ if (count === 0)
222
+ throw new Error("⚠️ No elements found to click.");
223
+ for (let i = 0; i < count; i++) {
224
+ const el = this.elements.nth(i);
225
+ await el.waitFor({ state: "visible", timeout: 5000 });
226
+ await el.click(options);
227
+ this.log?.(`🖱️ Clicked element #${i + 1}`);
228
+ }
229
+ this.log?.(`✅ Clicked all ${count} elements.`);
230
+ }
231
+ (0, cucumber_1.When)("I click all", When_I_click_all);
232
+ /**
233
+ * Double-clicks on an element containing the given text.
234
+ *
235
+ * ```gherkin
236
+ * When I double click on text {string}
237
+ * ```
238
+ *
239
+ * @example
240
+ * ```gherkin
241
+ * When I double click on text "Edit"
242
+ * ```
243
+ * @remarks
244
+ * Uses the previously stored element if available.
245
+ * @category Click Steps
246
+ */
247
+ async function When_I_double_click_on_text(text, ...rest) {
248
+ const maybeTable = rest[0];
249
+ const options = maybeTable?.rowsHash ? (0, optionsUtils_1.parseClickOptions)(maybeTable) : {};
250
+ const element = this.element || this.page.getByText(text);
251
+ await element.dblclick(options);
252
+ this.log?.(`🖱️ Double-clicked on text "${text}"`);
253
+ }
254
+ (0, cucumber_1.When)("I double click on text {string}", When_I_double_click_on_text);
255
+ /**
256
+ * Double-clicks at the given page coordinates.
257
+ *
258
+ * ```gherkin
259
+ * When I double click position {int} {int}
260
+ * ```
261
+ *
262
+ * @example
263
+ * ```gherkin
264
+ * When I double click position 100 200
265
+ * ```
266
+ * @category Click Steps
267
+ */
268
+ async function When_I_double_click_position(x, y, ...rest) {
269
+ const maybeTable = rest[0];
270
+ const options = maybeTable?.rowsHash ? (0, optionsUtils_1.parseClickOptions)(maybeTable) : {};
271
+ await this.page.mouse.dblclick(x, y, options);
272
+ this.log?.(`🖱️ Double-clicked at (${x}, ${y})`);
273
+ }
274
+ (0, cucumber_1.When)("I double click position {int} {int}", When_I_double_click_position);
275
+ /**
276
+ * Double-clicks on the previously stored element.
277
+ *
278
+ * ```gherkin
279
+ * When I double click
280
+ * ```
281
+ *
282
+ * @example
283
+ * ```gherkin
284
+ * When I double click
285
+ * ```
286
+ * @remarks
287
+ * Requires a previous step that stores an element.
288
+ * @category Click Steps
289
+ */
290
+ async function When_I_double_click(...rest) {
291
+ const maybeTable = rest[0];
292
+ const options = maybeTable?.rowsHash ? (0, optionsUtils_1.parseClickOptions)(maybeTable) : {};
293
+ if (!this.element)
294
+ throw new Error("❌ No stored element to double-click.");
295
+ await this.element.dblclick(options);
296
+ this.log?.("🖱️ Double-clicked on stored element");
297
+ }
298
+ (0, cucumber_1.When)("I double click", When_I_double_click);
299
+ /**
300
+ * Right-clicks on the previously stored element.
301
+ *
302
+ * ```gherkin
303
+ * When I right click
304
+ * ```
305
+ *
306
+ * @example
307
+ * ```gherkin
308
+ * When I right click
309
+ * ```
310
+ * @remarks
311
+ * Requires a previous step that stores an element.
312
+ * @category Click Steps
313
+ */
314
+ async function When_I_right_click(...rest) {
315
+ const maybeTable = rest[0];
316
+ const options = maybeTable?.rowsHash ? (0, optionsUtils_1.parseClickOptions)(maybeTable) : {};
317
+ if (!this.element)
318
+ throw new Error("❌ No stored element to right-click.");
319
+ await this.element.click({ button: "right", ...options });
320
+ this.log?.("🖱️ Right-clicked on stored element");
321
+ }
322
+ (0, cucumber_1.When)("I right click", When_I_right_click);
323
+ /**
324
+ * Right-clicks on an element containing the given text.
325
+ *
326
+ * ```gherkin
327
+ * When I right click on text {string}
328
+ * ```
329
+ *
330
+ * @example
331
+ * ```gherkin
332
+ * When I right click on text "Options"
333
+ * ```
334
+ * @category Click Steps
335
+ */
336
+ async function When_I_right_click_on_text(text, ...rest) {
337
+ const maybeTable = rest[0];
338
+ const options = maybeTable?.rowsHash ? (0, optionsUtils_1.parseClickOptions)(maybeTable) : {};
339
+ const element = this.page.getByText(text);
340
+ await element.click({ button: "right", ...options });
341
+ this.log?.(`🖱️ Right-clicked on text "${text}"`);
342
+ }
343
+ (0, cucumber_1.When)("I right click on text {string}", When_I_right_click_on_text);
344
+ /**
345
+ * Right-clicks at the given page coordinates.
346
+ *
347
+ * ```gherkin
348
+ * When I right click position {int} {int}
349
+ * ```
350
+ *
351
+ * @example
352
+ * ```gherkin
353
+ * When I right click position 50 50
354
+ * ```
355
+ * @category Click Steps
356
+ */
357
+ async function When_I_right_click_position(x, y, ...rest) {
358
+ const maybeTable = rest[0];
359
+ const options = maybeTable?.rowsHash ? (0, optionsUtils_1.parseClickOptions)(maybeTable) : {};
360
+ await this.page.mouse.click(x, y, { button: "right", ...options });
361
+ this.log?.(`🖱️ Right-clicked at (${x}, ${y})`);
362
+ }
363
+ (0, cucumber_1.When)("I right click position {int} {int}", When_I_right_click_position);
364
+ /**
365
+ * Clicks all stored elements (alternative signature).
366
+ *
367
+ * ```gherkin
368
+ * When I click all
369
+ * ```
370
+ *
371
+ * @example
372
+ * ```gherkin
373
+ * When I click all
374
+ * ```
375
+ * @remarks
376
+ * Requires a previous step that stores elements.
377
+ * @category Click Steps
378
+ */
379
+ async function When_I_click_all_alt(dataTable) {
380
+ const options = (0, optionsUtils_1.parseClickOptions)(dataTable);
381
+ if (!this.elements) {
382
+ throw new Error("❌ No elements stored. Use a 'find' step before 'I click all'.");
383
+ }
384
+ const count = await this.elements.count();
385
+ if (count === 0) {
386
+ throw new Error("⚠️ Stored elements are empty. Nothing to click.");
387
+ }
388
+ for (let i = 0; i < count; i++) {
389
+ const element = this.elements.nth(i);
390
+ await element.waitFor({ state: "visible", timeout: 5000 });
391
+ await element.click(options);
392
+ this.log?.(`🖱️ Clicked element #${i + 1}`);
393
+ }
394
+ this.log?.(`✅ Clicked all ${count} stored elements.`);
395
+ }
396
+ (0, cucumber_1.When)("I click all", When_I_click_all_alt);
397
+ /**
398
+ * Clicks on an element matching the given selector (regex step).
399
+ *
400
+ * ```gherkin
401
+ * When I click on selector {string}
402
+ * ```
403
+ *
404
+ * @example
405
+ * ```gherkin
406
+ * When I click on selector ".my-selector"
407
+ * ```
408
+ * @category Click Steps
409
+ */
410
+ async function When_I_click_on_selector(selector) {
411
+ const locator = this.getLocator(selector);
412
+ await locator.click();
413
+ this.log?.(`🖱️ Clicked on selector: ${selector}`);
414
+ }
415
+ (0, cucumber_1.When)(/^I click on selector "([^"]+)"$/, When_I_click_on_selector);
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @step
3
+ * @description Sets a cookie with the given name and value for the current domain.
4
+ * @example
5
+ * When I set cookie "session_id" to "abc123"
6
+ * @remarks
7
+ * The cookie is set for the current page's domain and path "/".
8
+ * @category Cookie Steps
9
+ */
10
+ export declare function When_I_set_cookie(this: any, name: string, value: string): Promise<void>;
11
+ /**
12
+ * @step
13
+ * @description Gets a cookie value by name and logs it.
14
+ * @example
15
+ * When I get cookie "session_id"
16
+ * @category Cookie Steps
17
+ */
18
+ export declare function When_I_get_cookie(this: any, name: string): Promise<void>;