playwright-cucumber-ts-steps 1.0.1 → 1.0.3

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 (137) hide show
  1. package/README.md +270 -244
  2. package/dist/backend/actions/formTable.js +34 -0
  3. package/dist/backend/actions/index.js +5 -0
  4. package/dist/backend/actions/interactions.js +23 -0
  5. package/dist/backend/actions/navigation.js +19 -0
  6. package/dist/backend/api/assertions.js +26 -0
  7. package/dist/backend/api/index.js +5 -0
  8. package/dist/backend/api/mock.js +75 -0
  9. package/dist/backend/api/requests.js +86 -0
  10. package/dist/backend/api/state.js +15 -0
  11. package/dist/backend/assertions/expectVisible.js +8 -0
  12. package/dist/backend/assertions/index.js +5 -0
  13. package/dist/backend/assertions/pageState.js +25 -0
  14. package/dist/backend/assertions/text.js +20 -0
  15. package/dist/backend/assertions/visibility.js +20 -0
  16. package/dist/backend/auth/index.js +71 -0
  17. package/dist/backend/db/index.js +6 -0
  18. package/dist/backend/db/state.js +24 -0
  19. package/dist/backend/db/steps.js +43 -0
  20. package/dist/backend/elements/alerts.js +21 -0
  21. package/dist/backend/elements/forms.js +59 -0
  22. package/dist/backend/elements/frames.js +25 -0
  23. package/dist/backend/elements/index.js +5 -0
  24. package/dist/core/registry.js +20 -0
  25. package/dist/core/runner.js +151 -0
  26. package/dist/index.js +10 -0
  27. package/dist/reporting/index.js +43 -0
  28. package/package.json +19 -101
  29. package/LICENSE +0 -21
  30. package/lib/actions/clickSteps.d.ts +0 -251
  31. package/lib/actions/clickSteps.js +0 -415
  32. package/lib/actions/cookieSteps.d.ts +0 -18
  33. package/lib/actions/cookieSteps.js +0 -93
  34. package/lib/actions/debugSteps.d.ts +0 -14
  35. package/lib/actions/debugSteps.js +0 -23
  36. package/lib/actions/elementFindSteps.d.ts +0 -668
  37. package/lib/actions/elementFindSteps.js +0 -931
  38. package/lib/actions/fillFormSteps.d.ts +0 -69
  39. package/lib/actions/fillFormSteps.js +0 -237
  40. package/lib/actions/index.d.ts +0 -11
  41. package/lib/actions/index.js +0 -28
  42. package/lib/actions/inputSteps.d.ts +0 -218
  43. package/lib/actions/inputSteps.js +0 -343
  44. package/lib/actions/interceptionSteps.d.ts +0 -169
  45. package/lib/actions/interceptionSteps.js +0 -291
  46. package/lib/actions/miscSteps.d.ts +0 -645
  47. package/lib/actions/miscSteps.js +0 -1061
  48. package/lib/actions/mouseSteps.d.ts +0 -143
  49. package/lib/actions/mouseSteps.js +0 -234
  50. package/lib/actions/scrollSteps.d.ts +0 -82
  51. package/lib/actions/scrollSteps.js +0 -123
  52. package/lib/actions/storageSteps.d.ts +0 -174
  53. package/lib/actions/storageSteps.js +0 -292
  54. package/lib/assertions/buttonAndTextVisibilitySteps.d.ts +0 -245
  55. package/lib/assertions/buttonAndTextVisibilitySteps.js +0 -401
  56. package/lib/assertions/cookieSteps.d.ts +0 -75
  57. package/lib/assertions/cookieSteps.js +0 -113
  58. package/lib/assertions/elementSteps.d.ts +0 -264
  59. package/lib/assertions/elementSteps.js +0 -388
  60. package/lib/assertions/formInputSteps.d.ts +0 -248
  61. package/lib/assertions/formInputSteps.js +0 -350
  62. package/lib/assertions/index.d.ts +0 -10
  63. package/lib/assertions/index.js +0 -27
  64. package/lib/assertions/interceptionRequestsSteps.d.ts +0 -353
  65. package/lib/assertions/interceptionRequestsSteps.js +0 -593
  66. package/lib/assertions/locationSteps.d.ts +0 -217
  67. package/lib/assertions/locationSteps.js +0 -310
  68. package/lib/assertions/roleTestIdSteps.d.ts +0 -159
  69. package/lib/assertions/roleTestIdSteps.js +0 -221
  70. package/lib/assertions/semanticSteps.d.ts +0 -176
  71. package/lib/assertions/semanticSteps.js +0 -252
  72. package/lib/assertions/storageSteps.d.ts +0 -149
  73. package/lib/assertions/storageSteps.js +0 -210
  74. package/lib/assertions/visualSteps.d.ts +0 -74
  75. package/lib/assertions/visualSteps.js +0 -209
  76. package/lib/custom_setups/loginHooks.d.ts +0 -1
  77. package/lib/custom_setups/loginHooks.js +0 -130
  78. package/lib/helpers/checkPeerDeps.d.ts +0 -1
  79. package/lib/helpers/checkPeerDeps.js +0 -19
  80. package/lib/helpers/compareSnapshots.d.ts +0 -6
  81. package/lib/helpers/compareSnapshots.js +0 -20
  82. package/lib/helpers/hooks.d.ts +0 -1
  83. package/lib/helpers/hooks.js +0 -210
  84. package/lib/helpers/utils/fakerUtils.d.ts +0 -1
  85. package/lib/helpers/utils/fakerUtils.js +0 -60
  86. package/lib/helpers/utils/index.d.ts +0 -4
  87. package/lib/helpers/utils/index.js +0 -20
  88. package/lib/helpers/utils/optionsUtils.d.ts +0 -24
  89. package/lib/helpers/utils/optionsUtils.js +0 -88
  90. package/lib/helpers/utils/resolveUtils.d.ts +0 -6
  91. package/lib/helpers/utils/resolveUtils.js +0 -72
  92. package/lib/helpers/utils/sessionUtils.d.ts +0 -3
  93. package/lib/helpers/utils/sessionUtils.js +0 -40
  94. package/lib/helpers/world.d.ts +0 -34
  95. package/lib/helpers/world.js +0 -110
  96. package/lib/iframes/frames.d.ts +0 -1
  97. package/lib/iframes/frames.js +0 -11
  98. package/lib/index.d.ts +0 -10
  99. package/lib/index.js +0 -28
  100. package/lib/register.d.ts +0 -1
  101. package/lib/register.js +0 -6
  102. package/src/actions/clickSteps.ts +0 -429
  103. package/src/actions/cookieSteps.ts +0 -95
  104. package/src/actions/debugSteps.ts +0 -21
  105. package/src/actions/elementFindSteps.ts +0 -961
  106. package/src/actions/fillFormSteps.ts +0 -270
  107. package/src/actions/index.ts +0 -12
  108. package/src/actions/inputSteps.ts +0 -354
  109. package/src/actions/interceptionSteps.ts +0 -325
  110. package/src/actions/miscSteps.ts +0 -1144
  111. package/src/actions/mouseSteps.ts +0 -256
  112. package/src/actions/scrollSteps.ts +0 -122
  113. package/src/actions/storageSteps.ts +0 -308
  114. package/src/assertions/buttonAndTextVisibilitySteps.ts +0 -436
  115. package/src/assertions/cookieSteps.ts +0 -131
  116. package/src/assertions/elementSteps.ts +0 -432
  117. package/src/assertions/formInputSteps.ts +0 -377
  118. package/src/assertions/index.ts +0 -11
  119. package/src/assertions/interceptionRequestsSteps.ts +0 -640
  120. package/src/assertions/locationSteps.ts +0 -315
  121. package/src/assertions/roleTestIdSteps.ts +0 -254
  122. package/src/assertions/semanticSteps.ts +0 -267
  123. package/src/assertions/storageSteps.ts +0 -250
  124. package/src/assertions/visualSteps.ts +0 -275
  125. package/src/custom_setups/loginHooks.ts +0 -154
  126. package/src/helpers/checkPeerDeps.ts +0 -19
  127. package/src/helpers/compareSnapshots.ts +0 -35
  128. package/src/helpers/hooks.ts +0 -212
  129. package/src/helpers/utils/fakerUtils.ts +0 -64
  130. package/src/helpers/utils/index.ts +0 -4
  131. package/src/helpers/utils/optionsUtils.ts +0 -104
  132. package/src/helpers/utils/resolveUtils.ts +0 -74
  133. package/src/helpers/utils/sessionUtils.ts +0 -36
  134. package/src/helpers/world.ts +0 -119
  135. package/src/iframes/frames.ts +0 -15
  136. package/src/index.ts +0 -18
  137. package/src/register.ts +0 -4
@@ -1,388 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Then_I_see_element_exists = Then_I_see_element_exists;
4
- exports.Then_I_see_stored_element_exists = Then_I_see_stored_element_exists;
5
- exports.Then_I_see_stored_element_does_not_exist = Then_I_see_stored_element_does_not_exist;
6
- exports.Then_I_see_stored_element_is_visible = Then_I_see_stored_element_is_visible;
7
- exports.Then_I_see_stored_element_is_not_visible = Then_I_see_stored_element_is_not_visible;
8
- exports.Then_I_see_element_does_not_exist = Then_I_see_element_does_not_exist;
9
- exports.Then_I_see_element_is_visible = Then_I_see_element_is_visible;
10
- exports.Then_I_see_element_is_not_visible = Then_I_see_element_is_not_visible;
11
- exports.Then_I_see_element_attribute_equals = Then_I_see_element_attribute_equals;
12
- exports.Then_I_see_stored_element_attribute_equals = Then_I_see_stored_element_attribute_equals;
13
- exports.Then_I_see_stored_element_has_attribute = Then_I_see_stored_element_has_attribute;
14
- exports.Then_I_see_stored_element_attribute_contains = Then_I_see_stored_element_attribute_contains;
15
- exports.Then_I_see_element_attribute_contains = Then_I_see_element_attribute_contains;
16
- exports.Then_I_see_element_has_attribute = Then_I_see_element_has_attribute;
17
- const cucumber_1 = require("@cucumber/cucumber");
18
- const test_1 = require("@playwright/test");
19
- // ===================================================================================
20
- // ASSERTIONS: ELEMENT EXISTENCE (IN DOM)
21
- // ===================================================================================
22
- /**
23
- * Asserts that at least one element matching the given selector exists in the DOM.
24
- * It does not necessarily check for visibility.
25
- *
26
- * ```gherkin
27
- * Then I see element {string} exists
28
- * ```
29
- *
30
- * @param selector - The CSS selector of the element expected to exist.
31
- *
32
- * @example
33
- * Then I see element ".user-profile-card" exists
34
- *
35
- * @remarks
36
- * This step uses Playwright's `expect(locator).toHaveCount(1)` as a robust way to
37
- * assert that exactly one matching element is present in the DOM. If multiple elements
38
- * match, it will still pass as long as at least one exists (though `toHaveCount(1)`
39
- * would strictly mean *only one*). For asserting multiple elements, use "Then I count X elements".
40
- * @category Assertion Steps
41
- */
42
- async function Then_I_see_element_exists(selector) {
43
- const locator = this.page.locator(selector);
44
- // Using toHaveCount(1) for "exists" implies expecting at least one, or exactly one.
45
- // If the intent is *at least one*, expect(locator).first().waitFor({state: 'attached'}) is also an option.
46
- // For strict "exists", toHaveCount(1) is good if you expect uniqueness.
47
- await (0, test_1.expect)(locator).toHaveCount(1, { timeout: 5000 });
48
- this.log?.(`✅ Verified element "${selector}" exists in the DOM.`);
49
- }
50
- (0, cucumber_1.Then)(/^I see element "([^"]+)" exists$/, Then_I_see_element_exists);
51
- /**
52
- * Asserts that the previously stored element exists in the DOM.
53
- * This checks for its presence, not necessarily its visibility.
54
- *
55
- * ```gherkin
56
- * Then I see element exists
57
- * ```
58
- *
59
- * @example
60
- * When I find element by selector ".my-dialog"
61
- * Then I see element exists
62
- *
63
- * @remarks
64
- * This step requires a preceding step that sets the {@link CustomWorld.element | current element}.
65
- * It asserts that the stored element is attached to the DOM.
66
- * @category Assertion Steps
67
- */
68
- async function Then_I_see_stored_element_exists() {
69
- if (!this.element)
70
- throw new Error("No element stored in context. Use a 'find' step before asserting.");
71
- // Playwright's toBeAttached is the most robust way to check for DOM existence
72
- await (0, test_1.expect)(this.element).toBeAttached({ timeout: 5000 });
73
- this.log?.(`✅ Verified stored element exists in the DOM.`);
74
- }
75
- (0, cucumber_1.Then)("I see element exists", Then_I_see_stored_element_exists);
76
- /**
77
- * Asserts that the previously stored element does NOT exist in the DOM.
78
- *
79
- * ```gherkin
80
- * Then I see element does not exist
81
- * ```
82
- *
83
- * @example
84
- * When I find element by selector "#deleted-item"
85
- * Then I see element does not exist
86
- *
87
- * @remarks
88
- * This step requires a preceding step that sets the {@link CustomWorld.element | current element}.
89
- * It asserts that the stored element is detached from the DOM.
90
- * @category Assertion Steps
91
- */
92
- async function Then_I_see_stored_element_does_not_exist() {
93
- if (!this.element)
94
- throw new Error("No element stored in context. Use a 'find' step before asserting.");
95
- // Playwright's not.toBeAttached is the most robust way to check for DOM non-existence
96
- await (0, test_1.expect)(this.element).not.toBeAttached({ timeout: 5000 });
97
- this.log?.(`✅ Verified stored element does NOT exist in the DOM.`);
98
- }
99
- (0, cucumber_1.Then)("I see element does not exist", Then_I_see_stored_element_does_not_exist);
100
- // ===================================================================================
101
- // ASSERTIONS: ELEMENT VISIBILITY (Stored Element)
102
- // ===================================================================================
103
- /**
104
- * Asserts that the previously stored element is visible in the viewport.
105
- *
106
- * ```gherkin
107
- * Then I see element is visible
108
- * ```
109
- *
110
- * @example
111
- * When I find element by selector ".success-message"
112
- * Then I see element is visible
113
- *
114
- * @remarks
115
- * This step requires a preceding step that sets the {@link CustomWorld.element | current element}.
116
- * It uses Playwright's `expect(locator).toBeVisible()` which automatically waits
117
- * for the element to become visible.
118
- * @category Assertion Steps
119
- */
120
- async function Then_I_see_stored_element_is_visible() {
121
- if (!this.element)
122
- throw new Error("No element stored in context to check visibility.");
123
- await (0, test_1.expect)(this.element).toBeVisible({ timeout: 5000 });
124
- this.log?.(`✅ Verified stored element is visible.`);
125
- }
126
- (0, cucumber_1.Then)("I see element is visible", Then_I_see_stored_element_is_visible);
127
- /**
128
- * Asserts that the previously stored element is NOT visible in the viewport.
129
- *
130
- * ```gherkin
131
- * Then I see element is not visible
132
- * ```
133
- *
134
- * @example
135
- * When I find element by selector ".loading-spinner"
136
- * Then I see element is not visible
137
- *
138
- * @remarks
139
- * This step requires a preceding step that sets the {@link CustomWorld.element | current element}.
140
- * It uses Playwright's `expect(locator).not.toBeVisible()` which automatically waits
141
- * for the element to become hidden.
142
- * @category Assertion Steps
143
- */
144
- async function Then_I_see_stored_element_is_not_visible() {
145
- if (!this.element)
146
- throw new Error("No element stored in context to check non-visibility.");
147
- await (0, test_1.expect)(this.element).not.toBeVisible({ timeout: 5000 });
148
- this.log?.(`✅ Verified stored element is NOT visible.`);
149
- }
150
- (0, cucumber_1.Then)("I see element is not visible", Then_I_see_stored_element_is_not_visible);
151
- // ===================================================================================
152
- // ASSERTIONS: ELEMENT EXISTENCE (Absence by Selector)
153
- // ===================================================================================
154
- /**
155
- * Asserts that no element matching the given selector exists in the DOM.
156
- *
157
- * ```gherkin
158
- * Then I see element {string} does not exist
159
- * ```
160
- *
161
- * @param selector - The CSS selector of the element expected NOT to exist.
162
- *
163
- * @example
164
- * Then I see element ".old-feature-flag" does not exist
165
- *
166
- * @remarks
167
- * This step uses Playwright's `expect(locator).toHaveCount(0)` as a robust way to
168
- * assert that no matching elements are present in the DOM.
169
- * @category Assertion Steps
170
- */
171
- async function Then_I_see_element_does_not_exist(selector) {
172
- const locator = this.page.locator(selector);
173
- await (0, test_1.expect)(locator).toHaveCount(0, { timeout: 5000 });
174
- this.log?.(`✅ Verified element "${selector}" does NOT exist in the DOM.`);
175
- }
176
- (0, cucumber_1.Then)(/^I see element "([^"]+)" does not exist$/, Then_I_see_element_does_not_exist);
177
- // ===================================================================================
178
- // ASSERTIONS: ELEMENT VISIBILITY (by Selector)
179
- // ===================================================================================
180
- /**
181
- * Asserts that an element matching the given selector is visible in the viewport.
182
- *
183
- * ```gherkin
184
- * Then I see element {string} is visible
185
- * ```
186
- *
187
- * @param selector - The CSS selector of the element expected to be visible.
188
- *
189
- * @example
190
- * Then I see element ".main-content" is visible
191
- *
192
- * @remarks
193
- * This step uses Playwright's `expect(locator).toBeVisible()` which automatically waits
194
- * for the element to become visible.
195
- * @category Assertion Steps
196
- */
197
- async function Then_I_see_element_is_visible(selector) {
198
- const locator = this.page.locator(selector);
199
- await (0, test_1.expect)(locator).toBeVisible({ timeout: 5000 });
200
- this.log?.(`✅ Verified element "${selector}" is visible.`);
201
- }
202
- (0, cucumber_1.Then)(/^I see element "([^"]+)" is visible$/, Then_I_see_element_is_visible);
203
- /**
204
- * Asserts that an element matching the given selector is NOT visible in the viewport.
205
- *
206
- * ```gherkin
207
- * Then I see element {string} is not visible
208
- * ```
209
- *
210
- * @param selector - The CSS selector of the element expected NOT to be visible.
211
- *
212
- * @example
213
- * Then I see element ".modal-overlay" is not visible
214
- *
215
- * @remarks
216
- * This step uses Playwright's `expect(locator).not.toBeVisible()` which automatically waits
217
- * for the element to become hidden.
218
- * @category Assertion Steps
219
- */
220
- async function Then_I_see_element_is_not_visible(selector) {
221
- const locator = this.page.locator(selector);
222
- await (0, test_1.expect)(locator).not.toBeVisible({ timeout: 5000 });
223
- this.log?.(`✅ Verified element "${selector}" is NOT visible.`);
224
- }
225
- (0, cucumber_1.Then)(/^I see element "([^"]+)" is not visible$/, Then_I_see_element_is_not_visible);
226
- // ===================================================================================
227
- // ASSERTIONS: ATTRIBUTE VALUES
228
- // ===================================================================================
229
- /**
230
- * Asserts that an element matching the given selector has a specific attribute with an exact value.
231
- *
232
- * ```gherkin
233
- * Then I see element {string} attribute {string} equals {string}
234
- * ```
235
- *
236
- * @param selector - The CSS selector of the element to check.
237
- * @param attribute - The name of the attribute (e.g., "id", "class", "data-test").
238
- * @param expectedValue - The exact expected value of the attribute.
239
- *
240
- * @example
241
- * Then I see element ".submit-button" attribute "disabled" equals "true"
242
- *
243
- * @remarks
244
- * This step uses Playwright's `expect(locator).toHaveAttribute()`.
245
- * @category Attribute Assertion Steps
246
- */
247
- async function Then_I_see_element_attribute_equals(selector, attribute, expectedValue) {
248
- const locator = this.page.locator(selector);
249
- await (0, test_1.expect)(locator).toHaveAttribute(attribute, expectedValue, { timeout: 5000 });
250
- this.log?.(`✅ Verified element "${selector}" has attribute "${attribute}" equal to "${expectedValue}".`);
251
- }
252
- (0, cucumber_1.Then)(/^I see element "([^"]+)" attribute "([^"]+)" equals "(.*)"$/, Then_I_see_element_attribute_equals);
253
- /**
254
- * Asserts that the previously stored element has a specific attribute with an exact value.
255
- *
256
- * ```gherkin
257
- * Then I see element attribute {string} equals {string}
258
- * ```
259
- *
260
- * @param attr - The name of the attribute to check.
261
- * @param expectedValue - The exact expected value of the attribute.
262
- *
263
- * @example
264
- * When I find element by selector "input[name='rememberMe']"
265
- * Then I see element attribute "checked" equals "checked"
266
- *
267
- * @remarks
268
- * This step requires a preceding step that sets the {@link CustomWorld.element | current element}.
269
- * It uses Playwright's `expect(locator).toHaveAttribute()`.
270
- * @category Attribute Assertion Steps
271
- */
272
- async function Then_I_see_stored_element_attribute_equals(attr, expectedValue) {
273
- if (!this.element) {
274
- throw new Error("No element is currently selected. Use a 'find' step before asserting its attributes.");
275
- }
276
- await (0, test_1.expect)(this.element).toHaveAttribute(attr, expectedValue, { timeout: 5000 });
277
- this.log?.(`✅ Verified stored element has attribute "${attr}" equal to "${expectedValue}".`);
278
- }
279
- (0, cucumber_1.Then)('I see element attribute "{word}" equals {string}', Then_I_see_stored_element_attribute_equals);
280
- /**
281
- * Asserts that the previously stored element has a specific attribute, regardless of its value.
282
- *
283
- * ```gherkin
284
- * Then I see element has attribute {string}
285
- * ```
286
- *
287
- * @param attr - The name of the attribute expected to exist.
288
- *
289
- * @example
290
- * When I find element by selector "img.user-avatar"
291
- * Then I see element has attribute "alt"
292
- *
293
- * @remarks
294
- * This step requires a preceding step that sets the {@link CustomWorld.element | current element}.
295
- * It retrieves the attribute's value and asserts that it's not `null` (meaning the attribute is present).
296
- * @category Attribute Assertion Steps
297
- */
298
- async function Then_I_see_stored_element_has_attribute(attr) {
299
- if (!this.element)
300
- throw new Error("No element stored in context to check for attribute.");
301
- // Use Playwright's expect.toHaveAttribute for robust checking of existence (value can be empty string, but not null)
302
- // For simply checking existence, we can assert that the attribute is not null or undefined.
303
- const attributeValue = await this.element.getAttribute(attr, { timeout: 5000 });
304
- (0, test_1.expect)(attributeValue).not.toBeNull();
305
- this.log?.(`✅ Verified stored element has attribute "${attr}".`);
306
- }
307
- (0, cucumber_1.Then)("I see element has attribute {string}", Then_I_see_stored_element_has_attribute);
308
- /**
309
- * Asserts that the previously stored element's specific attribute contains a given substring.
310
- *
311
- * ```gherkin
312
- * Then I see element attribute {string} contains {string}
313
- * ```
314
- *
315
- * @param attr - The name of the attribute to check.
316
- * @param part - The substring expected to be contained within the attribute's value.
317
- *
318
- * @example
319
- * When I find element by selector ".product-image"
320
- * Then I see element attribute "src" contains "thumbnail"
321
- *
322
- * @remarks
323
- * This step requires a preceding step that sets the {@link CustomWorld.element | current element}.
324
- * It retrieves the attribute's value and asserts that it includes the `part` substring.
325
- * @category Attribute Assertion Steps
326
- */
327
- async function Then_I_see_stored_element_attribute_contains(attr, part) {
328
- if (!this.element)
329
- throw new Error("No element stored in context to check attribute content.");
330
- // Use Playwright's expect.toHaveAttribute with a regex for 'contains' check
331
- await (0, test_1.expect)(this.element).toHaveAttribute(attr, new RegExp(part), { timeout: 5000 });
332
- this.log?.(`✅ Verified stored element attribute "${attr}" contains "${part}".`);
333
- }
334
- (0, cucumber_1.Then)('I see element attribute "{word}" contains {string}', Then_I_see_stored_element_attribute_contains);
335
- /**
336
- * Asserts that an element matching the given selector has a specific attribute containing a given substring.
337
- *
338
- * ```gherkin
339
- * Then I see element {string} attribute {string} contains {string}
340
- * ```
341
- *
342
- * @param selector - The CSS selector of the element to check.
343
- * @param attribute - The name of the attribute.
344
- * @param substring - The substring expected to be contained within the attribute's value.
345
- *
346
- * @example
347
- * Then I see element "a.download-link" attribute "href" contains ".pdf"
348
- *
349
- * @remarks
350
- * This step retrieves the attribute's value from the element matching the selector
351
- * and asserts that it includes the `substring`.
352
- * @category Attribute Assertion Steps
353
- */
354
- async function Then_I_see_element_attribute_contains(selector, attribute, substring) {
355
- const locator = this.page.locator(selector);
356
- // Use Playwright's expect.toHaveAttribute with a regex for 'contains' check
357
- await (0, test_1.expect)(locator).toHaveAttribute(attribute, new RegExp(substring), { timeout: 5000 });
358
- this.log?.(`✅ Verified element "${selector}" attribute "${attribute}" contains "${substring}".`);
359
- }
360
- (0, cucumber_1.Then)(/^I see element "([^"]+)" attribute "([^"]+)" contains "(.*)"$/, Then_I_see_element_attribute_contains);
361
- /**
362
- * Asserts that an element matching the given selector has a specific attribute, regardless of its value.
363
- *
364
- * ```gherkin
365
- * Then I see element {string} has attribute {string}
366
- * ```
367
- *
368
- * @param selector - The CSS selector of the element to check.
369
- * @param attribute - The name of the attribute expected to exist.
370
- *
371
- * @example
372
- * Then I see element "img.avatar" has attribute "src"
373
- *
374
- * @remarks
375
- * This step retrieves the attribute's value from the element matching the selector
376
- * and asserts that it's not `null` (meaning the attribute is present).
377
- * @category Attribute Assertion Steps
378
- */
379
- async function Then_I_see_element_has_attribute(selector, attribute) {
380
- const locator = this.page.locator(selector);
381
- // Playwright's toHaveAttribute with an empty string or regex can assert existence effectively.
382
- // toHaveAttribute(attr, /.+/) ensures it exists and has *some* non-empty value.
383
- // For just existence, checking if getAttribute is not null is explicit.
384
- const attributeValue = await locator.getAttribute(attribute, { timeout: 5000 });
385
- (0, test_1.expect)(attributeValue).not.toBeNull();
386
- this.log?.(`✅ Verified element "${selector}" has attribute "${attribute}".`);
387
- }
388
- (0, cucumber_1.Then)(/^I see element "([^"]+)" has attribute "([^"]+)"$/, Then_I_see_element_has_attribute);
@@ -1,248 +0,0 @@
1
- import { CustomWorld } from "../helpers/world";
2
- /**
3
- * Asserts that an input element matching the given selector has an exact expected value.
4
- *
5
- * ```gherkin
6
- * Then I see input {string} has value {string}
7
- * ```
8
- *
9
- * @param selector - The CSS selector of the input element (e.g., "input[name='email']").
10
- * @param expectedValue - The exact value the input is expected to have.
11
- *
12
- * @example
13
- * Then I see input "input[name='email']" has value "user@example.com"
14
- *
15
- * @remarks
16
- * This step uses Playwright's `expect(locator).toHaveValue()` which automatically waits
17
- * for the input to have the specified value.
18
- * @category Input Assertion Steps
19
- */
20
- export declare function Then_I_see_input_has_value(this: CustomWorld, selector: string, expectedValue: string): Promise<void>;
21
- /**
22
- * Asserts that the previously stored input element has an exact expected value.
23
- *
24
- * ```gherkin
25
- * Then I see input value {string}
26
- * ```
27
- *
28
- * @param expectedValue - The exact value the stored input is expected to have.
29
- *
30
- * @example
31
- * When I find element by selector "input[name='email']"
32
- * Then I see input value "user@example.com"
33
- *
34
- * @remarks
35
- * This step requires a preceding step that sets the {@link CustomWorld.element | current element}
36
- * to an input element. It uses Playwright's `locator.inputValue()` to get the current value
37
- * and asserts strict equality.
38
- * @category Input Assertion Steps
39
- */
40
- export declare function Then_I_see_stored_input_value(this: CustomWorld, expectedValue: string): Promise<void>;
41
- /**
42
- * Asserts that the previously stored input element's value contains a given substring.
43
- *
44
- * ```gherkin
45
- * Then I see input value contains {string}
46
- * ```
47
- *
48
- * @param part - The substring expected to be contained within the input's value.
49
- *
50
- * @example
51
- * When I find element by selector "input[name='email']"
52
- * Then I see input value contains "@gmail.com"
53
- *
54
- * @remarks
55
- * This step requires a preceding step that sets the {@link CustomWorld.element | current element}
56
- * to an input element. It uses Playwright's `locator.inputValue()` and then checks for substring presence.
57
- * @category Input Assertion Steps
58
- */
59
- export declare function Then_I_see_stored_input_value_contains(this: CustomWorld, part: string): Promise<void>;
60
- /**
61
- * Asserts that an input element matching the given selector's value contains a given substring.
62
- *
63
- * ```gherkin
64
- * Then I see input {string} value contains {string}
65
- * ```
66
- *
67
- * @param selector - The CSS selector of the input element.
68
- * @param partial - The substring expected to be contained within the input's value.
69
- *
70
- * @example
71
- * Then I see input "input[name='email']" value contains "@gmail.com"
72
- *
73
- * @remarks
74
- * This step uses Playwright's `locator.inputValue()` and asserts that the value includes the substring.
75
- * @category Input Assertion Steps
76
- */
77
- export declare function Then_I_see_input_value_contains(this: CustomWorld, selector: string, partial: string): Promise<void>;
78
- /**
79
- * Asserts that a textarea element matching the given selector has an exact expected value.
80
- *
81
- * ```gherkin
82
- * Then I see textarea {string} has value {string}
83
- * ```
84
- *
85
- * @param selector - The CSS selector of the textarea element (e.g., "textarea[name='bio']").
86
- * @param expectedValue - The exact value the textarea is expected to have.
87
- *
88
- * @example
89
- * Then I see textarea "textarea[name='bio']" has value "Hello"
90
- *
91
- * @remarks
92
- * This step uses Playwright's `expect(locator).toHaveValue()` which automatically waits
93
- * for the textarea to have the specified value.
94
- * @category Textarea Assertion Steps
95
- */
96
- export declare function Then_I_see_textarea_has_value(this: CustomWorld, selector: string, expectedValue: string): Promise<void>;
97
- /**
98
- * Asserts that the previously stored textarea element has an exact expected value.
99
- *
100
- * ```gherkin
101
- * Then I see textarea value {string}
102
- * ```
103
- *
104
- * @param expectedValue - The exact value the stored textarea is expected to have.
105
- *
106
- * @example
107
- * When I find element by selector "textarea[name='bio']"
108
- * Then I see textarea value "Hello"
109
- *
110
- * @remarks
111
- * This step requires a preceding step that sets the {@link CustomWorld.element | current element}
112
- * to a textarea element. It uses Playwright's `locator.inputValue()` to get the current value
113
- * and asserts strict equality.
114
- * @category Textarea Assertion Steps
115
- */
116
- export declare function Then_I_see_stored_textarea_value(this: CustomWorld, expectedValue: string): Promise<void>;
117
- /**
118
- * Asserts that the previously stored textarea element's value contains a given substring.
119
- *
120
- * ```gherkin
121
- * Then I see textarea value contains {string}
122
- * ```
123
- *
124
- * @param part - The substring expected to be contained within the textarea's value.
125
- *
126
- * @example
127
- * When I find element by selector "textarea[name='bio']"
128
- * Then I see textarea value contains "Hello"
129
- *
130
- * @remarks
131
- * This step requires a preceding step that sets the {@link CustomWorld.element | current element}
132
- * to a textarea element. It uses Playwright's `locator.inputValue()` and then checks for substring presence.
133
- * @category Textarea Assertion Steps
134
- */
135
- export declare function Then_I_see_stored_textarea_value_contains(this: CustomWorld, part: string): Promise<void>;
136
- /**
137
- * Asserts that a textarea element matching the given selector's value contains a given substring.
138
- *
139
- * ```gherkin
140
- * Then I see textarea {string} value contains {string}
141
- * ```
142
- *
143
- * @param selector - The CSS selector of the textarea element.
144
- * @param partial - The substring expected to be contained within the textarea's value.
145
- *
146
- * @example
147
- * Then I see textarea "textarea[name='bio']" value contains "Hello"
148
- *
149
- * @remarks
150
- * This step uses Playwright's `locator.inputValue()` and asserts that the value includes the substring.
151
- * @category Textarea Assertion Steps
152
- */
153
- export declare function Then_I_see_textarea_value_contains(this: CustomWorld, selector: string, partial: string): Promise<void>;
154
- /**
155
- * Asserts that an element matching the given selector has an exact expected value.
156
- * This step is generic and can be used for inputs, textareas, or other elements
157
- * whose value can be retrieved by Playwright's `toHaveValue`.
158
- *
159
- * ```gherkin
160
- * Then I see value {string} in {string}
161
- * ```
162
- *
163
- * @param expectedValue - The exact value expected.
164
- * @param selector - The CSS selector of the element to check.
165
- *
166
- * @example
167
- * Then I see value "foo" in "input[name='foo']"
168
- * Then I see value "true" in "input[type='checkbox'][name='terms']"
169
- *
170
- * @remarks
171
- * This step uses Playwright's `expect(locator).toHaveValue()` which is suitable
172
- * for `<input>`, `<textarea>`, and `<select>` elements.
173
- * @category Generic Assertion Steps
174
- */
175
- export declare function Then_I_see_value_in_element(this: CustomWorld, expectedValue: string, selector: string): Promise<void>;
176
- /**
177
- * Asserts that an element matching the given selector does NOT have a specific value.
178
- *
179
- * ```gherkin
180
- * Then I do not see value {string} in {string}
181
- * ```
182
- *
183
- * @param unwantedValue - The value that is expected NOT to be found.
184
- * @param selector - The CSS selector of the element to check.
185
- *
186
- * @example
187
- * Then I do not see value "guest" in "input[name='userRole']"
188
- *
189
- * @remarks
190
- * This step uses Playwright's `expect(locator).not.toHaveValue()` for robust assertion.
191
- * @category Generic Assertion Steps
192
- */
193
- export declare function Then_I_do_not_see_value_in_element(this: CustomWorld, unwantedValue: string, selector: string): Promise<void>;
194
- /**
195
- * Asserts that an `<option>` element with the given text exists in the DOM.
196
- * It does not necessarily assert that it is selected or visible within a `<select>` element.
197
- *
198
- * ```gherkin
199
- * Then I see option {string}
200
- * ```
201
- *
202
- * @param optionText - The text of the option expected to exist.
203
- *
204
- * @example
205
- * Then I see option "Admin"
206
- *
207
- * @remarks
208
- * This step directly targets `<option>` tags by their text content.
209
- * It asserts that at least one such option exists in the DOM.
210
- * @category Select Option Assertion Steps
211
- */
212
- export declare function Then_I_see_option(this: CustomWorld, optionText: string): Promise<void>;
213
- /**
214
- * Asserts that an `<option>` element with the given text is NOT visible.
215
- *
216
- * ```gherkin
217
- * Then I do not see option {string}
218
- * ```
219
- *
220
- * @param optionText - The text of the option expected NOT to be visible.
221
- *
222
- * @example
223
- * Then I do not see option "Deprecated Feature"
224
- *
225
- * @remarks
226
- * This step targets `<option>` tags by their text content and asserts that
227
- * any matching options are not visible. This is useful for dynamically hidden options.
228
- * @category Select Option Assertion Steps
229
- */
230
- export declare function Then_I_do_not_see_option(this: CustomWorld, optionText: string): Promise<void>;
231
- /**
232
- * Asserts that an `<option>` element with the given text does NOT exist in the DOM.
233
- *
234
- * ```gherkin
235
- * Then I do not see option {string} (regex pattern)
236
- * ```
237
- *
238
- * @param optionText - The text of the option expected NOT to exist in the DOM.
239
- *
240
- * @example
241
- * Then I do not see option "Super Admin"
242
- *
243
- * @remarks
244
- * This step targets `<option>` tags by their text content and asserts that
245
- * no such option is present in the DOM. This is useful for verifying removed options.
246
- * @category Select Option Assertion Steps
247
- */
248
- export declare function Then_I_do_not_see_option_exists(this: CustomWorld, optionText: string): Promise<void>;