playwright-cucumber-ts-steps 0.0.9 → 0.1.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 (39) hide show
  1. package/dist/actions/clickSteps.js +54 -69
  2. package/dist/actions/cookieSteps.js +7 -5
  3. package/dist/actions/debugSteps.js +5 -3
  4. package/dist/actions/elementFindSteps.js +75 -94
  5. package/dist/actions/inputSteps.js +65 -67
  6. package/dist/actions/interceptionSteps.js +9 -7
  7. package/dist/actions/miscSteps.js +52 -57
  8. package/dist/actions/mouseSteps.js +13 -14
  9. package/dist/actions/scrollSteps.js +7 -5
  10. package/dist/actions/storageSteps.js +11 -10
  11. package/dist/assertions/buttonAndTextVisibilitySteps.js +29 -31
  12. package/dist/assertions/cookieSteps.js +7 -5
  13. package/dist/assertions/elementSteps.js +27 -27
  14. package/dist/assertions/formInputSteps.js +28 -26
  15. package/dist/assertions/interceptionRequestsSteps.js +39 -29
  16. package/dist/assertions/locationSteps.js +17 -15
  17. package/dist/assertions/roleTestIdSteps.js +12 -10
  18. package/dist/assertions/semanticSteps.js +9 -7
  19. package/dist/assertions/storageSteps.js +25 -21
  20. package/dist/assertions/visualSteps.js +46 -44
  21. package/dist/custom_setups/globalLogin.js +10 -5
  22. package/dist/custom_setups/loginHooks.js +34 -32
  23. package/dist/helpers/compareSnapshots.js +15 -9
  24. package/dist/helpers/hooks.js +78 -42
  25. package/dist/helpers/utils/fakerUtils.js +32 -26
  26. package/dist/helpers/utils/index.js +19 -3
  27. package/dist/helpers/utils/optionsUtils.js +18 -8
  28. package/dist/helpers/utils/resolveUtils.js +19 -11
  29. package/dist/helpers/world.js +52 -17
  30. package/dist/iframes/frames.js +4 -2
  31. package/dist/index.js +43 -27
  32. package/dist/register.js +3 -1
  33. package/package.json +18 -2
  34. package/dist/assertions/InterceptionRequests.d.ts +0 -1
  35. package/dist/assertions/InterceptionRequests.js +0 -191
  36. package/dist/assertions/button_and_text_visibility.d.ts +0 -1
  37. package/dist/assertions/button_and_text_visibility.js +0 -172
  38. package/dist/custom_setups/global-login.d.ts +0 -2
  39. package/dist/custom_setups/global-login.js +0 -20
@@ -1,46 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
1
3
  // e2e/step_definitions/common/actions/clickSteps.ts
2
- import { When } from "@cucumber/cucumber";
3
- import { parseClickOptions } from "../helpers/utils/optionsUtils";
4
- When("I click", async function (...rest) {
5
- var _a;
4
+ const cucumber_1 = require("@cucumber/cucumber");
5
+ const optionsUtils_1 = require("../helpers/utils/optionsUtils");
6
+ (0, cucumber_1.When)("I click", async function (...rest) {
6
7
  const maybeTable = rest[0];
7
- const options = (maybeTable === null || maybeTable === void 0 ? void 0 : maybeTable.rowsHash) ? parseClickOptions(maybeTable) : {};
8
+ const options = maybeTable?.rowsHash ? (0, optionsUtils_1.parseClickOptions)(maybeTable) : {};
8
9
  if (!this.element)
9
10
  throw new Error("❌ No stored element to click.");
10
11
  await this.element.click(options);
11
- (_a = this.log) === null || _a === void 0 ? void 0 : _a.call(this, "🖱️ Clicked on stored element");
12
+ this.log?.("🖱️ Clicked on stored element");
12
13
  });
13
- When("I click on button {string}", async function (label, ...rest) {
14
- var _a;
14
+ (0, cucumber_1.When)("I click on button {string}", async function (label, ...rest) {
15
15
  const maybeTable = rest[0];
16
- const options = (maybeTable === null || maybeTable === void 0 ? void 0 : maybeTable.rowsHash) ? parseClickOptions(maybeTable) : {};
16
+ const options = maybeTable?.rowsHash ? (0, optionsUtils_1.parseClickOptions)(maybeTable) : {};
17
17
  const button = await this.page.getByRole("button", { name: label });
18
18
  await button.click(options);
19
19
  this.element = button;
20
- (_a = this.log) === null || _a === void 0 ? void 0 : _a.call(this, `🖱️ Clicked on button "${label}"`);
20
+ this.log?.(`🖱️ Clicked on button "${label}"`);
21
21
  });
22
- When("I click on link {string}", async function (text, ...rest) {
23
- var _a;
22
+ (0, cucumber_1.When)("I click on link {string}", async function (text, ...rest) {
24
23
  const maybeTable = rest[0];
25
- const options = (maybeTable === null || maybeTable === void 0 ? void 0 : maybeTable.rowsHash) ? parseClickOptions(maybeTable) : {};
24
+ const options = maybeTable?.rowsHash ? (0, optionsUtils_1.parseClickOptions)(maybeTable) : {};
26
25
  const link = await this.page.getByRole("link", { name: text });
27
26
  await link.click(options);
28
27
  this.element = link;
29
- (_a = this.log) === null || _a === void 0 ? void 0 : _a.call(this, `✅ Clicked on link "${text}"`);
28
+ this.log?.(`✅ Clicked on link "${text}"`);
30
29
  });
31
- When("I click on label {string}", async function (labelText, ...rest) {
32
- var _a;
30
+ (0, cucumber_1.When)("I click on label {string}", async function (labelText, ...rest) {
33
31
  const maybeTable = rest[0];
34
- const options = (maybeTable === null || maybeTable === void 0 ? void 0 : maybeTable.rowsHash) ? parseClickOptions(maybeTable) : {};
32
+ const options = maybeTable?.rowsHash ? (0, optionsUtils_1.parseClickOptions)(maybeTable) : {};
35
33
  const label = await this.page.getByLabel(labelText);
36
34
  await label.click(options);
37
35
  this.element = label;
38
- (_a = this.log) === null || _a === void 0 ? void 0 : _a.call(this, `🏷️ Clicked on label "${labelText}"`);
36
+ this.log?.(`🏷️ Clicked on label "${labelText}"`);
39
37
  });
40
- When("I click on text {string}", async function (rawText, ...rest) {
41
- var _a;
38
+ (0, cucumber_1.When)("I click on text {string}", async function (rawText, ...rest) {
42
39
  const maybeTable = rest[0];
43
- const options = (maybeTable === null || maybeTable === void 0 ? void 0 : maybeTable.rowsHash) ? parseClickOptions(maybeTable) : {};
40
+ const options = maybeTable?.rowsHash ? (0, optionsUtils_1.parseClickOptions)(maybeTable) : {};
44
41
  let text = rawText;
45
42
  if (rawText.startsWith("@")) {
46
43
  const alias = rawText.slice(1);
@@ -52,22 +49,20 @@ When("I click on text {string}", async function (rawText, ...rest) {
52
49
  await locator.first().waitFor({ state: "visible", timeout: 5000 });
53
50
  await locator.first().click(options);
54
51
  this.element = locator.first();
55
- (_a = this.log) === null || _a === void 0 ? void 0 : _a.call(this, `🖱️ Clicked on text "${text}"`);
52
+ this.log?.(`🖱️ Clicked on text "${text}"`);
56
53
  });
57
- When("I click on exact text {string}", async function (exactText, ...rest) {
58
- var _a;
54
+ (0, cucumber_1.When)("I click on exact text {string}", async function (exactText, ...rest) {
59
55
  const maybeTable = rest[0];
60
- const options = (maybeTable === null || maybeTable === void 0 ? void 0 : maybeTable.rowsHash) ? parseClickOptions(maybeTable) : {};
56
+ const options = maybeTable?.rowsHash ? (0, optionsUtils_1.parseClickOptions)(maybeTable) : {};
61
57
  const locator = this.page.getByText(exactText, { exact: true });
62
58
  await locator.waitFor({ state: "visible", timeout: 5000 });
63
59
  await locator.click(options);
64
60
  this.element = locator;
65
- (_a = this.log) === null || _a === void 0 ? void 0 : _a.call(this, `🖱️ Clicked on exact text "${exactText}"`);
61
+ this.log?.(`🖱️ Clicked on exact text "${exactText}"`);
66
62
  });
67
- When("I click all", async function (...rest) {
68
- var _a, _b;
63
+ (0, cucumber_1.When)("I click all", async function (...rest) {
69
64
  const maybeTable = rest[0];
70
- const options = (maybeTable === null || maybeTable === void 0 ? void 0 : maybeTable.rowsHash) ? parseClickOptions(maybeTable) : {};
65
+ const options = maybeTable?.rowsHash ? (0, optionsUtils_1.parseClickOptions)(maybeTable) : {};
71
66
  if (!this.elements)
72
67
  throw new Error("❌ No stored elements to click.");
73
68
  const count = await this.elements.count();
@@ -77,78 +72,69 @@ When("I click all", async function (...rest) {
77
72
  const el = this.elements.nth(i);
78
73
  await el.waitFor({ state: "visible", timeout: 5000 });
79
74
  await el.click(options);
80
- (_a = this.log) === null || _a === void 0 ? void 0 : _a.call(this, `🖱️ Clicked element #${i + 1}`);
75
+ this.log?.(`🖱️ Clicked element #${i + 1}`);
81
76
  }
82
- (_b = this.log) === null || _b === void 0 ? void 0 : _b.call(this, `✅ Clicked all ${count} elements.`);
77
+ this.log?.(`✅ Clicked all ${count} elements.`);
83
78
  });
84
- When("I double click on text {string}", async function (text, ...rest) {
85
- var _a;
79
+ (0, cucumber_1.When)("I double click on text {string}", async function (text, ...rest) {
86
80
  const maybeTable = rest[0];
87
- const options = (maybeTable === null || maybeTable === void 0 ? void 0 : maybeTable.rowsHash) ? parseClickOptions(maybeTable) : {};
81
+ const options = maybeTable?.rowsHash ? (0, optionsUtils_1.parseClickOptions)(maybeTable) : {};
88
82
  const element = this.element || this.page.getByText(text);
89
83
  await element.dblclick(options);
90
- (_a = this.log) === null || _a === void 0 ? void 0 : _a.call(this, `🖱️ Double-clicked on text "${text}"`);
84
+ this.log?.(`🖱️ Double-clicked on text "${text}"`);
91
85
  });
92
- When("I double click position {int} {int}", async function (x, y, ...rest) {
93
- var _a;
86
+ (0, cucumber_1.When)("I double click position {int} {int}", async function (x, y, ...rest) {
94
87
  const maybeTable = rest[0];
95
- const options = (maybeTable === null || maybeTable === void 0 ? void 0 : maybeTable.rowsHash) ? parseClickOptions(maybeTable) : {};
88
+ const options = maybeTable?.rowsHash ? (0, optionsUtils_1.parseClickOptions)(maybeTable) : {};
96
89
  await this.page.mouse.dblclick(x, y, options);
97
- (_a = this.log) === null || _a === void 0 ? void 0 : _a.call(this, `🖱️ Double-clicked at (${x}, ${y})`);
90
+ this.log?.(`🖱️ Double-clicked at (${x}, ${y})`);
98
91
  });
99
- When("I double click", async function (...rest) {
100
- var _a;
92
+ (0, cucumber_1.When)("I double click", async function (...rest) {
101
93
  const maybeTable = rest[0];
102
- const options = (maybeTable === null || maybeTable === void 0 ? void 0 : maybeTable.rowsHash) ? parseClickOptions(maybeTable) : {};
94
+ const options = maybeTable?.rowsHash ? (0, optionsUtils_1.parseClickOptions)(maybeTable) : {};
103
95
  if (!this.element)
104
96
  throw new Error("❌ No stored element to double-click.");
105
97
  await this.element.dblclick(options);
106
- (_a = this.log) === null || _a === void 0 ? void 0 : _a.call(this, "🖱️ Double-clicked on stored element");
98
+ this.log?.("🖱️ Double-clicked on stored element");
107
99
  });
108
- When("I right click", async function (...rest) {
109
- var _a;
100
+ (0, cucumber_1.When)("I right click", async function (...rest) {
110
101
  const maybeTable = rest[0];
111
- const options = (maybeTable === null || maybeTable === void 0 ? void 0 : maybeTable.rowsHash) ? parseClickOptions(maybeTable) : {};
102
+ const options = maybeTable?.rowsHash ? (0, optionsUtils_1.parseClickOptions)(maybeTable) : {};
112
103
  if (!this.element)
113
104
  throw new Error("❌ No stored element to right-click.");
114
105
  await this.element.click({ button: "right", ...options });
115
- (_a = this.log) === null || _a === void 0 ? void 0 : _a.call(this, "🖱️ Right-clicked on stored element");
106
+ this.log?.("🖱️ Right-clicked on stored element");
116
107
  });
117
- When("I right click on text {string}", async function (text, ...rest) {
118
- var _a;
108
+ (0, cucumber_1.When)("I right click on text {string}", async function (text, ...rest) {
119
109
  const maybeTable = rest[0];
120
- const options = (maybeTable === null || maybeTable === void 0 ? void 0 : maybeTable.rowsHash) ? parseClickOptions(maybeTable) : {};
110
+ const options = maybeTable?.rowsHash ? (0, optionsUtils_1.parseClickOptions)(maybeTable) : {};
121
111
  const element = this.page.getByText(text);
122
112
  await element.click({ button: "right", ...options });
123
- (_a = this.log) === null || _a === void 0 ? void 0 : _a.call(this, `🖱️ Right-clicked on text "${text}"`);
113
+ this.log?.(`🖱️ Right-clicked on text "${text}"`);
124
114
  });
125
- When("I right click position {int} {int}", async function (x, y, ...rest) {
126
- var _a;
115
+ (0, cucumber_1.When)("I right click position {int} {int}", async function (x, y, ...rest) {
127
116
  const maybeTable = rest[0];
128
- const options = (maybeTable === null || maybeTable === void 0 ? void 0 : maybeTable.rowsHash) ? parseClickOptions(maybeTable) : {};
117
+ const options = maybeTable?.rowsHash ? (0, optionsUtils_1.parseClickOptions)(maybeTable) : {};
129
118
  await this.page.mouse.click(x, y, { button: "right", ...options });
130
- (_a = this.log) === null || _a === void 0 ? void 0 : _a.call(this, `🖱️ Right-clicked at (${x}, ${y})`);
119
+ this.log?.(`🖱️ Right-clicked at (${x}, ${y})`);
131
120
  });
132
- When("I blur", async function () {
133
- var _a;
121
+ (0, cucumber_1.When)("I blur", async function () {
134
122
  await this.page.evaluate(() => {
135
123
  const active = document.activeElement;
136
124
  if (active && typeof active.blur === "function") {
137
125
  active.blur();
138
126
  }
139
127
  });
140
- (_a = this.log) === null || _a === void 0 ? void 0 : _a.call(this, "🌀 Blurred active element");
128
+ this.log?.("🌀 Blurred active element");
141
129
  });
142
- When("I focus", async function () {
143
- var _a;
130
+ (0, cucumber_1.When)("I focus", async function () {
144
131
  if (!this.element)
145
132
  throw new Error("❌ No stored element to focus.");
146
133
  await this.element.focus();
147
- (_a = this.log) === null || _a === void 0 ? void 0 : _a.call(this, "🎯 Focused stored element");
134
+ this.log?.("🎯 Focused stored element");
148
135
  });
149
- When("I click all", async function (dataTable) {
150
- var _a, _b;
151
- const options = parseClickOptions(dataTable);
136
+ (0, cucumber_1.When)("I click all", async function (dataTable) {
137
+ const options = (0, optionsUtils_1.parseClickOptions)(dataTable);
152
138
  if (!this.elements) {
153
139
  throw new Error("❌ No elements stored. Use a 'find' step before 'I click all'.");
154
140
  }
@@ -160,14 +146,13 @@ When("I click all", async function (dataTable) {
160
146
  const element = this.elements.nth(i);
161
147
  await element.waitFor({ state: "visible", timeout: 5000 });
162
148
  await element.click(options);
163
- (_a = this.log) === null || _a === void 0 ? void 0 : _a.call(this, `🖱️ Clicked element #${i + 1}`);
149
+ this.log?.(`🖱️ Clicked element #${i + 1}`);
164
150
  }
165
- (_b = this.log) === null || _b === void 0 ? void 0 : _b.call(this, `✅ Clicked all ${count} stored elements.`);
151
+ this.log?.(`✅ Clicked all ${count} stored elements.`);
166
152
  });
167
- When(/^I click on selector "([^"]+)"$/, async function (selector) {
168
- var _a;
153
+ (0, cucumber_1.When)(/^I click on selector "([^"]+)"$/, async function (selector) {
169
154
  const scope = this.getScope();
170
155
  const element = scope.locator(selector);
171
156
  await element.click();
172
- (_a = this.log) === null || _a === void 0 ? void 0 : _a.call(this, `🖱️ Clicked on selector: ${selector}`);
157
+ this.log?.(`🖱️ Clicked on selector: ${selector}`);
173
158
  });
@@ -1,14 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
1
3
  // e2e/step_definitions/common/actions/cookieSteps.ts
2
- import { When } from "@cucumber/cucumber";
3
- When("I clear all cookies", async function () {
4
+ const cucumber_1 = require("@cucumber/cucumber");
5
+ (0, cucumber_1.When)("I clear all cookies", async function () {
4
6
  await this.page.context().clearCookies();
5
7
  this.log("Cleared all cookies");
6
8
  });
7
- When("I clear cookies", async function () {
9
+ (0, cucumber_1.When)("I clear cookies", async function () {
8
10
  await this.page.context().clearCookies();
9
11
  this.log("Cleared cookies (alias)");
10
12
  });
11
- When("I clear cookie {string}", async function (name) {
13
+ (0, cucumber_1.When)("I clear cookie {string}", async function (name) {
12
14
  await this.page.context().addCookies([
13
15
  {
14
16
  name,
@@ -20,7 +22,7 @@ When("I clear cookie {string}", async function (name) {
20
22
  ]);
21
23
  this.log(`Cleared cookie: ${name}`);
22
24
  });
23
- When("I log all cookies", async function () {
25
+ (0, cucumber_1.When)("I log all cookies", async function () {
24
26
  const cookies = await this.page.context().cookies();
25
27
  console.log("Cookies:", cookies);
26
28
  });
@@ -1,9 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
1
3
  // e2e/step_definitions/common/actions/debugSteps.ts
2
- import { When } from "@cucumber/cucumber";
3
- When("I debug", async function () {
4
+ const cucumber_1 = require("@cucumber/cucumber");
5
+ (0, cucumber_1.When)("I debug", async function () {
4
6
  await this.page.pause();
5
7
  this.log("Paused test for debugging");
6
8
  });
7
- When("I log {string}", async function (msg) {
9
+ (0, cucumber_1.When)("I log {string}", async function (msg) {
8
10
  this.log(msg);
9
11
  });
@@ -1,56 +1,56 @@
1
- import { When } from "@cucumber/cucumber";
2
- import { expect } from "@playwright/test";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const cucumber_1 = require("@cucumber/cucumber");
4
+ const test_1 = require("@playwright/test");
3
5
  // =============================
4
6
  // WHEN I FIND ELEMENT(S)
5
7
  // =============================
6
- When("I find element by selector {string}", async function (selector) {
8
+ (0, cucumber_1.When)("I find element by selector {string}", async function (selector) {
7
9
  this.element = this.page.locator(selector);
8
- await expect(this.element).toHaveCount(1);
10
+ await (0, test_1.expect)(this.element).toHaveCount(1);
9
11
  });
10
- When("I find elements by selector {string}", async function (selector) {
11
- var _a;
12
+ (0, cucumber_1.When)("I find elements by selector {string}", async function (selector) {
12
13
  this.elements = this.page.locator(selector);
13
14
  const count = await this.elements.count();
14
- (_a = this.log) === null || _a === void 0 ? void 0 : _a.call(this, `Found ${count} elements with selector ${selector}`);
15
+ this.log?.(`Found ${count} elements with selector ${selector}`);
15
16
  });
16
- When("I find element by text {string}", async function (text) {
17
+ (0, cucumber_1.When)("I find element by text {string}", async function (text) {
17
18
  this.element = this.page.getByText(text, { exact: true });
18
- await expect(this.element).toHaveCount(1);
19
+ await (0, test_1.expect)(this.element).toHaveCount(1);
19
20
  });
20
- When("I find element by title {string}", async function (title) {
21
+ (0, cucumber_1.When)("I find element by title {string}", async function (title) {
21
22
  this.element = this.page.getByTitle(title);
22
- await expect(this.element).toHaveCount(1);
23
+ await (0, test_1.expect)(this.element).toHaveCount(1);
23
24
  });
24
- When("I find element by testid {string}", async function (testid) {
25
+ (0, cucumber_1.When)("I find element by testid {string}", async function (testid) {
25
26
  this.element = this.page.getByTestId(testid);
26
- await expect(this.element).toHaveCount(1);
27
+ await (0, test_1.expect)(this.element).toHaveCount(1);
27
28
  });
28
- When("I find element by role {string}", async function (role) {
29
+ (0, cucumber_1.When)("I find element by role {string}", async function (role) {
29
30
  this.element = this.page.getByRole(role);
30
- await expect(this.element).toHaveCount(1);
31
+ await (0, test_1.expect)(this.element).toHaveCount(1);
31
32
  });
32
- When("I find element by placeholder text {string}", async function (text) {
33
+ (0, cucumber_1.When)("I find element by placeholder text {string}", async function (text) {
33
34
  this.element = this.page.getByPlaceholder(text);
34
- await expect(this.element).toHaveCount(1);
35
+ await (0, test_1.expect)(this.element).toHaveCount(1);
35
36
  });
36
- When("I find element by label text {string}", async function (label) {
37
+ (0, cucumber_1.When)("I find element by label text {string}", async function (label) {
37
38
  this.element = this.page.getByLabel(label);
38
- await expect(this.element).toHaveCount(1);
39
+ await (0, test_1.expect)(this.element).toHaveCount(1);
39
40
  });
40
- When("I find element by alt text {string}", async function (alt) {
41
+ (0, cucumber_1.When)("I find element by alt text {string}", async function (alt) {
41
42
  this.element = this.page.getByAltText(alt);
42
- await expect(this.element).toHaveCount(1);
43
+ await (0, test_1.expect)(this.element).toHaveCount(1);
43
44
  });
44
- When("I find element by name {string}", async function (name) {
45
+ (0, cucumber_1.When)("I find element by name {string}", async function (name) {
45
46
  this.element = this.page.getByRole("textbox", { name });
46
- await expect(this.element).toHaveCount(1);
47
+ await (0, test_1.expect)(this.element).toHaveCount(1);
47
48
  });
48
- When("I find buttons by text {string}", async function (buttonText) {
49
- var _a, _b;
49
+ (0, cucumber_1.When)("I find buttons by text {string}", async function (buttonText) {
50
50
  // 🧠 Resolve alias
51
51
  if (buttonText.startsWith("@")) {
52
52
  const alias = buttonText.slice(1);
53
- buttonText = (_a = this.data) === null || _a === void 0 ? void 0 : _a[alias];
53
+ buttonText = this.data?.[alias];
54
54
  if (!buttonText) {
55
55
  throw new Error(`No value found for alias "@${alias}"`);
56
56
  }
@@ -60,29 +60,28 @@ When("I find buttons by text {string}", async function (buttonText) {
60
60
  name: buttonText,
61
61
  exact: false,
62
62
  });
63
- (_b = this.log) === null || _b === void 0 ? void 0 : _b.call(this, `🔘 Stored all buttons matching text "${buttonText}"`);
63
+ this.log?.(`🔘 Stored all buttons matching text "${buttonText}"`);
64
64
  });
65
65
  // =============================
66
66
  // WHEN I GET ELEMENT(S)
67
67
  // =============================
68
- When("I get element by selector {string}", async function (selector) {
68
+ (0, cucumber_1.When)("I get element by selector {string}", async function (selector) {
69
69
  this.element = this.page.locator(selector).first();
70
70
  });
71
- When("I get elements by selector {string}", async function (selector) {
71
+ (0, cucumber_1.When)("I get elements by selector {string}", async function (selector) {
72
72
  this.elements = this.page.locator(selector);
73
73
  });
74
- When("I get first element", async function () {
74
+ (0, cucumber_1.When)("I get first element", async function () {
75
75
  if (!this.elements)
76
76
  throw new Error("No element collection found");
77
77
  this.element = this.elements.first();
78
78
  });
79
- When("I get last element", async function () {
79
+ (0, cucumber_1.When)("I get last element", async function () {
80
80
  if (!this.elements)
81
81
  throw new Error("No element collection found");
82
82
  this.element = this.elements.last();
83
83
  });
84
- When(/^I get (\d+)(?:st|nd|rd|th) element$/, async function (index) {
85
- var _a;
84
+ (0, cucumber_1.When)(/^I get (\d+)(?:st|nd|rd|th) element$/, async function (index) {
86
85
  if (!this.elements)
87
86
  throw new Error("No elements stored to pick from");
88
87
  const count = await this.elements.count();
@@ -90,17 +89,16 @@ When(/^I get (\d+)(?:st|nd|rd|th) element$/, async function (index) {
90
89
  throw new Error(`Cannot get element ${index} — only ${count} found`);
91
90
  }
92
91
  this.element = this.elements.nth(index - 1);
93
- (_a = this.log) === null || _a === void 0 ? void 0 : _a.call(this, `Selected ${index} element from stored elements`);
92
+ this.log?.(`Selected ${index} element from stored elements`);
94
93
  });
95
- When("I find elements by role {string}", async function (role) {
96
- var _a;
94
+ (0, cucumber_1.When)("I find elements by role {string}", async function (role) {
97
95
  const locator = this.page.getByRole(role);
98
96
  const count = await locator.count();
99
97
  if (count === 0) {
100
98
  throw new Error(`No elements found with role "${role}"`);
101
99
  }
102
100
  this.elements = locator;
103
- (_a = this.log) === null || _a === void 0 ? void 0 : _a.call(this, `Stored ${count} elements with role "${role}"`);
101
+ this.log?.(`Stored ${count} elements with role "${role}"`);
104
102
  });
105
103
  // When(
106
104
  // "I get {int}{ordinal} element",
@@ -120,120 +118,103 @@ When("I find elements by role {string}", async function (role) {
120
118
  // this.log?.(`Stored ${index}th element from collection`);
121
119
  // }
122
120
  // );
123
- When("I get {int}rd element", async function (index) {
121
+ (0, cucumber_1.When)("I get {int}rd element", async function (index) {
124
122
  if (!this.elements)
125
123
  throw new Error("No element collection found");
126
124
  this.element = this.elements.nth(index);
127
125
  });
128
- When("I get focused element", async function () {
126
+ (0, cucumber_1.When)("I get focused element", async function () {
129
127
  this.element = (await this.page.evaluateHandle(() => document.activeElement));
130
128
  });
131
- When("I store element text as {string}", async function (alias) {
132
- var _a;
129
+ (0, cucumber_1.When)("I store element text as {string}", async function (alias) {
133
130
  const element = this.element;
134
131
  if (!element)
135
132
  throw new Error("No element selected");
136
133
  const text = await element.textContent();
137
- this.data[alias] = text === null || text === void 0 ? void 0 : text.trim();
138
- (_a = this.log) === null || _a === void 0 ? void 0 : _a.call(this, `Stored text "${text}" as "${alias}"`);
134
+ this.data[alias] = text?.trim();
135
+ this.log?.(`Stored text "${text}" as "${alias}"`);
139
136
  });
140
- When("I find textarea by label text {string}", async function (label) {
141
- var _a;
137
+ (0, cucumber_1.When)("I find textarea by label text {string}", async function (label) {
142
138
  this.element = this.page.getByLabel(label);
143
- (_a = this.log) === null || _a === void 0 ? void 0 : _a.call(this, `Stored textarea with label "${label}"`);
139
+ this.log?.(`Stored textarea with label "${label}"`);
144
140
  });
145
- When("I find textarea by placeholder text {string}", async function (placeholder) {
146
- var _a;
141
+ (0, cucumber_1.When)("I find textarea by placeholder text {string}", async function (placeholder) {
147
142
  this.element = this.page.getByPlaceholder(placeholder);
148
- (_a = this.log) === null || _a === void 0 ? void 0 : _a.call(this, `Stored textarea with placeholder "${placeholder}"`);
143
+ this.log?.(`Stored textarea with placeholder "${placeholder}"`);
149
144
  });
150
- When("I find textareas by label text {string}", async function (label) {
151
- var _a;
145
+ (0, cucumber_1.When)("I find textareas by label text {string}", async function (label) {
152
146
  this.elements = this.page.locator(`label:has-text("${label}") + textarea`);
153
- (_a = this.log) === null || _a === void 0 ? void 0 : _a.call(this, `Stored multiple textareas with label "${label}"`);
147
+ this.log?.(`Stored multiple textareas with label "${label}"`);
154
148
  });
155
- When("I find textarea by name {string}", async function (name) {
156
- var _a;
149
+ (0, cucumber_1.When)("I find textarea by name {string}", async function (name) {
157
150
  this.element = this.page.locator(`textarea[name="${name}"]`);
158
- (_a = this.log) === null || _a === void 0 ? void 0 : _a.call(this, `Stored textarea with name "${name}"`);
151
+ this.log?.(`Stored textarea with name "${name}"`);
159
152
  });
160
- When("I find textareas by ID {string}", async function (id) {
161
- var _a;
153
+ (0, cucumber_1.When)("I find textareas by ID {string}", async function (id) {
162
154
  this.elements = this.page.locator(`textarea#${id}`);
163
- (_a = this.log) === null || _a === void 0 ? void 0 : _a.call(this, `Stored multiple textareas with ID "${id}"`);
155
+ this.log?.(`Stored multiple textareas with ID "${id}"`);
164
156
  });
165
- When("I find input by ID {string}", async function (id) {
166
- var _a;
157
+ (0, cucumber_1.When)("I find input by ID {string}", async function (id) {
167
158
  this.element = this.page.locator(`input#${id}`);
168
- (_a = this.log) === null || _a === void 0 ? void 0 : _a.call(this, `Stored input with ID "${id}"`);
159
+ this.log?.(`Stored input with ID "${id}"`);
169
160
  });
170
- When("I find inputs by ID {string}", async function (id) {
171
- var _a;
161
+ (0, cucumber_1.When)("I find inputs by ID {string}", async function (id) {
172
162
  this.elements = this.page.locator(`input#${id}`);
173
- (_a = this.log) === null || _a === void 0 ? void 0 : _a.call(this, `Stored multiple inputs with ID "${id}"`);
163
+ this.log?.(`Stored multiple inputs with ID "${id}"`);
174
164
  });
175
- When("I find textareas by placeholder text {string}", async function (placeholder) {
176
- var _a;
165
+ (0, cucumber_1.When)("I find textareas by placeholder text {string}", async function (placeholder) {
177
166
  this.elements = this.page.locator(`textarea[placeholder="${placeholder}"]`);
178
- (_a = this.log) === null || _a === void 0 ? void 0 : _a.call(this, `Stored multiple textareas with placeholder "${placeholder}"`);
167
+ this.log?.(`Stored multiple textareas with placeholder "${placeholder}"`);
179
168
  });
180
- When("I find input by label text {string}", async function (label) {
181
- var _a;
169
+ (0, cucumber_1.When)("I find input by label text {string}", async function (label) {
182
170
  this.element = this.page.getByLabel(label);
183
- (_a = this.log) === null || _a === void 0 ? void 0 : _a.call(this, `Stored input with label "${label}"`);
171
+ this.log?.(`Stored input with label "${label}"`);
184
172
  });
185
- When("I find input by name {string}", async function (name) {
186
- var _a;
173
+ (0, cucumber_1.When)("I find input by name {string}", async function (name) {
187
174
  this.element = this.page.locator(`input[name="${name}"]`);
188
- (_a = this.log) === null || _a === void 0 ? void 0 : _a.call(this, `Stored input with name "${name}"`);
175
+ this.log?.(`Stored input with name "${name}"`);
189
176
  });
190
- When("I find input by placeholder text {string}", async function (placeholder) {
191
- var _a;
177
+ (0, cucumber_1.When)("I find input by placeholder text {string}", async function (placeholder) {
192
178
  this.element = this.page.getByPlaceholder(placeholder);
193
- (_a = this.log) === null || _a === void 0 ? void 0 : _a.call(this, `Stored input with placeholder "${placeholder}"`);
179
+ this.log?.(`Stored input with placeholder "${placeholder}"`);
194
180
  });
195
- When("I find inputs by name {string}", async function (name) {
196
- var _a;
181
+ (0, cucumber_1.When)("I find inputs by name {string}", async function (name) {
197
182
  this.elements = this.page.locator(`input[name="${name}"]`);
198
- (_a = this.log) === null || _a === void 0 ? void 0 : _a.call(this, `Stored multiple inputs with name "${name}"`);
183
+ this.log?.(`Stored multiple inputs with name "${name}"`);
199
184
  });
200
- When("I find inputs by placeholder text {string}", async function (placeholder) {
201
- var _a;
185
+ (0, cucumber_1.When)("I find inputs by placeholder text {string}", async function (placeholder) {
202
186
  this.elements = this.page.locator(`input[placeholder="${placeholder}"]`);
203
- (_a = this.log) === null || _a === void 0 ? void 0 : _a.call(this, `Stored multiple inputs with placeholder "${placeholder}"`);
187
+ this.log?.(`Stored multiple inputs with placeholder "${placeholder}"`);
204
188
  });
205
- When("I find inputs by label text {string}", async function (label) {
206
- var _a;
189
+ (0, cucumber_1.When)("I find inputs by label text {string}", async function (label) {
207
190
  this.elements = this.page.locator(`label:has-text("${label}") + input`);
208
- (_a = this.log) === null || _a === void 0 ? void 0 : _a.call(this, `Stored multiple inputs with label "${label}"`);
191
+ this.log?.(`Stored multiple inputs with label "${label}"`);
209
192
  });
210
- When("I find inputs by display value {string}", async function (value) {
211
- var _a, _b;
193
+ (0, cucumber_1.When)("I find inputs by display value {string}", async function (value) {
212
194
  // 🧠 Handle alias
213
195
  if (value.startsWith("@")) {
214
196
  const alias = value.slice(1);
215
- value = (_a = this.data) === null || _a === void 0 ? void 0 : _a[alias];
197
+ value = this.data?.[alias];
216
198
  if (!value) {
217
199
  throw new Error(`No value found for alias "@${alias}"`);
218
200
  }
219
201
  }
220
202
  // 🔍 Find all matching inputs
221
203
  this.elements = this.page.locator(`input[value="${value}"]`);
222
- (_b = this.log) === null || _b === void 0 ? void 0 : _b.call(this, `📦 Stored multiple inputs with display value "${value}"`);
204
+ this.log?.(`📦 Stored multiple inputs with display value "${value}"`);
223
205
  });
224
- When("I find input by display value {string}", async function (value) {
225
- var _a, _b;
206
+ (0, cucumber_1.When)("I find input by display value {string}", async function (value) {
226
207
  // 🧠 Handle alias
227
208
  if (value.startsWith("@")) {
228
209
  const alias = value.slice(1);
229
- value = (_a = this.data) === null || _a === void 0 ? void 0 : _a[alias];
210
+ value = this.data?.[alias];
230
211
  if (!value) {
231
212
  throw new Error(`No value found for alias "@${alias}"`);
232
213
  }
233
214
  }
234
215
  // 🎯 Try to find input element with matching display value
235
216
  const locator = this.page.locator(`input[value="${value}"]`);
236
- await expect(locator).toBeVisible({ timeout: 5000 });
217
+ await (0, test_1.expect)(locator).toBeVisible({ timeout: 5000 });
237
218
  this.element = locator;
238
- (_b = this.log) === null || _b === void 0 ? void 0 : _b.call(this, `🔍 Found input with value: "${value}"`);
219
+ this.log?.(`🔍 Found input with value: "${value}"`);
239
220
  });