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.
Files changed (84) hide show
  1. package/README.md +1697 -2
  2. package/dist/backend/actions/click.d.ts +55 -77
  3. package/dist/backend/actions/click.d.ts.map +1 -1
  4. package/dist/backend/actions/click.js +125 -103
  5. package/dist/backend/actions/find.d.ts +48 -121
  6. package/dist/backend/actions/find.d.ts.map +1 -1
  7. package/dist/backend/actions/find.js +126 -172
  8. package/dist/backend/actions/form.d.ts +18 -26
  9. package/dist/backend/actions/form.d.ts.map +1 -1
  10. package/dist/backend/actions/form.js +30 -35
  11. package/dist/backend/actions/formTable.d.ts +4 -9
  12. package/dist/backend/actions/formTable.d.ts.map +1 -1
  13. package/dist/backend/actions/formTable.js +13 -11
  14. package/dist/backend/actions/frames.d.ts +7 -35
  15. package/dist/backend/actions/frames.d.ts.map +1 -1
  16. package/dist/backend/actions/frames.js +22 -61
  17. package/dist/backend/actions/index.d.ts +0 -1
  18. package/dist/backend/actions/index.d.ts.map +1 -1
  19. package/dist/backend/actions/index.js +0 -1
  20. package/dist/backend/actions/inputs.d.ts +33 -77
  21. package/dist/backend/actions/inputs.d.ts.map +1 -1
  22. package/dist/backend/actions/inputs.js +92 -116
  23. package/dist/backend/actions/interactions.d.ts +10 -32
  24. package/dist/backend/actions/interactions.d.ts.map +1 -1
  25. package/dist/backend/actions/interactions.js +31 -41
  26. package/dist/backend/actions/keyboard.d.ts +13 -37
  27. package/dist/backend/actions/keyboard.d.ts.map +1 -1
  28. package/dist/backend/actions/keyboard.js +35 -46
  29. package/dist/backend/actions/misc.d.ts +29 -69
  30. package/dist/backend/actions/misc.d.ts.map +1 -1
  31. package/dist/backend/actions/misc.js +77 -98
  32. package/dist/backend/actions/mobile.d.ts +14 -36
  33. package/dist/backend/actions/mobile.d.ts.map +1 -1
  34. package/dist/backend/actions/mobile.js +42 -55
  35. package/dist/backend/actions/mouse.d.ts +29 -36
  36. package/dist/backend/actions/mouse.d.ts.map +1 -1
  37. package/dist/backend/actions/mouse.js +76 -51
  38. package/dist/backend/actions/navigation.d.ts +11 -23
  39. package/dist/backend/actions/navigation.d.ts.map +1 -1
  40. package/dist/backend/actions/navigation.js +32 -32
  41. package/dist/backend/actions/waits.d.ts +11 -30
  42. package/dist/backend/actions/waits.d.ts.map +1 -1
  43. package/dist/backend/actions/waits.js +32 -39
  44. package/dist/backend/api/assertions.d.ts +6 -15
  45. package/dist/backend/api/assertions.d.ts.map +1 -1
  46. package/dist/backend/api/assertions.js +21 -23
  47. package/dist/backend/api/mock.d.ts +9 -18
  48. package/dist/backend/api/mock.d.ts.map +1 -1
  49. package/dist/backend/api/mock.js +24 -22
  50. package/dist/backend/api/network.d.ts +13 -25
  51. package/dist/backend/api/network.d.ts.map +1 -1
  52. package/dist/backend/api/network.js +40 -39
  53. package/dist/backend/api/requests.d.ts +13 -24
  54. package/dist/backend/api/requests.d.ts.map +1 -1
  55. package/dist/backend/api/requests.js +31 -30
  56. package/dist/backend/assertions/pageState.d.ts +13 -24
  57. package/dist/backend/assertions/pageState.d.ts.map +1 -1
  58. package/dist/backend/assertions/pageState.js +31 -29
  59. package/dist/backend/assertions/text.d.ts +12 -23
  60. package/dist/backend/assertions/text.d.ts.map +1 -1
  61. package/dist/backend/assertions/text.js +30 -28
  62. package/dist/backend/assertions/visibility.d.ts +24 -51
  63. package/dist/backend/assertions/visibility.d.ts.map +1 -1
  64. package/dist/backend/assertions/visibility.js +74 -79
  65. package/dist/backend/auth/index.d.ts +14 -1
  66. package/dist/backend/auth/index.d.ts.map +1 -1
  67. package/dist/backend/auth/index.js +26 -8
  68. package/dist/backend/db/steps.d.ts +58 -18
  69. package/dist/backend/db/steps.d.ts.map +1 -1
  70. package/dist/backend/db/steps.js +180 -26
  71. package/dist/backend/elements/alerts.d.ts +10 -19
  72. package/dist/backend/elements/alerts.d.ts.map +1 -1
  73. package/dist/backend/elements/alerts.js +25 -23
  74. package/dist/backend/elements/forms.d.ts +12 -23
  75. package/dist/backend/elements/forms.d.ts.map +1 -1
  76. package/dist/backend/elements/forms.js +30 -29
  77. package/dist/backend/elements/frames.d.ts +9 -18
  78. package/dist/backend/elements/frames.d.ts.map +1 -1
  79. package/dist/backend/elements/frames.js +24 -23
  80. package/dist/backend/index.d.ts +14 -0
  81. package/dist/backend/index.d.ts.map +1 -0
  82. package/dist/backend/index.js +31 -0
  83. package/dist/metadata.json +1016 -0
  84. package/package.json +8 -4
@@ -1,230 +1,198 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.StoreElementText = exports.FindTextareaByLabel = exports.FindInputByValue = exports.FindInputByPlaceholder = exports.FindInputByName = exports.FindInputById = exports.GetFocusedElement = exports.GetNthElement = exports.GetLastElement = exports.GetFirstElement = exports.FindButtonsByText = exports.FindHeadingsByText = exports.FindElementsBySelector = exports.FindElementByName = exports.FindHeadingByText = exports.FindLinkByText = exports.FindElementByAltText = exports.FindElementByLabel = exports.FindElementByPlaceholder = exports.FindElementByRole = exports.FindElementByTestId = exports.FindElementByTitle = exports.FindElementByText = exports.FindElementBySelector = void 0;
3
+ exports.findElementBySelector = findElementBySelector;
4
+ exports.findElementByText = findElementByText;
5
+ exports.findElementByTitle = findElementByTitle;
6
+ exports.findElementByTestId = findElementByTestId;
7
+ exports.findElementByRole = findElementByRole;
8
+ exports.findElementByPlaceholder = findElementByPlaceholder;
9
+ exports.findElementByLabel = findElementByLabel;
10
+ exports.findElementByAltText = findElementByAltText;
11
+ exports.findLinkByText = findLinkByText;
12
+ exports.findHeadingByText = findHeadingByText;
13
+ exports.findElementByName = findElementByName;
14
+ exports.findElementsBySelector = findElementsBySelector;
15
+ exports.findHeadingsByText = findHeadingsByText;
16
+ exports.findButtonsByText = findButtonsByText;
17
+ exports.getFirstElement = getFirstElement;
18
+ exports.getLastElement = getLastElement;
19
+ exports.getNthElement = getNthElement;
20
+ exports.getFocusedElement = getFocusedElement;
21
+ exports.findInputById = findInputById;
22
+ exports.findInputByName = findInputByName;
23
+ exports.findInputByPlaceholder = findInputByPlaceholder;
24
+ exports.findInputByValue = findInputByValue;
25
+ exports.findTextareaByLabel = findTextareaByLabel;
26
+ exports.storeElementText = storeElementText;
4
27
  const test_1 = require("@playwright/test");
5
28
  const registry_1 = require("../../core/registry");
6
29
  const state_1 = require("../utils/state");
7
- // =============================
8
- // 1. GENERAL FINDING (Single)
9
- // =============================
30
+ // ==================================================
31
+ // CORE FUNCTIONS
32
+ // ==================================================
10
33
  /**
11
34
  * Finds a single element using a CSS or XPath selector.
12
35
  * Asserts that exactly one element is found.
13
- *
14
- * ```gherkin
36
+ * @example
15
37
  * When I find element by selector ".nav-bar"
16
- * ```
17
- *
18
38
  * @param selector - The CSS or XPath selector string.
19
39
  */
20
- exports.FindElementBySelector = (0, registry_1.Step)("I find element by selector {string}", async (page, selector) => {
40
+ async function findElementBySelector(page, selector) {
21
41
  const element = page.locator(selector);
22
42
  await (0, test_1.expect)(element).toHaveCount(1);
23
43
  (0, state_1.setActiveElement)(page, element);
24
44
  console.log(`🔍 Found element by selector: "${selector}"`);
25
- });
45
+ }
26
46
  /**
27
47
  * Finds an element containing the exact text provided.
28
- *
29
- * ```gherkin
48
+ * @example
30
49
  * When I find element by text "Submit Order"
31
- * ```
32
- *
33
50
  * @param text - The exact text content to match.
34
51
  */
35
- exports.FindElementByText = (0, registry_1.Step)("I find element by text {string}", async (page, text) => {
52
+ async function findElementByText(page, text) {
36
53
  const element = page.getByText(text, { exact: true });
37
54
  await (0, test_1.expect)(element).toHaveCount(1);
38
55
  (0, state_1.setActiveElement)(page, element);
39
56
  console.log(`🔍 Found element by exact text: "${text}"`);
40
- });
57
+ }
41
58
  /**
42
59
  * Finds an element by its `title` attribute.
43
- *
44
- * ```gherkin
60
+ * @example
45
61
  * When I find element by title "Close Modal"
46
- * ```
47
- *
48
62
  * @param title - The value of the title attribute.
49
63
  */
50
- exports.FindElementByTitle = (0, registry_1.Step)("I find element by title {string}", async (page, title) => {
64
+ async function findElementByTitle(page, title) {
51
65
  const element = page.getByTitle(title);
52
66
  await (0, test_1.expect)(element).toHaveCount(1);
53
67
  (0, state_1.setActiveElement)(page, element);
54
68
  console.log(`🔍 Found element by title: "${title}"`);
55
- });
69
+ }
56
70
  /**
57
71
  * Finds an element by its test ID (usually `data-testid`).
58
- *
59
- * ```gherkin
72
+ * @example
60
73
  * When I find element by testid "login-form"
61
- * ```
62
- *
63
74
  * @param testid - The data-testid attribute value.
64
75
  */
65
- exports.FindElementByTestId = (0, registry_1.Step)("I find element by testid {string}", async (page, testid) => {
76
+ async function findElementByTestId(page, testid) {
66
77
  const element = page.getByTestId(testid);
67
78
  await (0, test_1.expect)(element).toHaveCount(1);
68
79
  (0, state_1.setActiveElement)(page, element);
69
80
  console.log(`🔍 Found element by testid: "${testid}"`);
70
- });
81
+ }
71
82
  /**
72
83
  * Finds an element by its ARIA role.
73
- *
74
- * ```gherkin
84
+ * @example
75
85
  * When I find element by role "button"
76
- * ```
77
- *
78
86
  * @param role - The ARIA role (e.g., "button", "link", "heading").
79
87
  */
80
- exports.FindElementByRole = (0, registry_1.Step)("I find element by role {string}", async (page, role) => {
88
+ async function findElementByRole(page, role) {
81
89
  const element = page.getByRole(role);
82
90
  await (0, test_1.expect)(element).toHaveCount(1);
83
91
  (0, state_1.setActiveElement)(page, element);
84
92
  console.log(`🔍 Found element by role: "${role}"`);
85
- });
93
+ }
86
94
  /**
87
95
  * Finds an input element by its placeholder text.
88
- *
89
- * ```gherkin
96
+ * @example
90
97
  * When I find element by placeholder text "Enter your email"
91
- * ```
92
- *
93
98
  * @param text - The placeholder text value.
94
99
  */
95
- exports.FindElementByPlaceholder = (0, registry_1.Step)("I find element by placeholder text {string}", async (page, text) => {
100
+ async function findElementByPlaceholder(page, text) {
96
101
  const element = page.getByPlaceholder(text);
97
102
  await (0, test_1.expect)(element).toHaveCount(1);
98
103
  (0, state_1.setActiveElement)(page, element);
99
104
  console.log(`🔍 Found element by placeholder: "${text}"`);
100
- });
105
+ }
101
106
  /**
102
107
  * Finds a form control associated with a specific label text.
103
- *
104
- * ```gherkin
108
+ * @example
105
109
  * When I find element by label text "Password"
106
- * ```
107
- *
108
110
  * @param label - The visible text of the label.
109
111
  */
110
- exports.FindElementByLabel = (0, registry_1.Step)("I find element by label text {string}", async (page, label) => {
112
+ async function findElementByLabel(page, label) {
111
113
  const element = page.getByLabel(label);
112
114
  await (0, test_1.expect)(element).toHaveCount(1);
113
115
  (0, state_1.setActiveElement)(page, element);
114
116
  console.log(`🔍 Found element by label: "${label}"`);
115
- });
117
+ }
116
118
  /**
117
119
  * Finds an element (usually an image) by its alt text.
118
- *
119
- * ```gherkin
120
+ * @example
120
121
  * When I find element by alt text "Company Logo"
121
- * ```
122
- *
123
122
  * @param alt - The value of the alt attribute.
124
123
  */
125
- exports.FindElementByAltText = (0, registry_1.Step)("I find element by alt text {string}", async (page, alt) => {
124
+ async function findElementByAltText(page, alt) {
126
125
  const element = page.getByAltText(alt);
127
126
  await (0, test_1.expect)(element).toHaveCount(1);
128
127
  (0, state_1.setActiveElement)(page, element);
129
128
  console.log(`🔍 Found element by alt text: "${alt}"`);
130
- });
131
- // =============================
132
- // 2. SPECIFIC ELEMENTS (Link/Heading/Name)
133
- // =============================
129
+ }
134
130
  /**
135
131
  * Finds a specific link by its visible text.
136
- * If multiple links match, selects the first one.
137
- *
138
- * ```gherkin
132
+ * @example
139
133
  * When I find link by text "Read More"
140
- * ```
141
- *
142
134
  * @param text - The visible text of the link.
143
135
  */
144
- exports.FindLinkByText = (0, registry_1.Step)("I find link by text {string}", async (page, text) => {
136
+ async function findLinkByText(page, text) {
145
137
  const element = page.getByRole("link", { name: text });
146
- // We use .first() here because links often have duplicates (e.g. footer/header)
147
- // but strict mode usually prefers uniqueness.
148
138
  (0, state_1.setActiveElement)(page, element.first());
149
139
  console.log(`🔍 Found link by text: "${text}"`);
150
- });
140
+ }
151
141
  /**
152
142
  * Finds a heading (h1-h6) by its text content.
153
- * If multiple headings match, selects the first one.
154
- *
155
- * ```gherkin
143
+ * @example
156
144
  * When I find heading by text "Dashboard"
157
- * ```
158
- *
159
145
  * @param text - The text content of the heading.
160
146
  */
161
- exports.FindHeadingByText = (0, registry_1.Step)("I find heading by text {string}", async (page, text) => {
147
+ async function findHeadingByText(page, text) {
162
148
  const element = page.getByRole("heading", { name: text });
163
149
  (0, state_1.setActiveElement)(page, element.first());
164
150
  console.log(`🔍 Found heading by text: "${text}"`);
165
- });
151
+ }
166
152
  /**
167
153
  * Finds an element by its `name` attribute.
168
- * Useful for form fields not easily accessible by label.
169
- *
170
- * ```gherkin
154
+ * @example
171
155
  * When I find element by name "csrf_token"
172
- * ```
173
- *
174
156
  * @param name - The value of the name attribute.
175
157
  */
176
- exports.FindElementByName = (0, registry_1.Step)("I find element by name {string}", async (page, name) => {
177
- // Broad selector for name attribute
158
+ async function findElementByName(page, name) {
178
159
  const element = page.locator(`[name="${name}"]`);
179
160
  await (0, test_1.expect)(element).toHaveCount(1);
180
161
  (0, state_1.setActiveElement)(page, element);
181
162
  console.log(`🔍 Found element by name: "${name}"`);
182
- });
183
- // =============================
184
- // 3. GENERAL FINDING (Multiple)
185
- // =============================
163
+ }
186
164
  /**
187
165
  * Finds all elements matching a CSS selector and stores them as a list.
188
- *
189
- * ```gherkin
166
+ * @example
190
167
  * When I find elements by selector "ul > li"
191
- * ```
192
- *
193
168
  * @param selector - The CSS selector.
194
169
  */
195
- exports.FindElementsBySelector = (0, registry_1.Step)("I find elements by selector {string}", async (page, selector) => {
170
+ async function findElementsBySelector(page, selector) {
196
171
  const elements = page.locator(selector);
197
172
  const count = await elements.count();
198
173
  (0, state_1.setActiveElements)(page, elements);
199
174
  console.log(`🔍 Found ${count} elements with selector: "${selector}"`);
200
- });
175
+ }
201
176
  /**
202
177
  * Finds all headings matching specific text.
203
- *
204
- * ```gherkin
178
+ * @example
205
179
  * When I find headings by text "Article Title"
206
- * ```
207
- *
208
180
  * @param text - The text to match headings against.
209
181
  */
210
- exports.FindHeadingsByText = (0, registry_1.Step)("I find headings by text {string}", async (page, text) => {
182
+ async function findHeadingsByText(page, text) {
211
183
  const elements = page.getByRole("heading", { name: text });
212
184
  (0, state_1.setActiveElements)(page, elements);
213
185
  console.log(`🔍 Found headings matching "${text}"`);
214
- });
186
+ }
215
187
  /**
216
188
  * Finds all buttons matching specific text.
217
189
  * Supports variable aliasing (e.g., "@buttonName").
218
- *
219
- * ```gherkin
190
+ * @example
220
191
  * When I find buttons by text "Add to Cart"
221
- * ```
222
- *
223
192
  * @param text - The button text or an alias (e.g., "@myBtn").
224
193
  */
225
- exports.FindButtonsByText = (0, registry_1.Step)("I find buttons by text {string}", async (page, text) => {
194
+ async function findButtonsByText(page, text) {
226
195
  let searchText = text;
227
- // Handle Alias
228
196
  if (text.startsWith("@")) {
229
197
  const alias = text.slice(1);
230
198
  const val = (0, state_1.getVariable)(page, alias);
@@ -235,128 +203,99 @@ exports.FindButtonsByText = (0, registry_1.Step)("I find buttons by text {string
235
203
  const elements = page.getByRole("button", { name: searchText });
236
204
  (0, state_1.setActiveElements)(page, elements);
237
205
  console.log(`🔍 Found buttons matching "${searchText}"`);
238
- });
239
- // =============================
240
- // 4. GET / REFINE SELECTION
241
- // =============================
206
+ }
242
207
  /**
243
208
  * Selects the first element from the currently stored list of elements.
244
- *
245
- * ```gherkin
209
+ * @example
246
210
  * When I get first element
247
- * ```
248
211
  */
249
- exports.GetFirstElement = (0, registry_1.Step)("I get first element", async (page) => {
212
+ async function getFirstElement(page) {
250
213
  const elements = (0, state_1.getActiveElements)(page);
251
214
  const element = elements.first();
252
215
  (0, state_1.setActiveElement)(page, element);
253
216
  console.log("👉 Selected FIRST element");
254
- });
217
+ }
255
218
  /**
256
219
  * Selects the last element from the currently stored list of elements.
257
- *
258
- * ```gherkin
220
+ * @example
259
221
  * When I get last element
260
- * ```
261
222
  */
262
- exports.GetLastElement = (0, registry_1.Step)("I get last element", async (page) => {
223
+ async function getLastElement(page) {
263
224
  const elements = (0, state_1.getActiveElements)(page);
264
225
  const element = elements.last();
265
226
  (0, state_1.setActiveElement)(page, element);
266
227
  console.log("👉 Selected LAST element");
267
- });
228
+ }
268
229
  /**
269
230
  * Selects the nth element from the currently stored list.
270
231
  * Uses 1-based indexing (e.g., 1st, 2nd, 3rd).
271
- *
272
- * ```gherkin
232
+ * @example
273
233
  * When I get 2nd element
274
234
  * When I get 10th element
275
- * ```
276
- *
277
235
  * @param indexStr - The number captured from the regex (e.g., "2").
278
236
  */
279
- exports.GetNthElement = (0, registry_1.Step)(/^I get (\d+)(?:st|nd|rd|th) element$/, async (page, indexStr) => {
237
+ async function getNthElement(page, indexStr) {
280
238
  const index = parseInt(indexStr, 10);
281
239
  const elements = (0, state_1.getActiveElements)(page);
282
240
  const count = await elements.count();
283
241
  if (index < 1 || index > count) {
284
242
  throw new Error(`❌ Cannot get element #${index} — only ${count} found.`);
285
243
  }
286
- // Playwright is 0-based, Gherkin is 1-based
287
244
  const element = elements.nth(index - 1);
288
245
  (0, state_1.setActiveElement)(page, element);
289
246
  console.log(`👉 Selected element #${index}`);
290
- });
247
+ }
291
248
  /**
292
249
  * Selects the element that currently has browser focus.
293
- *
294
- * ```gherkin
250
+ * @example
295
251
  * When I get focused element
296
- * ```
297
252
  */
298
- exports.GetFocusedElement = (0, registry_1.Step)("I get focused element", async (page) => {
299
- // Use CSS selector for focused element
253
+ async function getFocusedElement(page) {
300
254
  const element = page.locator("*:focus");
301
255
  (0, state_1.setActiveElement)(page, element);
302
256
  console.log("👉 Selected FOCUSED element");
303
- });
304
- // =============================
305
- // 5. INPUTS & TEXTAREAS SPECIFICS
306
- // =============================
257
+ }
307
258
  /**
308
259
  * Finds an input field by its ID attribute.
309
- *
310
- * ```gherkin
260
+ * @example
311
261
  * When I find input by ID "user_email"
312
- * ```
313
- *
314
262
  * @param id - The ID string.
315
263
  */
316
- exports.FindInputById = (0, registry_1.Step)("I find input by ID {string}", async (page, id) => {
264
+ async function findInputById(page, id) {
317
265
  const element = page.locator(`input#${id}`);
318
266
  (0, state_1.setActiveElement)(page, element);
319
267
  console.log(`🔍 Found input by ID: "${id}"`);
320
- });
268
+ }
321
269
  /**
322
270
  * Finds an input field by its name attribute.
323
- *
324
- * ```gherkin
271
+ * @example
325
272
  * When I find input by name "password"
326
- * ```
327
- *
328
273
  * @param name - The name attribute value.
329
274
  */
330
- exports.FindInputByName = (0, registry_1.Step)("I find input by name {string}", async (page, name) => {
275
+ async function findInputByName(page, name) {
331
276
  const element = page.locator(`input[name="${name}"]`);
332
277
  (0, state_1.setActiveElement)(page, element);
333
278
  console.log(`🔍 Found input by name: "${name}"`);
334
- });
279
+ }
335
280
  /**
336
281
  * Finds an input field by its placeholder text.
337
- *
338
- * ```gherkin
282
+ * @example
339
283
  * When I find input by placeholder text "Search products..."
340
- * ```
341
- *
342
284
  * @param placeholder - The placeholder text.
343
285
  */
344
- exports.FindInputByPlaceholder = (0, registry_1.Step)("I find input by placeholder text {string}", async (page, placeholder) => {
286
+ async function findInputByPlaceholder(page, placeholder) {
345
287
  const element = page.locator(`input[placeholder="${placeholder}"]`);
346
288
  (0, state_1.setActiveElement)(page, element);
347
289
  console.log(`🔍 Found input by placeholder: "${placeholder}"`);
348
- });
290
+ }
349
291
  /**
350
292
  * Finds an input field that currently has a specific value.
351
293
  * Supports variable aliasing (e.g., "@storedValue").
352
- *
353
- * ```gherkin
294
+ * @example
354
295
  * When I find input by display value "John"
355
- * ```
356
- *
357
296
  * @param value - The value to match.
358
297
  */
359
- exports.FindInputByValue = (0, registry_1.Step)("I find input by display value {string}", async (page, value) => {
298
+ async function findInputByValue(page, value) {
360
299
  let searchValue = value;
361
300
  if (value.startsWith("@")) {
362
301
  const alias = value.slice(1);
@@ -369,23 +308,17 @@ exports.FindInputByValue = (0, registry_1.Step)("I find input by display value {
369
308
  await (0, test_1.expect)(element).toBeVisible();
370
309
  (0, state_1.setActiveElement)(page, element);
371
310
  console.log(`🔍 Found input with value: "${searchValue}"`);
372
- });
311
+ }
373
312
  /**
374
313
  * Finds a textarea associated with a specific label.
375
- * Fallback mechanism attempts to find the textarea via label if the standard getByLabel returns a generic element.
376
- *
377
- * ```gherkin
314
+ * @example
378
315
  * When I find textarea by label text "Description"
379
- * ```
380
- *
381
316
  * @param label - The visible text of the label.
382
317
  */
383
- exports.FindTextareaByLabel = (0, registry_1.Step)("I find textarea by label text {string}", async (page, label) => {
318
+ async function findTextareaByLabel(page, label) {
384
319
  const element = page.getByLabel(label).locator("textarea").first();
385
- // Fallback if strict label matching fails, try locator strategy
386
320
  const count = await element.count();
387
321
  if (count === 0) {
388
- // Try generic label finding
389
322
  const altElement = page.getByLabel(label);
390
323
  (0, state_1.setActiveElement)(page, altElement);
391
324
  }
@@ -393,23 +326,44 @@ exports.FindTextareaByLabel = (0, registry_1.Step)("I find textarea by label tex
393
326
  (0, state_1.setActiveElement)(page, element);
394
327
  }
395
328
  console.log(`🔍 Found textarea by label: "${label}"`);
396
- });
397
- // =============================
398
- // 6. UTILITIES (Store Text)
399
- // =============================
329
+ }
400
330
  /**
401
331
  * Reads the text content of the currently active element and stores it in a variable.
402
- *
403
- * ```gherkin
332
+ * @example
404
333
  * When I store element text as "confirmationCode"
405
- * ```
406
- *
407
334
  * @param alias - The name of the variable to store the text in (without "@").
408
335
  */
409
- exports.StoreElementText = (0, registry_1.Step)("I store element text as {string}", async (page, alias) => {
336
+ async function storeElementText(page, alias) {
410
337
  const element = (0, state_1.getActiveElement)(page);
411
338
  const text = await element.textContent();
412
339
  const cleanText = text?.trim() || "";
413
340
  (0, state_1.setVariable)(page, alias, cleanText);
414
341
  console.log(`💾 Stored text "${cleanText}" as variable "@${alias}"`);
415
- });
342
+ }
343
+ // ==================================================
344
+ // GLUE STEPS
345
+ // ==================================================
346
+ (0, registry_1.Step)("I find element by selector {string}", findElementBySelector);
347
+ (0, registry_1.Step)("I find element by text {string}", findElementByText);
348
+ (0, registry_1.Step)("I find element by title {string}", findElementByTitle);
349
+ (0, registry_1.Step)("I find element by testid {string}", findElementByTestId);
350
+ (0, registry_1.Step)("I find element by role {string}", findElementByRole);
351
+ (0, registry_1.Step)("I find element by placeholder text {string}", findElementByPlaceholder);
352
+ (0, registry_1.Step)("I find element by label text {string}", findElementByLabel);
353
+ (0, registry_1.Step)("I find element by alt text {string}", findElementByAltText);
354
+ (0, registry_1.Step)("I find link by text {string}", findLinkByText);
355
+ (0, registry_1.Step)("I find heading by text {string}", findHeadingByText);
356
+ (0, registry_1.Step)("I find element by name {string}", findElementByName);
357
+ (0, registry_1.Step)("I find elements by selector {string}", findElementsBySelector);
358
+ (0, registry_1.Step)("I find headings by text {string}", findHeadingsByText);
359
+ (0, registry_1.Step)("I find buttons by text {string}", findButtonsByText);
360
+ (0, registry_1.Step)("I get first element", getFirstElement);
361
+ (0, registry_1.Step)("I get last element", getLastElement);
362
+ (0, registry_1.Step)(/^I get (\d+)(?:st|nd|rd|th) element$/, getNthElement);
363
+ (0, registry_1.Step)("I get focused element", getFocusedElement);
364
+ (0, registry_1.Step)("I find input by ID {string}", findInputById);
365
+ (0, registry_1.Step)("I find input by name {string}", findInputByName);
366
+ (0, registry_1.Step)("I find input by placeholder text {string}", findInputByPlaceholder);
367
+ (0, registry_1.Step)("I find input by display value {string}", findInputByValue);
368
+ (0, registry_1.Step)("I find textarea by label text {string}", findTextareaByLabel);
369
+ (0, registry_1.Step)("I store element text as {string}", storeElementText);
@@ -1,29 +1,6 @@
1
1
  /**
2
- * A "Swiss Army Knife" step for filling forms, performing assertions, and executing mixed workflows.
3
- * It iterates through a Data Table and performs actions based on the `Target` and `Value` columns.
4
- *
5
- * ```gherkin
6
- * When I fill the following {string} form data
7
- * ```
8
- *
9
- * @remarks
10
- * **Columns:**
11
- * - `Target`: The CSS selector, or a special keyword (request:, set:localStorage:, wait).
12
- * - `Value`: The value to input, the action (click, check), or assertion pattern.
13
- *
14
- * **Supported UI Actions:**
15
- * - **Fill:** Default behavior. Types `Value` into `Target`.
16
- * - **Click:** Set `Value` to "click".
17
- * - **Check:** Set `Value` to "check".
18
- * - **Select:** Set `Value` to "select" (selects first option).
19
- * - **Assert Visible:** Set `Value` to "assert:visible".
20
- * - **Assert Text:** Set `Value` to "assert:text:Expected Text".
21
- *
22
- * **Supported Special Actions:**
23
- * - **API Request:** Target = `request:METHOD:URL`, Value = `payload_filename.json`.
24
- * - **Local Storage:** Target = `set:localStorage:key`, Value = `value`.
25
- * - **Wait:** Target = `wait`, Value = `wait:1000` (ms).
26
- *
2
+ * A "Swiss Army Knife" function for filling forms, performing assertions, and executing mixed workflows.
3
+ * Iterates through a Data Table and performs actions based on the Target and Value columns.
27
4
  * @example
28
5
  * When I fill the following "Login Flow" form data:
29
6
  * | Target | Value |
@@ -33,6 +10,21 @@
33
10
  * | wait | wait:500 |
34
11
  * | .error-msg | assert:visible |
35
12
  * | request:GET:/api/status | body: {} |
13
+ * @remarks
14
+ * **Columns:**
15
+ * - Target: The CSS selector, or a special keyword (request:, set:localStorage:, wait).
16
+ * - Value: The value to input, the action (click, check), or assertion pattern.
17
+ * **Supported UI Actions:**
18
+ * - Fill: Default behavior. Types Value into Target.
19
+ * - Click: Set Value to "click".
20
+ * - Check: Set Value to "check".
21
+ * - Select: Set Value to "select".
22
+ * - Assert Visible: Set Value to "assert:visible".
23
+ * - Assert Text: Set Value to "assert:text:Expected Text".
24
+ * **Supported Special Actions:**
25
+ * - API Request: Target = "request:METHOD:URL", Value = "payload_filename.json".
26
+ * - Local Storage: Target = "set:localStorage:key", Value = "value".
27
+ * - Wait: Target = "wait", Value = "wait:1000" (ms).
36
28
  */
37
- export declare const FillFormData: void;
29
+ export declare function fillFormData(page: any, formName: string, table: any): Promise<void>;
38
30
  //# sourceMappingURL=form.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"form.d.ts","sourceRoot":"","sources":["../../../src/backend/actions/form.ts"],"names":[],"mappings":"AAkFA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,eAAO,MAAM,YAAY,MAgIxB,CAAC"}
1
+ {"version":3,"file":"form.d.ts","sourceRoot":"","sources":["../../../src/backend/actions/form.ts"],"names":[],"mappings":"AAuFA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAsB,YAAY,CAAC,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CA6HzF"}