@playq/core 0.2.77

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 (225) hide show
  1. package/README.md +41 -0
  2. package/bin/playq.js +175 -0
  3. package/cucumber.js +10 -0
  4. package/dist/exec/featureFileCache.d.ts +21 -0
  5. package/dist/exec/featureFileCache.js +124 -0
  6. package/dist/exec/featureFilePreProcess.d.ts +12 -0
  7. package/dist/exec/featureFilePreProcess.js +208 -0
  8. package/dist/exec/preLoader.d.ts +1 -0
  9. package/dist/exec/preLoader.js +72 -0
  10. package/dist/exec/preProcessEntry.d.ts +1 -0
  11. package/dist/exec/preProcessEntry.js +83 -0
  12. package/dist/exec/preProcess_old_todelete.d.ts +1 -0
  13. package/dist/exec/preProcess_old_todelete.js +258 -0
  14. package/dist/exec/runner.d.ts +1 -0
  15. package/dist/exec/runner.js +221 -0
  16. package/dist/exec/runner_orchestrator.d.ts +1 -0
  17. package/dist/exec/runner_orchestrator.js +85 -0
  18. package/dist/exec/sgGenerator.d.ts +11 -0
  19. package/dist/exec/sgGenerator.js +310 -0
  20. package/dist/global.d.ts +15 -0
  21. package/dist/global.js +185 -0
  22. package/dist/helper/actions/api/apiRequestActions.d.ts +117 -0
  23. package/dist/helper/actions/api/apiRequestActions.js +374 -0
  24. package/dist/helper/actions/api/apiValidationActions.d.ts +119 -0
  25. package/dist/helper/actions/api/apiValidationActions.js +615 -0
  26. package/dist/helper/actions/apiActions.d.ts +18 -0
  27. package/dist/helper/actions/apiActions.js +34 -0
  28. package/dist/helper/actions/apiStepDefs.d.ts +1 -0
  29. package/dist/helper/actions/apiStepDefs.js +64 -0
  30. package/dist/helper/actions/comm/commonActions.d.ts +58 -0
  31. package/dist/helper/actions/comm/commonActions.js +198 -0
  32. package/dist/helper/actions/comm/utilityActions.d.ts +131 -0
  33. package/dist/helper/actions/comm/utilityActions.js +351 -0
  34. package/dist/helper/actions/commActions.d.ts +18 -0
  35. package/dist/helper/actions/commActions.js +34 -0
  36. package/dist/helper/actions/commStepDefs.d.ts +1 -0
  37. package/dist/helper/actions/commStepDefs.js +57 -0
  38. package/dist/helper/actions/stepGroupStepDefs.d.ts +1 -0
  39. package/dist/helper/actions/stepGroupStepDefs.js +15 -0
  40. package/dist/helper/actions/web/alertActions.d.ts +61 -0
  41. package/dist/helper/actions/web/alertActions.js +224 -0
  42. package/dist/helper/actions/web/cookieActions.d.ts +45 -0
  43. package/dist/helper/actions/web/cookieActions.js +186 -0
  44. package/dist/helper/actions/web/downloadActions.d.ts +40 -0
  45. package/dist/helper/actions/web/downloadActions.js +153 -0
  46. package/dist/helper/actions/web/elementReaderActions.d.ts +95 -0
  47. package/dist/helper/actions/web/elementReaderActions.js +326 -0
  48. package/dist/helper/actions/web/formActions.d.ts +122 -0
  49. package/dist/helper/actions/web/formActions.js +423 -0
  50. package/dist/helper/actions/web/iframeActions.d.ts +23 -0
  51. package/dist/helper/actions/web/iframeActions.js +108 -0
  52. package/dist/helper/actions/web/javascriptActions.d.ts +14 -0
  53. package/dist/helper/actions/web/javascriptActions.js +77 -0
  54. package/dist/helper/actions/web/keyboardActions.d.ts +35 -0
  55. package/dist/helper/actions/web/keyboardActions.js +118 -0
  56. package/dist/helper/actions/web/localStorageActions.d.ts +51 -0
  57. package/dist/helper/actions/web/localStorageActions.js +163 -0
  58. package/dist/helper/actions/web/mouseActions.d.ts +240 -0
  59. package/dist/helper/actions/web/mouseActions.js +609 -0
  60. package/dist/helper/actions/web/reportingActions.d.ts +34 -0
  61. package/dist/helper/actions/web/reportingActions.js +58 -0
  62. package/dist/helper/actions/web/screenshotActions.d.ts +34 -0
  63. package/dist/helper/actions/web/screenshotActions.js +151 -0
  64. package/dist/helper/actions/web/testDataActions.d.ts +21 -0
  65. package/dist/helper/actions/web/testDataActions.js +211 -0
  66. package/dist/helper/actions/web/validationActions.d.ts +547 -0
  67. package/dist/helper/actions/web/validationActions.js +1754 -0
  68. package/dist/helper/actions/web/waitActions.d.ts +191 -0
  69. package/dist/helper/actions/web/waitActions.js +589 -0
  70. package/dist/helper/actions/web/webNavigation.d.ts +104 -0
  71. package/dist/helper/actions/web/webNavigation.js +288 -0
  72. package/dist/helper/actions/webActions.d.ts +32 -0
  73. package/dist/helper/actions/webActions.js +48 -0
  74. package/dist/helper/actions/webStepDefs.d.ts +1 -0
  75. package/dist/helper/actions/webStepDefs.js +455 -0
  76. package/dist/helper/browsers/browserManager.d.ts +1 -0
  77. package/dist/helper/browsers/browserManager.js +56 -0
  78. package/dist/helper/bundle/defaultEntries.d.ts +6 -0
  79. package/dist/helper/bundle/defaultEntries.js +200 -0
  80. package/dist/helper/bundle/env.d.ts +1 -0
  81. package/dist/helper/bundle/env.js +157 -0
  82. package/dist/helper/bundle/vars.d.ts +9 -0
  83. package/dist/helper/bundle/vars.js +375 -0
  84. package/dist/helper/faker/customFaker.d.ts +55 -0
  85. package/dist/helper/faker/customFaker.js +45 -0
  86. package/dist/helper/faker/modules/data/postcodes_valid_sg.json +17 -0
  87. package/dist/helper/faker/modules/dateTime.d.ts +18 -0
  88. package/dist/helper/faker/modules/dateTime.js +106 -0
  89. package/dist/helper/faker/modules/mobile.d.ts +4 -0
  90. package/dist/helper/faker/modules/mobile.js +59 -0
  91. package/dist/helper/faker/modules/nric.d.ts +32 -0
  92. package/dist/helper/faker/modules/nric.js +84 -0
  93. package/dist/helper/faker/modules/passport.d.ts +3 -0
  94. package/dist/helper/faker/modules/passport.js +36 -0
  95. package/dist/helper/faker/modules/person.d.ts +14 -0
  96. package/dist/helper/faker/modules/person.js +73 -0
  97. package/dist/helper/faker/modules/postcode.d.ts +6 -0
  98. package/dist/helper/faker/modules/postcode.js +47 -0
  99. package/dist/helper/fixtures/locAggregate.d.ts +7 -0
  100. package/dist/helper/fixtures/locAggregate.js +94 -0
  101. package/dist/helper/fixtures/logFixture.d.ts +8 -0
  102. package/dist/helper/fixtures/logFixture.js +56 -0
  103. package/dist/helper/fixtures/webFixture.d.ts +19 -0
  104. package/dist/helper/fixtures/webFixture.js +186 -0
  105. package/dist/helper/fixtures/webLocFixture.d.ts +2 -0
  106. package/dist/helper/fixtures/webLocFixture.js +144 -0
  107. package/dist/helper/report/allureStepLogger.d.ts +0 -0
  108. package/dist/helper/report/allureStepLogger.js +25 -0
  109. package/dist/helper/report/customiseReport.d.ts +1 -0
  110. package/dist/helper/report/customiseReport.js +55 -0
  111. package/dist/helper/report/init.d.ts +1 -0
  112. package/dist/helper/report/init.js +14 -0
  113. package/dist/helper/report/report.d.ts +1 -0
  114. package/dist/helper/report/report.js +102 -0
  115. package/dist/helper/util/dataLoader.d.ts +10 -0
  116. package/dist/helper/util/dataLoader.js +73 -0
  117. package/dist/helper/util/logger.d.ts +4 -0
  118. package/dist/helper/util/logger.js +61 -0
  119. package/dist/helper/util/session/sessionUtil.d.ts +26 -0
  120. package/dist/helper/util/session/sessionUtil.js +729 -0
  121. package/dist/helper/util/stepHelpers.d.ts +2 -0
  122. package/dist/helper/util/stepHelpers.js +16 -0
  123. package/dist/helper/util/test-data/dataLoader.d.ts +7 -0
  124. package/dist/helper/util/test-data/dataLoader.js +145 -0
  125. package/dist/helper/util/test-data/dataTest.d.ts +10 -0
  126. package/dist/helper/util/test-data/dataTest.js +216 -0
  127. package/dist/helper/util/totp/totpHelper.d.ts +38 -0
  128. package/dist/helper/util/totp/totpHelper.js +117 -0
  129. package/dist/helper/util/utilities/cryptoUtil.d.ts +2 -0
  130. package/dist/helper/util/utilities/cryptoUtil.js +53 -0
  131. package/dist/helper/util/utilities/schemaGeneratorUtil.d.ts +2 -0
  132. package/dist/helper/util/utilities/schemaGeneratorUtil.js +129 -0
  133. package/dist/helper/util/utils.d.ts +2 -0
  134. package/dist/helper/util/utils.js +22 -0
  135. package/dist/helper/wrapper/PlaywrightWrappers.d.ts +8 -0
  136. package/dist/helper/wrapper/PlaywrightWrappers.js +26 -0
  137. package/dist/helper/wrapper/assert.d.ts +9 -0
  138. package/dist/helper/wrapper/assert.js +23 -0
  139. package/dist/index.d.ts +7 -0
  140. package/dist/index.js +57 -0
  141. package/dist/scripts/get-versions.d.ts +1 -0
  142. package/dist/scripts/get-versions.js +98 -0
  143. package/dist/scripts/posttest.d.ts +1 -0
  144. package/dist/scripts/posttest.js +29 -0
  145. package/dist/scripts/pretest.d.ts +1 -0
  146. package/dist/scripts/pretest.js +57 -0
  147. package/dist/scripts/util.d.ts +1 -0
  148. package/dist/scripts/util.js +376 -0
  149. package/package.json +68 -0
  150. package/src/exec/featureFileCache.ts +80 -0
  151. package/src/exec/featureFilePreProcess.ts +239 -0
  152. package/src/exec/preLoader.ts +72 -0
  153. package/src/exec/preProcessEntry.ts +59 -0
  154. package/src/exec/preProcess_old_todelete.ts +289 -0
  155. package/src/exec/runner.ts +241 -0
  156. package/src/exec/runnerCuke.js +90 -0
  157. package/src/exec/runner_orchestrator.ts +91 -0
  158. package/src/exec/sgGenerator.ts +373 -0
  159. package/src/global.ts +130 -0
  160. package/src/helper/actions/api/apiRequestActions.ts +362 -0
  161. package/src/helper/actions/api/apiValidationActions.ts +594 -0
  162. package/src/helper/actions/apiActions.ts +18 -0
  163. package/src/helper/actions/apiStepDefs.ts +80 -0
  164. package/src/helper/actions/comm/commonActions.ts +165 -0
  165. package/src/helper/actions/comm/utilityActions.ts +344 -0
  166. package/src/helper/actions/commActions.ts +18 -0
  167. package/src/helper/actions/commStepDefs.ts +72 -0
  168. package/src/helper/actions/stepGroupStepDefs.ts +17 -0
  169. package/src/helper/actions/web/alertActions.ts +179 -0
  170. package/src/helper/actions/web/cookieActions.ts +124 -0
  171. package/src/helper/actions/web/downloadActions.ts +129 -0
  172. package/src/helper/actions/web/elementReaderActions.ts +323 -0
  173. package/src/helper/actions/web/formActions.ts +469 -0
  174. package/src/helper/actions/web/iframeActions.ts +67 -0
  175. package/src/helper/actions/web/javascriptActions.ts +38 -0
  176. package/src/helper/actions/web/keyboardActions.ts +101 -0
  177. package/src/helper/actions/web/localStorageActions.ts +109 -0
  178. package/src/helper/actions/web/mouseActions.ts +864 -0
  179. package/src/helper/actions/web/reportingActions.ts +53 -0
  180. package/src/helper/actions/web/screenshotActions.ts +124 -0
  181. package/src/helper/actions/web/testDataActions.ts +162 -0
  182. package/src/helper/actions/web/validationActions.ts +2287 -0
  183. package/src/helper/actions/web/waitActions.ts +757 -0
  184. package/src/helper/actions/web/webNavigation.ts +313 -0
  185. package/src/helper/actions/webActions.ts +33 -0
  186. package/src/helper/actions/webStepDefs.ts +505 -0
  187. package/src/helper/browsers/browserManager.ts +23 -0
  188. package/src/helper/bundle/defaultEntries.ts +208 -0
  189. package/src/helper/bundle/env.ts +119 -0
  190. package/src/helper/bundle/vars.ts +368 -0
  191. package/src/helper/faker/customFaker.ts +107 -0
  192. package/src/helper/faker/modules/data/postcodes_valid_sg.json +17 -0
  193. package/src/helper/faker/modules/dateTime.ts +121 -0
  194. package/src/helper/faker/modules/mobile.ts +58 -0
  195. package/src/helper/faker/modules/nric.ts +109 -0
  196. package/src/helper/faker/modules/passport.ts +34 -0
  197. package/src/helper/faker/modules/person.ts +93 -0
  198. package/src/helper/faker/modules/postcode.ts +57 -0
  199. package/src/helper/fixtures/locAggregate.ts +61 -0
  200. package/src/helper/fixtures/logFixture.ts +57 -0
  201. package/src/helper/fixtures/webFixture.ts +206 -0
  202. package/src/helper/fixtures/webLocFixture.ts +143 -0
  203. package/src/helper/report/allureStepLogger.ts +26 -0
  204. package/src/helper/report/customiseReport.ts +61 -0
  205. package/src/helper/report/init.ts +18 -0
  206. package/src/helper/report/report.ts +72 -0
  207. package/src/helper/util/dataLoader.ts +42 -0
  208. package/src/helper/util/logger.ts +32 -0
  209. package/src/helper/util/session/sessionUtil.ts +839 -0
  210. package/src/helper/util/stepHelpers.ts +14 -0
  211. package/src/helper/util/test-data/dataLoader.ts +108 -0
  212. package/src/helper/util/test-data/dataTest.ts +191 -0
  213. package/src/helper/util/test-data/registerUser.json +7 -0
  214. package/src/helper/util/totp/totpHelper.ts +102 -0
  215. package/src/helper/util/utilities/cryptoUtil.ts +53 -0
  216. package/src/helper/util/utilities/schemaGeneratorUtil.ts +143 -0
  217. package/src/helper/util/utils.ts +28 -0
  218. package/src/helper/wrapper/PlaywrightWrappers.ts +28 -0
  219. package/src/helper/wrapper/assert.ts +25 -0
  220. package/src/index.ts +17 -0
  221. package/src/scripts/get-versions.ts +68 -0
  222. package/src/scripts/posttest.ts +32 -0
  223. package/src/scripts/pretest.ts +48 -0
  224. package/src/scripts/util.ts +406 -0
  225. package/tsconfig.json +30 -0
@@ -0,0 +1,95 @@
1
+ import type { Page, Locator } from "playwright";
2
+ /**
3
+ * Web: Get Text -field: {param} -options: {param}
4
+ *
5
+ * Returns the inner text of the resolved element.
6
+ *
7
+ * @param page - Playwright Page instance
8
+ * @param field - Label/selector or Locator of the element
9
+ * @param options - Optional JSON string or object ({ pattern, actionTimeout })
10
+ * @returns The element's inner text
11
+ * @throws Error if page is not initialized or element resolution fails
12
+ */
13
+ export declare function getText(page: Page, field: string | Locator, options?: string | Record<string, any>): Promise<any>;
14
+ /**
15
+ * Web: Get Value -field: {param} -options: {param}
16
+ *
17
+ * Returns the input value of the resolved element.
18
+ *
19
+ * @param page - Playwright Page instance
20
+ * @param field - Label/selector or Locator of the element
21
+ * @param options - Optional JSON string or object ({ pattern, actionTimeout })
22
+ * @returns The input's current value
23
+ * @throws Error if page is not initialized or element resolution fails
24
+ */
25
+ export declare function getValue(page: Page, field: string | Locator, options?: string | Record<string, any>): Promise<any>;
26
+ /**
27
+ * Web: Get Attribute -field: {param} -name: {param} -options: {param}
28
+ *
29
+ * Returns the value of an attribute from the resolved element.
30
+ *
31
+ * @param page - Playwright Page instance
32
+ * @param field - Label/selector or Locator of the element
33
+ * @param name - Attribute name
34
+ * @param options - Optional JSON string or object ({ pattern, actionTimeout })
35
+ * @returns The attribute value or null
36
+ * @throws Error if page is not initialized or element resolution fails
37
+ */
38
+ export declare function getAttribute(page: Page, field: string | Locator, name: string, options?: string | Record<string, any>): Promise<any>;
39
+ /**
40
+ * Web: Has Class -field: {param} -className: {param} -options: {param}
41
+ *
42
+ * Checks whether the element has the specified CSS class.
43
+ *
44
+ * @param page - Playwright Page instance
45
+ * @param field - Label/selector or Locator of the element
46
+ * @param className - Class name to check
47
+ * @param options - Optional JSON string or object ({ pattern, actionTimeout })
48
+ * @returns True when class present; false otherwise
49
+ * @throws Error if page is not initialized or element resolution fails
50
+ */
51
+ export declare function hasClass(page: Page, field: string | Locator, className: string, options?: string | Record<string, any>): Promise<any>;
52
+ /**
53
+ * Web: Get HTML -field: {param} -options: {param}
54
+ *
55
+ * Returns the inner HTML of the resolved element.
56
+ *
57
+ * @param page - Playwright Page instance
58
+ * @param field - Label/selector or Locator of the element
59
+ * @param options - Optional JSON string or object ({ pattern, actionTimeout })
60
+ * @returns The element's inner HTML
61
+ * @throws Error if page is not initialized or element resolution fails
62
+ */
63
+ export declare function getHtml(page: Page, field: string | Locator, options?: string | Record<string, any>): Promise<any>;
64
+ /**
65
+ * Web: Store element text in Variable -field: {param} into variable: {param} -options: {param}
66
+ * Stores the text content of a web element into a variable for later use.
67
+ * @param page - Playwright Page instance.
68
+ * @param field - The label, text, id, name, or selector of the web element.
69
+ * @param variableName - The name of the variable to store the text content.
70
+ * @param options - Optional JSON string or object:
71
+ * - actionTimeout: [number] Optional timeout in milliseconds. Default: Configured timeout.
72
+ * - pattern: [string] Optional pattern to refine element search.
73
+ * - attribute: [string] If provided, reads specific attribute instead of text/value.
74
+ * - trim: [boolean] Whether to trim whitespace. Default: true.
75
+ * - normalizeWhitespace: [boolean] Whether to normalize whitespace. Default: true.
76
+ * - screenshot: [boolean] Capture screenshot after storing text. Default: false.
77
+ * - screenshotText: [string] Description for the screenshot.
78
+ */
79
+ export declare function storeElementTextInVariable(page: Page, field: string | Locator, variableName: string, options?: string | Record<string, any>): Promise<void>;
80
+ /**
81
+ * Web: Get All Texts -selector/field: {param} -options: {param}
82
+ *
83
+ * Returns an array of inner texts of all elements matching the selector or field.
84
+ *
85
+ * @param page - Playwright Page instance
86
+ * @param field - CSS selector, label, or Locator
87
+ * @param options - Optional JSON string or object:
88
+ * - pattern: [string] Pattern for pattern engine
89
+ * - fieldType: [string] Pattern engine field type (default: 'field')
90
+ * - itemSelector: [string] Sub-selector to locate text inside each element
91
+ * - attribute: [string] Attribute to extract instead of innerText (e.g., 'textContent', 'value')
92
+ * - actionTimeout: [number] Timeout in ms
93
+ * @returns Array of strings representing the text of each element
94
+ */
95
+ export declare function getAllTexts(page: Page, field: string | Locator, options?: string | Record<string, any>): Promise<string[]>;
@@ -0,0 +1,326 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.getText = getText;
37
+ exports.getValue = getValue;
38
+ exports.getAttribute = getAttribute;
39
+ exports.hasClass = hasClass;
40
+ exports.getHtml = getHtml;
41
+ exports.storeElementTextInVariable = storeElementTextInVariable;
42
+ exports.getAllTexts = getAllTexts;
43
+ /**
44
+ * @file elementReaderActions.ts
45
+ *
46
+ * Element reader helpers for PlayQ web actions.
47
+ * Provides text/value/attribute/class/html readers and a utility to store
48
+ * element text into a PlayQ variable, with runner-aware step wrappers.
49
+ *
50
+ * Authors: PlayQ Team
51
+ * Version: v1.0.0
52
+ */
53
+ const allure = __importStar(require("allure-js-commons"));
54
+ const global_1 = require("../../../global");
55
+ const screenshotActions_1 = require("./screenshotActions");
56
+ const commonActions_1 = require("../comm/commonActions");
57
+ const config = {};
58
+ function isPlaywrightRunner() { return process.env.TEST_RUNNER === 'playwright'; }
59
+ const __allureAny_reader = allure;
60
+ if (typeof __allureAny_reader.step !== 'function') {
61
+ __allureAny_reader.step = async (_n, f) => await f();
62
+ }
63
+ // Allure compatibility shim: if step is unavailable, just run the body
64
+ const __allureAny_web = allure;
65
+ if (typeof __allureAny_web.step !== 'function') {
66
+ __allureAny_web.step = async (_name, fn) => await fn();
67
+ }
68
+ /**
69
+ * Web: Get Text -field: {param} -options: {param}
70
+ *
71
+ * Returns the inner text of the resolved element.
72
+ *
73
+ * @param page - Playwright Page instance
74
+ * @param field - Label/selector or Locator of the element
75
+ * @param options - Optional JSON string or object ({ pattern, actionTimeout })
76
+ * @returns The element's inner text
77
+ * @throws Error if page is not initialized or element resolution fails
78
+ */
79
+ async function getText(page, field, options) {
80
+ const options_json = typeof options === 'string' ? global_1.vars.parseLooseJson(options) : options || {};
81
+ const stepName = `Web: Get Text -field: ${typeof field === 'string' ? field : '<locator>'}`;
82
+ const run = async () => {
83
+ if (!page)
84
+ throw new Error("Page not initialized");
85
+ const locator = typeof field === 'string'
86
+ ? await (0, global_1.webLocResolver)((options_json === null || options_json === void 0 ? void 0 : options_json.fieldType) || '', field, page, options_json === null || options_json === void 0 ? void 0 : options_json.pattern, typeof (options_json === null || options_json === void 0 ? void 0 : options_json.actionTimeout) === 'number' ? options_json.actionTimeout : undefined, (options_json === null || options_json === void 0 ? void 0 : options_json.smartAiRefresh) || '')
87
+ : field;
88
+ return locator.innerText();
89
+ };
90
+ if (isPlaywrightRunner()) {
91
+ return __allureAny_reader.step(stepName, run);
92
+ }
93
+ return run();
94
+ }
95
+ /**
96
+ * Web: Get Value -field: {param} -options: {param}
97
+ *
98
+ * Returns the input value of the resolved element.
99
+ *
100
+ * @param page - Playwright Page instance
101
+ * @param field - Label/selector or Locator of the element
102
+ * @param options - Optional JSON string or object ({ pattern, actionTimeout })
103
+ * @returns The input's current value
104
+ * @throws Error if page is not initialized or element resolution fails
105
+ */
106
+ async function getValue(page, field, options) {
107
+ const options_json = typeof options === 'string' ? global_1.vars.parseLooseJson(options) : options || {};
108
+ const stepName = `Web: Get Value -field: ${typeof field === 'string' ? field : '<locator>'}`;
109
+ const run = async () => {
110
+ if (!page)
111
+ throw new Error("Page not initialized");
112
+ const locator = typeof field === 'string'
113
+ ? await (0, global_1.webLocResolver)((options_json === null || options_json === void 0 ? void 0 : options_json.fieldType) || '', field, page, options_json === null || options_json === void 0 ? void 0 : options_json.pattern, typeof (options_json === null || options_json === void 0 ? void 0 : options_json.actionTimeout) === 'number' ? options_json.actionTimeout : undefined, (options_json === null || options_json === void 0 ? void 0 : options_json.smartAiRefresh) || '')
114
+ : field;
115
+ return locator.inputValue();
116
+ };
117
+ if (isPlaywrightRunner()) {
118
+ return __allureAny_reader.step(stepName, run);
119
+ }
120
+ return run();
121
+ }
122
+ /**
123
+ * Web: Get Attribute -field: {param} -name: {param} -options: {param}
124
+ *
125
+ * Returns the value of an attribute from the resolved element.
126
+ *
127
+ * @param page - Playwright Page instance
128
+ * @param field - Label/selector or Locator of the element
129
+ * @param name - Attribute name
130
+ * @param options - Optional JSON string or object ({ pattern, actionTimeout })
131
+ * @returns The attribute value or null
132
+ * @throws Error if page is not initialized or element resolution fails
133
+ */
134
+ async function getAttribute(page, field, name, options) {
135
+ const options_json = typeof options === 'string' ? global_1.vars.parseLooseJson(options) : options || {};
136
+ const stepName = `Web: Get Attribute -field: ${typeof field === 'string' ? field : '<locator>'} -name: ${name}`;
137
+ const run = async () => {
138
+ if (!page)
139
+ throw new Error("Page not initialized");
140
+ const locator = typeof field === 'string'
141
+ ? await (0, global_1.webLocResolver)((options_json === null || options_json === void 0 ? void 0 : options_json.fieldType) || '', field, page, options_json === null || options_json === void 0 ? void 0 : options_json.pattern, typeof (options_json === null || options_json === void 0 ? void 0 : options_json.actionTimeout) === 'number' ? options_json.actionTimeout : undefined, (options_json === null || options_json === void 0 ? void 0 : options_json.smartAiRefresh) || '')
142
+ : field;
143
+ return locator.getAttribute(name);
144
+ };
145
+ if (isPlaywrightRunner()) {
146
+ return __allureAny_reader.step(stepName, run);
147
+ }
148
+ return run();
149
+ }
150
+ /**
151
+ * Web: Has Class -field: {param} -className: {param} -options: {param}
152
+ *
153
+ * Checks whether the element has the specified CSS class.
154
+ *
155
+ * @param page - Playwright Page instance
156
+ * @param field - Label/selector or Locator of the element
157
+ * @param className - Class name to check
158
+ * @param options - Optional JSON string or object ({ pattern, actionTimeout })
159
+ * @returns True when class present; false otherwise
160
+ * @throws Error if page is not initialized or element resolution fails
161
+ */
162
+ async function hasClass(page, field, className, options) {
163
+ const options_json = typeof options === 'string' ? global_1.vars.parseLooseJson(options) : options || {};
164
+ const stepName = `Web: Has Class -field: ${typeof field === 'string' ? field : '<locator>'} -className: ${className}`;
165
+ const run = async () => {
166
+ if (!page)
167
+ throw new Error("Page not initialized");
168
+ const locator = typeof field === 'string'
169
+ ? await (0, global_1.webLocResolver)((options_json === null || options_json === void 0 ? void 0 : options_json.fieldType) || '', field, page, options_json === null || options_json === void 0 ? void 0 : options_json.pattern, typeof (options_json === null || options_json === void 0 ? void 0 : options_json.actionTimeout) === 'number' ? options_json.actionTimeout : undefined, (options_json === null || options_json === void 0 ? void 0 : options_json.smartAiRefresh) || '')
170
+ : field;
171
+ const cls = await locator.getAttribute('class');
172
+ return (cls || '').split(/\s+/).includes(className);
173
+ };
174
+ if (isPlaywrightRunner()) {
175
+ return __allureAny_reader.step(stepName, run);
176
+ }
177
+ return run();
178
+ }
179
+ /**
180
+ * Web: Get HTML -field: {param} -options: {param}
181
+ *
182
+ * Returns the inner HTML of the resolved element.
183
+ *
184
+ * @param page - Playwright Page instance
185
+ * @param field - Label/selector or Locator of the element
186
+ * @param options - Optional JSON string or object ({ pattern, actionTimeout })
187
+ * @returns The element's inner HTML
188
+ * @throws Error if page is not initialized or element resolution fails
189
+ */
190
+ async function getHtml(page, field, options) {
191
+ const options_json = typeof options === 'string' ? global_1.vars.parseLooseJson(options) : options || {};
192
+ const stepName = `Web: Get HTML -field: ${typeof field === 'string' ? field : '<locator>'}`;
193
+ const run = async () => {
194
+ if (!page)
195
+ throw new Error("Page not initialized");
196
+ const locator = typeof field === 'string'
197
+ ? await (0, global_1.webLocResolver)((options_json === null || options_json === void 0 ? void 0 : options_json.fieldType) || '', field, page, options_json === null || options_json === void 0 ? void 0 : options_json.pattern, typeof (options_json === null || options_json === void 0 ? void 0 : options_json.actionTimeout) === 'number' ? options_json.actionTimeout : undefined, (options_json === null || options_json === void 0 ? void 0 : options_json.smartAiRefresh) || '')
198
+ : field;
199
+ return locator.innerHTML();
200
+ };
201
+ if (isPlaywrightRunner()) {
202
+ return __allureAny_reader.step(stepName, run);
203
+ }
204
+ return run();
205
+ }
206
+ /**
207
+ * Web: Store element text in Variable -field: {param} into variable: {param} -options: {param}
208
+ * Stores the text content of a web element into a variable for later use.
209
+ * @param page - Playwright Page instance.
210
+ * @param field - The label, text, id, name, or selector of the web element.
211
+ * @param variableName - The name of the variable to store the text content.
212
+ * @param options - Optional JSON string or object:
213
+ * - actionTimeout: [number] Optional timeout in milliseconds. Default: Configured timeout.
214
+ * - pattern: [string] Optional pattern to refine element search.
215
+ * - attribute: [string] If provided, reads specific attribute instead of text/value.
216
+ * - trim: [boolean] Whether to trim whitespace. Default: true.
217
+ * - normalizeWhitespace: [boolean] Whether to normalize whitespace. Default: true.
218
+ * - screenshot: [boolean] Capture screenshot after storing text. Default: false.
219
+ * - screenshotText: [string] Description for the screenshot.
220
+ */
221
+ async function storeElementTextInVariable(page, field, variableName, options) {
222
+ var _a;
223
+ const options_json = typeof options === "string" ? global_1.vars.parseLooseJson(options) : options || {};
224
+ // Default fieldType to "input" if not provided or falsy
225
+ const { actionTimeout = ((_a = config === null || config === void 0 ? void 0 : config.testExecution) === null || _a === void 0 ? void 0 : _a.actionTimeout) || Number(global_1.vars.getConfigValue("testExecution.actionTimeout")) || 30000, pattern, fieldType = "input", attribute = "", trim = true, normalizeWhitespace = true, screenshot = false, screenshotText = "", screenshotFullPage = true, } = options_json;
226
+ if (isPlaywrightRunner()) {
227
+ await __allureAny_web.step(`Web: Store element text in Variable -field: ${field} into variable: ${variableName} -options: ${JSON.stringify(options_json)}`, async () => {
228
+ await doStoreElementTextInVariable();
229
+ });
230
+ }
231
+ else {
232
+ await doStoreElementTextInVariable();
233
+ }
234
+ async function doStoreElementTextInVariable() {
235
+ if (!page)
236
+ throw new Error("Page not initialized");
237
+ const target = typeof field === "string"
238
+ ? await (0, global_1.webLocResolver)(fieldType, field, page, pattern, actionTimeout)
239
+ : field;
240
+ await target.waitFor({ state: "visible", timeout: actionTimeout });
241
+ const tag = await target.evaluate((el) => el.tagName.toLowerCase());
242
+ let raw;
243
+ if (attribute) {
244
+ raw = await target.getAttribute(attribute);
245
+ }
246
+ else if (tag === "input" || tag === "textarea" || tag === "select") {
247
+ raw = await target.inputValue();
248
+ }
249
+ else {
250
+ raw = await target.innerText();
251
+ }
252
+ let value = (raw !== null && raw !== void 0 ? raw : "").toString();
253
+ if (trim)
254
+ value = value.trim();
255
+ if (normalizeWhitespace)
256
+ value = value.replace(/\s+/g, " ");
257
+ if (typeof global_1.vars.setValue === "function") {
258
+ global_1.vars.setValue(variableName, value);
259
+ }
260
+ else if (typeof global_1.vars.set === "function") {
261
+ global_1.vars.set(variableName, value);
262
+ }
263
+ else {
264
+ throw new Error(`No supported setter found on vars to store "${variableName}"`);
265
+ }
266
+ await (0, commonActions_1.attachLog)(`✅ Stored element text into "${variableName}": "${value}"`, "text/plain");
267
+ await (0, screenshotActions_1.processScreenshot)(page, screenshot, screenshotText || `Stored text for: ${variableName}`, screenshotFullPage);
268
+ }
269
+ }
270
+ /**
271
+ * Web: Get All Texts -selector/field: {param} -options: {param}
272
+ *
273
+ * Returns an array of inner texts of all elements matching the selector or field.
274
+ *
275
+ * @param page - Playwright Page instance
276
+ * @param field - CSS selector, label, or Locator
277
+ * @param options - Optional JSON string or object:
278
+ * - pattern: [string] Pattern for pattern engine
279
+ * - fieldType: [string] Pattern engine field type (default: 'field')
280
+ * - itemSelector: [string] Sub-selector to locate text inside each element
281
+ * - attribute: [string] Attribute to extract instead of innerText (e.g., 'textContent', 'value')
282
+ * - actionTimeout: [number] Timeout in ms
283
+ * @returns Array of strings representing the text of each element
284
+ */
285
+ async function getAllTexts(page, field, options) {
286
+ var _a;
287
+ const options_json = typeof options === "string" ? global_1.vars.parseLooseJson(options) : options || {};
288
+ const { pattern = '', fieldType = 'field', itemSelector = '', attribute = 'innerText', actionTimeout = ((_a = config === null || config === void 0 ? void 0 : config.testExecution) === null || _a === void 0 ? void 0 : _a.actionTimeout) || Number(global_1.vars.getConfigValue("testExecution.actionTimeout")) || 30000 } = options_json;
289
+ const stepName = `Web: Get All Texts -field: ${typeof field === 'string' ? field : '<locator>'} -options: ${JSON.stringify(options_json)}`;
290
+ const run = async () => {
291
+ if (!page)
292
+ throw new Error("Page not initialized");
293
+ // Resolve locator
294
+ const locator = typeof field === 'string'
295
+ ? await (0, global_1.webLocResolver)(fieldType, field, page, pattern, actionTimeout)
296
+ : field;
297
+ const count = await locator.count();
298
+ if (count === 0) {
299
+ await (0, commonActions_1.attachLog)(`❌ No elements found for field/selector "${field}"`, "text/plain");
300
+ return [];
301
+ }
302
+ const texts = [];
303
+ for (let i = 0; i < count; i++) {
304
+ let el = locator.nth(i);
305
+ if (itemSelector)
306
+ el = el.locator(itemSelector);
307
+ let value;
308
+ if (attribute === 'innerText') {
309
+ value = (await el.innerText()).trim();
310
+ }
311
+ else if (attribute === 'textContent') {
312
+ value = (await el.textContent() || '').trim();
313
+ }
314
+ else {
315
+ value = (await el.getAttribute(attribute) || '').trim();
316
+ }
317
+ texts.push(value.replace(/\s+/g, ' '));
318
+ }
319
+ await (0, commonActions_1.attachLog)(`✅ Retrieved texts for "${field}": ${texts.join(', ')}`, "text/plain");
320
+ return texts;
321
+ };
322
+ if (isPlaywrightRunner()) {
323
+ return __allureAny_reader.step(stepName, run);
324
+ }
325
+ return run();
326
+ }
@@ -0,0 +1,122 @@
1
+ import { Page, Locator } from "@playwright/test";
2
+ /**
3
+ * Web: Fill -field: {param} -value: {param} -options: {param}
4
+ *
5
+ * Fills a form input field (e.g., text box, textarea) with the specified value.
6
+ *
7
+ * @param field - The label, placeholder, id, name, or pattern of the input field (e.g., "Username", "Email", "search").
8
+ * @param value - The text value to fill in the input field (e.g., "JohnDoe", "test@example.com").
9
+ * @param options - Optional JSON string or object:
10
+ * - actionTimeout: [number] Timeout in ms (default: 30000)
11
+ * - pattern: [string] Optional pattern to refine element search. Default: Configured pattern.
12
+ * - screenshot: [boolean] Capture a screenshot after filling the input. Default: false.
13
+ * - screenshotText: [string] Text description for the screenshot. Default: "".
14
+ * - screenshotFullPage: [boolean] Capture a full page screenshot. Default: true.
15
+ * - screenshotField: [boolean] Capture screenshot of the field (input element) only. Overrides fullPage. Default: false.
16
+ *
17
+ * @example
18
+ * Web: Fill -field: "Username" -value: "JohnDoe" -options: "{screenshot: true, screenshotText: 'After filling Username', screenshotField: true}"
19
+ */
20
+ export declare function fill(page: Page, field: string | Locator, value: string | number, options?: string | Record<string, any>): Promise<void>;
21
+ export declare const input: typeof fill;
22
+ export declare const type: typeof fill;
23
+ export declare const set: typeof fill;
24
+ export declare const enter: typeof fill;
25
+ /**
26
+ * Web: Append -field: {param} -value: {param} -options: {param}
27
+ *
28
+ * Appends text to an input or textarea without clearing existing content.
29
+ *
30
+ * @param page - Playwright Page instance
31
+ * @param field - The label, placeholder, id, name, or pattern of the input field
32
+ * @param value - The text value to append
33
+ * @param options - Optional JSON string or object:
34
+ * - actionTimeout: [number] Timeout in ms (default: 30000)
35
+ * - pattern: [string] Optional pattern to refine element search
36
+ * - screenshot: [boolean] Capture a screenshot after appending (default: false)
37
+ * - screenshotText: [string] Text description for the screenshot
38
+ * - screenshotFullPage: [boolean] Capture a full page screenshot (default: true)
39
+ * - screenshotField: [boolean] Capture screenshot of the field (input element) only (default: false)
40
+ */
41
+ export declare function append(page: Page, field: string | Locator, value: string | number, options?: string | Record<string, any>): Promise<void>;
42
+ /**
43
+ * Web: Select Option -field: {param} -value: {param} -options: {param}
44
+ *
45
+ * Selects an option in a dropdown by label or value.
46
+ * Delegates to core `selectDropdown`.
47
+ *
48
+ * @param page Playwright Page instance
49
+ * @param field Dropdown locator or string selector
50
+ * @param value Option label or value
51
+ * @param options Optional JSON string or object ({ actionTimeout, pattern })
52
+ */
53
+ /**
54
+ * Web: Select Dropdown -field: {param} -value: {param} -options: {param}
55
+ *
56
+ * Selects a dropdown option by visible text or value.
57
+ * Works with both native <select> elements and custom dropdowns.
58
+ *
59
+ * @param page - Playwright Page instance
60
+ * @param field - Locator or label of the dropdown
61
+ * @param value - Value or label of the option to select
62
+ * @param options - Optional string or object containing:
63
+ * - actionTimeout: custom timeout
64
+ * - pattern: extra pattern string for locator resolution
65
+ * - screenshot: boolean (default false)
66
+ * - screenshotText: text for screenshot description
67
+ * - screenshotFullPage: boolean (default true)
68
+ * - smartIQ_refreshLoc: optional override for locator refresh key
69
+ */
70
+ export declare function selectOption(page: Page, field: string | Locator, value: string | number, options?: string | Record<string, any>): Promise<void>;
71
+ /**
72
+ * Web: Upload File -field: {param} -file: {param} -options: {param}
73
+ *
74
+ * Uploads a file to an input element.
75
+ * Delegates to core `uploadFile`.
76
+ *
77
+ * @param page Playwright Page instance
78
+ * @param field File input locator or string selector
79
+ * @param file Local file path
80
+ * @param options Optional JSON string or object ({ actionTimeout })
81
+ */
82
+ export declare function uploadFile(page: Page, field: string | Locator, file: string, options?: string | Record<string, any>): Promise<void>;
83
+ /**
84
+ * Web: Select Dropdown by Index -field: {param} -index: {param} -options: {param}
85
+ *
86
+ * Selects a dropdown option by its index (zero-based).
87
+ * Works with both native <select> elements and custom dropdowns.
88
+ *
89
+ * @param page - Playwright Page instance
90
+ * @param field - Locator or label of the dropdown
91
+ * @param index - Index of the option to select (zero-based)
92
+ * @param options - Optional string or object containing:
93
+ * - actionTimeout: custom timeout
94
+ * - pattern: extra pattern string for locator resolution
95
+ * - screenshot: boolean (default false)
96
+ * - screenshotText: text for screenshot description
97
+ * - screenshotFullPage: boolean (default true)
98
+ * - smartIQ_refreshLoc: optional override for locator refresh key
99
+ */
100
+ export declare function selectOptionByIndex(page: Page, field: string | Locator, index: number, options?: string | Record<string, any>): Promise<void>;
101
+ /**
102
+ * Web: Select Dropdown -field: {param} -value: {param} -options: {param}
103
+ *
104
+ * Selects a dropdown option by visible text or value.
105
+ * Works with both native <select> elements and custom dropdowns.
106
+ *
107
+ * @param page - Playwright Page instance
108
+ * @param field - Locator or label of the dropdown
109
+ * @param value - Value or label of the option to select
110
+ * @param options - Optional string or object containing:
111
+ * - actionTimeout: custom timeout
112
+ * - pattern: extra pattern string for locator resolution
113
+ * - screenshot: boolean (default false)
114
+ * - screenshotText: text for screenshot description
115
+ * - screenshotFullPage: boolean (default true)
116
+ * - smartIQ_refreshLoc: optional override for locator refresh key
117
+ */
118
+ export declare function selectDropdown(page: Page, field: string | Locator, value: string | number, options?: string | Record<string, any>): Promise<void>;
119
+ /**
120
+ * Alias: Select Dropdown by Index (wrapper to selectOptionByIndex)
121
+ */
122
+ export declare function selectDropdownByIndex(page: Page, field: string | Locator, index: number, options?: string | Record<string, any>): Promise<void>;