@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.
- package/README.md +41 -0
- package/bin/playq.js +175 -0
- package/cucumber.js +10 -0
- package/dist/exec/featureFileCache.d.ts +21 -0
- package/dist/exec/featureFileCache.js +124 -0
- package/dist/exec/featureFilePreProcess.d.ts +12 -0
- package/dist/exec/featureFilePreProcess.js +208 -0
- package/dist/exec/preLoader.d.ts +1 -0
- package/dist/exec/preLoader.js +72 -0
- package/dist/exec/preProcessEntry.d.ts +1 -0
- package/dist/exec/preProcessEntry.js +83 -0
- package/dist/exec/preProcess_old_todelete.d.ts +1 -0
- package/dist/exec/preProcess_old_todelete.js +258 -0
- package/dist/exec/runner.d.ts +1 -0
- package/dist/exec/runner.js +221 -0
- package/dist/exec/runner_orchestrator.d.ts +1 -0
- package/dist/exec/runner_orchestrator.js +85 -0
- package/dist/exec/sgGenerator.d.ts +11 -0
- package/dist/exec/sgGenerator.js +310 -0
- package/dist/global.d.ts +15 -0
- package/dist/global.js +185 -0
- package/dist/helper/actions/api/apiRequestActions.d.ts +117 -0
- package/dist/helper/actions/api/apiRequestActions.js +374 -0
- package/dist/helper/actions/api/apiValidationActions.d.ts +119 -0
- package/dist/helper/actions/api/apiValidationActions.js +615 -0
- package/dist/helper/actions/apiActions.d.ts +18 -0
- package/dist/helper/actions/apiActions.js +34 -0
- package/dist/helper/actions/apiStepDefs.d.ts +1 -0
- package/dist/helper/actions/apiStepDefs.js +64 -0
- package/dist/helper/actions/comm/commonActions.d.ts +58 -0
- package/dist/helper/actions/comm/commonActions.js +198 -0
- package/dist/helper/actions/comm/utilityActions.d.ts +131 -0
- package/dist/helper/actions/comm/utilityActions.js +351 -0
- package/dist/helper/actions/commActions.d.ts +18 -0
- package/dist/helper/actions/commActions.js +34 -0
- package/dist/helper/actions/commStepDefs.d.ts +1 -0
- package/dist/helper/actions/commStepDefs.js +57 -0
- package/dist/helper/actions/stepGroupStepDefs.d.ts +1 -0
- package/dist/helper/actions/stepGroupStepDefs.js +15 -0
- package/dist/helper/actions/web/alertActions.d.ts +61 -0
- package/dist/helper/actions/web/alertActions.js +224 -0
- package/dist/helper/actions/web/cookieActions.d.ts +45 -0
- package/dist/helper/actions/web/cookieActions.js +186 -0
- package/dist/helper/actions/web/downloadActions.d.ts +40 -0
- package/dist/helper/actions/web/downloadActions.js +153 -0
- package/dist/helper/actions/web/elementReaderActions.d.ts +95 -0
- package/dist/helper/actions/web/elementReaderActions.js +326 -0
- package/dist/helper/actions/web/formActions.d.ts +122 -0
- package/dist/helper/actions/web/formActions.js +423 -0
- package/dist/helper/actions/web/iframeActions.d.ts +23 -0
- package/dist/helper/actions/web/iframeActions.js +108 -0
- package/dist/helper/actions/web/javascriptActions.d.ts +14 -0
- package/dist/helper/actions/web/javascriptActions.js +77 -0
- package/dist/helper/actions/web/keyboardActions.d.ts +35 -0
- package/dist/helper/actions/web/keyboardActions.js +118 -0
- package/dist/helper/actions/web/localStorageActions.d.ts +51 -0
- package/dist/helper/actions/web/localStorageActions.js +163 -0
- package/dist/helper/actions/web/mouseActions.d.ts +240 -0
- package/dist/helper/actions/web/mouseActions.js +609 -0
- package/dist/helper/actions/web/reportingActions.d.ts +34 -0
- package/dist/helper/actions/web/reportingActions.js +58 -0
- package/dist/helper/actions/web/screenshotActions.d.ts +34 -0
- package/dist/helper/actions/web/screenshotActions.js +151 -0
- package/dist/helper/actions/web/testDataActions.d.ts +21 -0
- package/dist/helper/actions/web/testDataActions.js +211 -0
- package/dist/helper/actions/web/validationActions.d.ts +547 -0
- package/dist/helper/actions/web/validationActions.js +1754 -0
- package/dist/helper/actions/web/waitActions.d.ts +191 -0
- package/dist/helper/actions/web/waitActions.js +589 -0
- package/dist/helper/actions/web/webNavigation.d.ts +104 -0
- package/dist/helper/actions/web/webNavigation.js +288 -0
- package/dist/helper/actions/webActions.d.ts +32 -0
- package/dist/helper/actions/webActions.js +48 -0
- package/dist/helper/actions/webStepDefs.d.ts +1 -0
- package/dist/helper/actions/webStepDefs.js +455 -0
- package/dist/helper/browsers/browserManager.d.ts +1 -0
- package/dist/helper/browsers/browserManager.js +56 -0
- package/dist/helper/bundle/defaultEntries.d.ts +6 -0
- package/dist/helper/bundle/defaultEntries.js +200 -0
- package/dist/helper/bundle/env.d.ts +1 -0
- package/dist/helper/bundle/env.js +157 -0
- package/dist/helper/bundle/vars.d.ts +9 -0
- package/dist/helper/bundle/vars.js +375 -0
- package/dist/helper/faker/customFaker.d.ts +55 -0
- package/dist/helper/faker/customFaker.js +45 -0
- package/dist/helper/faker/modules/data/postcodes_valid_sg.json +17 -0
- package/dist/helper/faker/modules/dateTime.d.ts +18 -0
- package/dist/helper/faker/modules/dateTime.js +106 -0
- package/dist/helper/faker/modules/mobile.d.ts +4 -0
- package/dist/helper/faker/modules/mobile.js +59 -0
- package/dist/helper/faker/modules/nric.d.ts +32 -0
- package/dist/helper/faker/modules/nric.js +84 -0
- package/dist/helper/faker/modules/passport.d.ts +3 -0
- package/dist/helper/faker/modules/passport.js +36 -0
- package/dist/helper/faker/modules/person.d.ts +14 -0
- package/dist/helper/faker/modules/person.js +73 -0
- package/dist/helper/faker/modules/postcode.d.ts +6 -0
- package/dist/helper/faker/modules/postcode.js +47 -0
- package/dist/helper/fixtures/locAggregate.d.ts +7 -0
- package/dist/helper/fixtures/locAggregate.js +94 -0
- package/dist/helper/fixtures/logFixture.d.ts +8 -0
- package/dist/helper/fixtures/logFixture.js +56 -0
- package/dist/helper/fixtures/webFixture.d.ts +19 -0
- package/dist/helper/fixtures/webFixture.js +186 -0
- package/dist/helper/fixtures/webLocFixture.d.ts +2 -0
- package/dist/helper/fixtures/webLocFixture.js +144 -0
- package/dist/helper/report/allureStepLogger.d.ts +0 -0
- package/dist/helper/report/allureStepLogger.js +25 -0
- package/dist/helper/report/customiseReport.d.ts +1 -0
- package/dist/helper/report/customiseReport.js +55 -0
- package/dist/helper/report/init.d.ts +1 -0
- package/dist/helper/report/init.js +14 -0
- package/dist/helper/report/report.d.ts +1 -0
- package/dist/helper/report/report.js +102 -0
- package/dist/helper/util/dataLoader.d.ts +10 -0
- package/dist/helper/util/dataLoader.js +73 -0
- package/dist/helper/util/logger.d.ts +4 -0
- package/dist/helper/util/logger.js +61 -0
- package/dist/helper/util/session/sessionUtil.d.ts +26 -0
- package/dist/helper/util/session/sessionUtil.js +729 -0
- package/dist/helper/util/stepHelpers.d.ts +2 -0
- package/dist/helper/util/stepHelpers.js +16 -0
- package/dist/helper/util/test-data/dataLoader.d.ts +7 -0
- package/dist/helper/util/test-data/dataLoader.js +145 -0
- package/dist/helper/util/test-data/dataTest.d.ts +10 -0
- package/dist/helper/util/test-data/dataTest.js +216 -0
- package/dist/helper/util/totp/totpHelper.d.ts +38 -0
- package/dist/helper/util/totp/totpHelper.js +117 -0
- package/dist/helper/util/utilities/cryptoUtil.d.ts +2 -0
- package/dist/helper/util/utilities/cryptoUtil.js +53 -0
- package/dist/helper/util/utilities/schemaGeneratorUtil.d.ts +2 -0
- package/dist/helper/util/utilities/schemaGeneratorUtil.js +129 -0
- package/dist/helper/util/utils.d.ts +2 -0
- package/dist/helper/util/utils.js +22 -0
- package/dist/helper/wrapper/PlaywrightWrappers.d.ts +8 -0
- package/dist/helper/wrapper/PlaywrightWrappers.js +26 -0
- package/dist/helper/wrapper/assert.d.ts +9 -0
- package/dist/helper/wrapper/assert.js +23 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +57 -0
- package/dist/scripts/get-versions.d.ts +1 -0
- package/dist/scripts/get-versions.js +98 -0
- package/dist/scripts/posttest.d.ts +1 -0
- package/dist/scripts/posttest.js +29 -0
- package/dist/scripts/pretest.d.ts +1 -0
- package/dist/scripts/pretest.js +57 -0
- package/dist/scripts/util.d.ts +1 -0
- package/dist/scripts/util.js +376 -0
- package/package.json +68 -0
- package/src/exec/featureFileCache.ts +80 -0
- package/src/exec/featureFilePreProcess.ts +239 -0
- package/src/exec/preLoader.ts +72 -0
- package/src/exec/preProcessEntry.ts +59 -0
- package/src/exec/preProcess_old_todelete.ts +289 -0
- package/src/exec/runner.ts +241 -0
- package/src/exec/runnerCuke.js +90 -0
- package/src/exec/runner_orchestrator.ts +91 -0
- package/src/exec/sgGenerator.ts +373 -0
- package/src/global.ts +130 -0
- package/src/helper/actions/api/apiRequestActions.ts +362 -0
- package/src/helper/actions/api/apiValidationActions.ts +594 -0
- package/src/helper/actions/apiActions.ts +18 -0
- package/src/helper/actions/apiStepDefs.ts +80 -0
- package/src/helper/actions/comm/commonActions.ts +165 -0
- package/src/helper/actions/comm/utilityActions.ts +344 -0
- package/src/helper/actions/commActions.ts +18 -0
- package/src/helper/actions/commStepDefs.ts +72 -0
- package/src/helper/actions/stepGroupStepDefs.ts +17 -0
- package/src/helper/actions/web/alertActions.ts +179 -0
- package/src/helper/actions/web/cookieActions.ts +124 -0
- package/src/helper/actions/web/downloadActions.ts +129 -0
- package/src/helper/actions/web/elementReaderActions.ts +323 -0
- package/src/helper/actions/web/formActions.ts +469 -0
- package/src/helper/actions/web/iframeActions.ts +67 -0
- package/src/helper/actions/web/javascriptActions.ts +38 -0
- package/src/helper/actions/web/keyboardActions.ts +101 -0
- package/src/helper/actions/web/localStorageActions.ts +109 -0
- package/src/helper/actions/web/mouseActions.ts +864 -0
- package/src/helper/actions/web/reportingActions.ts +53 -0
- package/src/helper/actions/web/screenshotActions.ts +124 -0
- package/src/helper/actions/web/testDataActions.ts +162 -0
- package/src/helper/actions/web/validationActions.ts +2287 -0
- package/src/helper/actions/web/waitActions.ts +757 -0
- package/src/helper/actions/web/webNavigation.ts +313 -0
- package/src/helper/actions/webActions.ts +33 -0
- package/src/helper/actions/webStepDefs.ts +505 -0
- package/src/helper/browsers/browserManager.ts +23 -0
- package/src/helper/bundle/defaultEntries.ts +208 -0
- package/src/helper/bundle/env.ts +119 -0
- package/src/helper/bundle/vars.ts +368 -0
- package/src/helper/faker/customFaker.ts +107 -0
- package/src/helper/faker/modules/data/postcodes_valid_sg.json +17 -0
- package/src/helper/faker/modules/dateTime.ts +121 -0
- package/src/helper/faker/modules/mobile.ts +58 -0
- package/src/helper/faker/modules/nric.ts +109 -0
- package/src/helper/faker/modules/passport.ts +34 -0
- package/src/helper/faker/modules/person.ts +93 -0
- package/src/helper/faker/modules/postcode.ts +57 -0
- package/src/helper/fixtures/locAggregate.ts +61 -0
- package/src/helper/fixtures/logFixture.ts +57 -0
- package/src/helper/fixtures/webFixture.ts +206 -0
- package/src/helper/fixtures/webLocFixture.ts +143 -0
- package/src/helper/report/allureStepLogger.ts +26 -0
- package/src/helper/report/customiseReport.ts +61 -0
- package/src/helper/report/init.ts +18 -0
- package/src/helper/report/report.ts +72 -0
- package/src/helper/util/dataLoader.ts +42 -0
- package/src/helper/util/logger.ts +32 -0
- package/src/helper/util/session/sessionUtil.ts +839 -0
- package/src/helper/util/stepHelpers.ts +14 -0
- package/src/helper/util/test-data/dataLoader.ts +108 -0
- package/src/helper/util/test-data/dataTest.ts +191 -0
- package/src/helper/util/test-data/registerUser.json +7 -0
- package/src/helper/util/totp/totpHelper.ts +102 -0
- package/src/helper/util/utilities/cryptoUtil.ts +53 -0
- package/src/helper/util/utilities/schemaGeneratorUtil.ts +143 -0
- package/src/helper/util/utils.ts +28 -0
- package/src/helper/wrapper/PlaywrightWrappers.ts +28 -0
- package/src/helper/wrapper/assert.ts +25 -0
- package/src/index.ts +17 -0
- package/src/scripts/get-versions.ts +68 -0
- package/src/scripts/posttest.ts +32 -0
- package/src/scripts/pretest.ts +48 -0
- package/src/scripts/util.ts +406 -0
- package/tsconfig.json +30 -0
|
@@ -0,0 +1,423 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.enter = exports.set = exports.type = exports.input = void 0;
|
|
40
|
+
exports.fill = fill;
|
|
41
|
+
exports.append = append;
|
|
42
|
+
exports.selectOption = selectOption;
|
|
43
|
+
exports.uploadFile = uploadFile;
|
|
44
|
+
exports.selectOptionByIndex = selectOptionByIndex;
|
|
45
|
+
exports.selectDropdown = selectDropdown;
|
|
46
|
+
exports.selectDropdownByIndex = selectDropdownByIndex;
|
|
47
|
+
/**
|
|
48
|
+
* @file formActions.ts
|
|
49
|
+
*
|
|
50
|
+
* Form interaction helpers for PlayQ web actions.
|
|
51
|
+
* Provides fill/select/upload utilities with runner-aware step wrappers,
|
|
52
|
+
* locator resolution, and screenshot options.
|
|
53
|
+
*
|
|
54
|
+
* Authors: PlayQ Team
|
|
55
|
+
* Version: v1.0.0
|
|
56
|
+
*/
|
|
57
|
+
const allure = __importStar(require("allure-js-commons"));
|
|
58
|
+
const global_1 = require("../../../global");
|
|
59
|
+
const path_1 = __importDefault(require("path"));
|
|
60
|
+
const fs_1 = __importDefault(require("fs"));
|
|
61
|
+
const webLocFixture_1 = require("../../fixtures/webLocFixture");
|
|
62
|
+
const waitActions_1 = require("./waitActions");
|
|
63
|
+
const screenshotActions_1 = require("./screenshotActions");
|
|
64
|
+
const vars_1 = require("../../bundle/vars");
|
|
65
|
+
const commActions_1 = require("../commActions");
|
|
66
|
+
function isPlaywrightRunner() { return process.env.TEST_RUNNER === 'playwright'; }
|
|
67
|
+
const __allureAny_form = allure;
|
|
68
|
+
if (typeof __allureAny_form.step !== 'function') {
|
|
69
|
+
__allureAny_form.step = async (_n, f) => await f();
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Web: Fill -field: {param} -value: {param} -options: {param}
|
|
73
|
+
*
|
|
74
|
+
* Fills a form input field (e.g., text box, textarea) with the specified value.
|
|
75
|
+
*
|
|
76
|
+
* @param field - The label, placeholder, id, name, or pattern of the input field (e.g., "Username", "Email", "search").
|
|
77
|
+
* @param value - The text value to fill in the input field (e.g., "JohnDoe", "test@example.com").
|
|
78
|
+
* @param options - Optional JSON string or object:
|
|
79
|
+
* - actionTimeout: [number] Timeout in ms (default: 30000)
|
|
80
|
+
* - pattern: [string] Optional pattern to refine element search. Default: Configured pattern.
|
|
81
|
+
* - screenshot: [boolean] Capture a screenshot after filling the input. Default: false.
|
|
82
|
+
* - screenshotText: [string] Text description for the screenshot. Default: "".
|
|
83
|
+
* - screenshotFullPage: [boolean] Capture a full page screenshot. Default: true.
|
|
84
|
+
* - screenshotField: [boolean] Capture screenshot of the field (input element) only. Overrides fullPage. Default: false.
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* Web: Fill -field: "Username" -value: "JohnDoe" -options: "{screenshot: true, screenshotText: 'After filling Username', screenshotField: true}"
|
|
88
|
+
*/
|
|
89
|
+
async function fill(page, field, value, options) {
|
|
90
|
+
let resolvedvalue = global_1.vars.replaceVariables(value.toString());
|
|
91
|
+
const options_json = typeof options === "string" ? (0, vars_1.parseLooseJson)(options) : options || {};
|
|
92
|
+
if (!page)
|
|
93
|
+
throw new Error("Page not initialized");
|
|
94
|
+
const { iframe = "", actionTimeout = Number(global_1.vars.getConfigValue("testExecution.actionTimeout")), pattern, screenshot = false, screenshotText = "", screenshotFullPage = true, screenshotField = false, smartIQ_refreshLoc = "", } = options_json || {};
|
|
95
|
+
if (isPlaywrightRunner()) {
|
|
96
|
+
await __allureAny_form.step(`Web: Fill -field: ${field} -value: ${value} -options: ${JSON.stringify(options_json)}`, async () => {
|
|
97
|
+
await doFill();
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
await doFill();
|
|
102
|
+
}
|
|
103
|
+
async function doFill() {
|
|
104
|
+
const target = typeof field === "string"
|
|
105
|
+
? await (0, webLocFixture_1.webLocResolver)("input", field, page, pattern, smartIQ_refreshLoc)
|
|
106
|
+
: field;
|
|
107
|
+
if (iframe) {
|
|
108
|
+
await (0, waitActions_1.waitForEnabled)(page.frameLocator(iframe).locator(target), actionTimeout);
|
|
109
|
+
await page
|
|
110
|
+
.frameLocator(iframe)
|
|
111
|
+
.locator(target)
|
|
112
|
+
.fill(resolvedvalue, { timeout: actionTimeout });
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
await (0, waitActions_1.waitForEnabled)(target, actionTimeout);
|
|
116
|
+
await target.fill(resolvedvalue, { timeout: actionTimeout });
|
|
117
|
+
}
|
|
118
|
+
const isFieldScreenshot = screenshotField === true;
|
|
119
|
+
await (0, screenshotActions_1.processScreenshot)(page, screenshot, screenshotText, !isFieldScreenshot, isFieldScreenshot ? target : undefined);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
// Friendly aliases
|
|
123
|
+
exports.input = fill;
|
|
124
|
+
exports.type = fill;
|
|
125
|
+
exports.set = fill;
|
|
126
|
+
exports.enter = fill;
|
|
127
|
+
/**
|
|
128
|
+
* Web: Append -field: {param} -value: {param} -options: {param}
|
|
129
|
+
*
|
|
130
|
+
* Appends text to an input or textarea without clearing existing content.
|
|
131
|
+
*
|
|
132
|
+
* @param page - Playwright Page instance
|
|
133
|
+
* @param field - The label, placeholder, id, name, or pattern of the input field
|
|
134
|
+
* @param value - The text value to append
|
|
135
|
+
* @param options - Optional JSON string or object:
|
|
136
|
+
* - actionTimeout: [number] Timeout in ms (default: 30000)
|
|
137
|
+
* - pattern: [string] Optional pattern to refine element search
|
|
138
|
+
* - screenshot: [boolean] Capture a screenshot after appending (default: false)
|
|
139
|
+
* - screenshotText: [string] Text description for the screenshot
|
|
140
|
+
* - screenshotFullPage: [boolean] Capture a full page screenshot (default: true)
|
|
141
|
+
* - screenshotField: [boolean] Capture screenshot of the field (input element) only (default: false)
|
|
142
|
+
*/
|
|
143
|
+
async function append(page, field, value, options) {
|
|
144
|
+
let resolvedvalue = global_1.vars.replaceVariables(value.toString());
|
|
145
|
+
const options_json = typeof options === "string" ? (0, vars_1.parseLooseJson)(options) : options || {};
|
|
146
|
+
if (!page)
|
|
147
|
+
throw new Error("Page not initialized");
|
|
148
|
+
const { iframe = "", actionTimeout = Number(global_1.vars.getConfigValue("testExecution.actionTimeout")), pattern, screenshot = false, screenshotText = "", screenshotFullPage = true, screenshotField = false, smartIQ_refreshLoc = "", } = options_json || {};
|
|
149
|
+
if (isPlaywrightRunner()) {
|
|
150
|
+
await __allureAny_form.step(`Web: Append -field: ${field} -value: ${value} -options: ${JSON.stringify(options_json)}`, async () => {
|
|
151
|
+
await doAppend();
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
await doAppend();
|
|
156
|
+
}
|
|
157
|
+
async function doAppend() {
|
|
158
|
+
const target = typeof field === "string"
|
|
159
|
+
? await (0, webLocFixture_1.webLocResolver)("input", field, page, pattern, smartIQ_refreshLoc)
|
|
160
|
+
: field;
|
|
161
|
+
if (iframe) {
|
|
162
|
+
await (0, waitActions_1.waitForEnabled)(page.frameLocator(iframe).locator(target), actionTimeout);
|
|
163
|
+
await page
|
|
164
|
+
.frameLocator(iframe)
|
|
165
|
+
.locator(target)
|
|
166
|
+
.type(resolvedvalue, { timeout: actionTimeout });
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
await (0, waitActions_1.waitForEnabled)(target, actionTimeout);
|
|
170
|
+
await target.type(resolvedvalue, { timeout: actionTimeout });
|
|
171
|
+
}
|
|
172
|
+
const isFieldScreenshot = screenshotField === true;
|
|
173
|
+
await (0, screenshotActions_1.processScreenshot)(page, screenshot, screenshotText, !isFieldScreenshot, isFieldScreenshot ? target : undefined);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Web: Select Option -field: {param} -value: {param} -options: {param}
|
|
178
|
+
*
|
|
179
|
+
* Selects an option in a dropdown by label or value.
|
|
180
|
+
* Delegates to core `selectDropdown`.
|
|
181
|
+
*
|
|
182
|
+
* @param page Playwright Page instance
|
|
183
|
+
* @param field Dropdown locator or string selector
|
|
184
|
+
* @param value Option label or value
|
|
185
|
+
* @param options Optional JSON string or object ({ actionTimeout, pattern })
|
|
186
|
+
*/
|
|
187
|
+
/**
|
|
188
|
+
* Web: Select Dropdown -field: {param} -value: {param} -options: {param}
|
|
189
|
+
*
|
|
190
|
+
* Selects a dropdown option by visible text or value.
|
|
191
|
+
* Works with both native <select> elements and custom dropdowns.
|
|
192
|
+
*
|
|
193
|
+
* @param page - Playwright Page instance
|
|
194
|
+
* @param field - Locator or label of the dropdown
|
|
195
|
+
* @param value - Value or label of the option to select
|
|
196
|
+
* @param options - Optional string or object containing:
|
|
197
|
+
* - actionTimeout: custom timeout
|
|
198
|
+
* - pattern: extra pattern string for locator resolution
|
|
199
|
+
* - screenshot: boolean (default false)
|
|
200
|
+
* - screenshotText: text for screenshot description
|
|
201
|
+
* - screenshotFullPage: boolean (default true)
|
|
202
|
+
* - smartIQ_refreshLoc: optional override for locator refresh key
|
|
203
|
+
*/
|
|
204
|
+
async function selectOption(page, field, value, options) {
|
|
205
|
+
const resolvedValue = value !== undefined && value !== null ? global_1.vars.replaceVariables(value.toString()) : "";
|
|
206
|
+
const options_json = typeof options === "string" ? global_1.vars.parseLooseJson(options) : options || {};
|
|
207
|
+
const { actionTimeout = Number(global_1.vars.getConfigValue("testExecution.actionTimeout")) || 30000, pattern, screenshot = false, screenshotText = "", screenshotFullPage = true, smartIQ_refreshLoc = "" } = options_json;
|
|
208
|
+
const stepName = `Web: Select Dropdown -field: ${String(field)} -value: ${resolvedValue} -options: ${JSON.stringify(options_json)}`;
|
|
209
|
+
async function run() {
|
|
210
|
+
if (!page)
|
|
211
|
+
throw new Error("Page not initialized");
|
|
212
|
+
const target = typeof field === "string" ? await (0, webLocFixture_1.webLocResolver)("dropdown", field, page, pattern, actionTimeout, smartIQ_refreshLoc) : field;
|
|
213
|
+
const tag = await target.evaluate((el) => el.tagName.toLowerCase());
|
|
214
|
+
try {
|
|
215
|
+
if (tag === "select") {
|
|
216
|
+
await target.selectOption({ label: resolvedValue }).catch(async () => { await target.selectOption({ value: resolvedValue }); });
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
await (0, waitActions_1.waitForEnabled)(target, actionTimeout);
|
|
220
|
+
await target.click();
|
|
221
|
+
const dropdownOptions = page.locator(`role=option >> text="${resolvedValue}"`);
|
|
222
|
+
const visibleOption = dropdownOptions.first();
|
|
223
|
+
if (await visibleOption.isVisible()) {
|
|
224
|
+
await visibleOption.click();
|
|
225
|
+
}
|
|
226
|
+
else {
|
|
227
|
+
await page.locator(`text="${resolvedValue}"`).first().click();
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
catch (e) {
|
|
232
|
+
throw new Error(`❌ Failed to select "${resolvedValue}" from dropdown: ${e}`);
|
|
233
|
+
}
|
|
234
|
+
await (0, screenshotActions_1.processScreenshot)(page, screenshot, screenshotText || `Select: ${resolvedValue}`, screenshotFullPage);
|
|
235
|
+
}
|
|
236
|
+
if (isPlaywrightRunner()) {
|
|
237
|
+
await __allureAny_form.step(stepName, run);
|
|
238
|
+
}
|
|
239
|
+
else {
|
|
240
|
+
await run();
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Web: Upload File -field: {param} -file: {param} -options: {param}
|
|
245
|
+
*
|
|
246
|
+
* Uploads a file to an input element.
|
|
247
|
+
* Delegates to core `uploadFile`.
|
|
248
|
+
*
|
|
249
|
+
* @param page Playwright Page instance
|
|
250
|
+
* @param field File input locator or string selector
|
|
251
|
+
* @param file Local file path
|
|
252
|
+
* @param options Optional JSON string or object ({ actionTimeout })
|
|
253
|
+
*/
|
|
254
|
+
async function uploadFile(page, field, file, options) {
|
|
255
|
+
const projectRoot = process.env['PLAYQ_PROJECT_ROOT'] || process.cwd();
|
|
256
|
+
let filePath = file;
|
|
257
|
+
if (!path_1.default.isAbsolute(filePath)) {
|
|
258
|
+
const basePath = path_1.default.resolve(projectRoot, 'test-data');
|
|
259
|
+
filePath = path_1.default.resolve(basePath, file);
|
|
260
|
+
}
|
|
261
|
+
filePath = path_1.default.normalize(filePath);
|
|
262
|
+
if (!fs_1.default.existsSync(filePath)) {
|
|
263
|
+
throw new Error(`File not found for upload: ${filePath}`);
|
|
264
|
+
}
|
|
265
|
+
const options_json = typeof options === "string" ? global_1.vars.parseLooseJson(options) : options || {};
|
|
266
|
+
const { actionTimeout = Number(global_1.vars.getConfigValue("testExecution.actionTimeout")) || 10000, screenshot = false, screenshotText = "", screenshotFullPage = true, pattern } = options_json || {};
|
|
267
|
+
const stepName = `Web: Upload file at -field: ${String(field)} with filename: ${file} -options: ${JSON.stringify(options_json)}`;
|
|
268
|
+
async function run() {
|
|
269
|
+
if (!page)
|
|
270
|
+
throw new Error("Page not initialized");
|
|
271
|
+
const target = typeof field === "string" ? await (0, webLocFixture_1.webLocResolver)("input", field, page, pattern, actionTimeout) : field;
|
|
272
|
+
await target.waitFor({ state: "visible", timeout: actionTimeout });
|
|
273
|
+
const tag = await target.evaluate((el) => ({ tag: el.tagName.toLowerCase(), type: el.getAttribute('type') || '' }));
|
|
274
|
+
if (tag.tag === 'input' && tag.type.toLowerCase() === 'file') {
|
|
275
|
+
await target.setInputFiles(filePath, { timeout: actionTimeout });
|
|
276
|
+
}
|
|
277
|
+
else {
|
|
278
|
+
const fileChooserPromise = page.waitForEvent('filechooser');
|
|
279
|
+
await target.click();
|
|
280
|
+
const fileChooser = await fileChooserPromise;
|
|
281
|
+
await fileChooser.setFiles(filePath);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
if (isPlaywrightRunner()) {
|
|
285
|
+
await __allureAny_form.step(stepName, run);
|
|
286
|
+
}
|
|
287
|
+
else {
|
|
288
|
+
await run();
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Web: Select Dropdown by Index -field: {param} -index: {param} -options: {param}
|
|
293
|
+
*
|
|
294
|
+
* Selects a dropdown option by its index (zero-based).
|
|
295
|
+
* Works with both native <select> elements and custom dropdowns.
|
|
296
|
+
*
|
|
297
|
+
* @param page - Playwright Page instance
|
|
298
|
+
* @param field - Locator or label of the dropdown
|
|
299
|
+
* @param index - Index of the option to select (zero-based)
|
|
300
|
+
* @param options - Optional string or object containing:
|
|
301
|
+
* - actionTimeout: custom timeout
|
|
302
|
+
* - pattern: extra pattern string for locator resolution
|
|
303
|
+
* - screenshot: boolean (default false)
|
|
304
|
+
* - screenshotText: text for screenshot description
|
|
305
|
+
* - screenshotFullPage: boolean (default true)
|
|
306
|
+
* - smartIQ_refreshLoc: optional override for locator refresh key
|
|
307
|
+
*/
|
|
308
|
+
async function selectOptionByIndex(page, field, index, options) {
|
|
309
|
+
const options_json = typeof options === "string" ? global_1.vars.parseLooseJson(options) : options || {};
|
|
310
|
+
const { actionTimeout = Number(global_1.vars.getConfigValue("testExecution.actionTimeout")) || 30000, pattern, screenshot = false, screenshotText = "", screenshotFullPage = true, smartIQ_refreshLoc = "" } = options_json;
|
|
311
|
+
const stepName = `Web: Select Dropdown by Index -field: ${String(field)} -index: ${index} -options: ${JSON.stringify(options_json)}`;
|
|
312
|
+
async function run() {
|
|
313
|
+
if (!page)
|
|
314
|
+
throw new Error("Page not initialized");
|
|
315
|
+
const target = typeof field === "string" ? await (0, webLocFixture_1.webLocResolver)("dropdown", field, page, pattern, actionTimeout, smartIQ_refreshLoc) : field;
|
|
316
|
+
const tag = await target.evaluate((el) => el.tagName.toLowerCase());
|
|
317
|
+
try {
|
|
318
|
+
if (tag === "select") {
|
|
319
|
+
const optionsCount = await target.locator("option").count();
|
|
320
|
+
if (index < 0 || index >= optionsCount) {
|
|
321
|
+
throw new Error(`❌ Index ${index} is out of bounds for dropdown with ${optionsCount} options`);
|
|
322
|
+
}
|
|
323
|
+
const optionLocator = target.locator("option").nth(index);
|
|
324
|
+
const value = await optionLocator.getAttribute("value");
|
|
325
|
+
await target.selectOption({ value });
|
|
326
|
+
}
|
|
327
|
+
else {
|
|
328
|
+
await target.click();
|
|
329
|
+
const dropdownOptions = page.locator('role=option');
|
|
330
|
+
const optionCount = await dropdownOptions.count();
|
|
331
|
+
if (index < 0 || index >= optionCount) {
|
|
332
|
+
throw new Error(`❌ Index ${index} is out of bounds for custom dropdown with ${optionCount} options`);
|
|
333
|
+
}
|
|
334
|
+
const optionToClick = dropdownOptions.nth(index);
|
|
335
|
+
await optionToClick.click();
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
catch (e) {
|
|
339
|
+
throw new Error(`❌ Failed to select index ${index} from dropdown: ${e}`);
|
|
340
|
+
}
|
|
341
|
+
await (0, screenshotActions_1.processScreenshot)(page, screenshot, screenshotText || `Select dropdown index: ${index}`, screenshotFullPage);
|
|
342
|
+
}
|
|
343
|
+
if (isPlaywrightRunner()) {
|
|
344
|
+
await __allureAny_form.step(stepName, run);
|
|
345
|
+
}
|
|
346
|
+
else {
|
|
347
|
+
await run();
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Web: Select Dropdown -field: {param} -value: {param} -options: {param}
|
|
352
|
+
*
|
|
353
|
+
* Selects a dropdown option by visible text or value.
|
|
354
|
+
* Works with both native <select> elements and custom dropdowns.
|
|
355
|
+
*
|
|
356
|
+
* @param page - Playwright Page instance
|
|
357
|
+
* @param field - Locator or label of the dropdown
|
|
358
|
+
* @param value - Value or label of the option to select
|
|
359
|
+
* @param options - Optional string or object containing:
|
|
360
|
+
* - actionTimeout: custom timeout
|
|
361
|
+
* - pattern: extra pattern string for locator resolution
|
|
362
|
+
* - screenshot: boolean (default false)
|
|
363
|
+
* - screenshotText: text for screenshot description
|
|
364
|
+
* - screenshotFullPage: boolean (default true)
|
|
365
|
+
* - smartIQ_refreshLoc: optional override for locator refresh key
|
|
366
|
+
*/
|
|
367
|
+
async function selectDropdown(page, field, value, options) {
|
|
368
|
+
const resolvedValue = value !== undefined && value !== null
|
|
369
|
+
? global_1.vars.replaceVariables(value.toString())
|
|
370
|
+
: "";
|
|
371
|
+
const options_json = typeof options === "string" ? (0, vars_1.parseLooseJson)(options) : options || {};
|
|
372
|
+
const { actionTimeout, pattern, screenshot = false, screenshotText = "", screenshotFullPage = true, smartIQ_refreshLoc = "", } = options_json;
|
|
373
|
+
if (isPlaywrightRunner()) {
|
|
374
|
+
await __allureAny_form.step(`Web: Select Dropdown -field: ${field} -value: ${resolvedValue} -options: ${JSON.stringify(options_json)}`, async () => {
|
|
375
|
+
await doSelectDropdown();
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
else {
|
|
379
|
+
await doSelectDropdown();
|
|
380
|
+
}
|
|
381
|
+
async function doSelectDropdown() {
|
|
382
|
+
if (!page)
|
|
383
|
+
throw new Error("Page not initialized");
|
|
384
|
+
// Resolve dropdown element
|
|
385
|
+
const target = typeof field === "string"
|
|
386
|
+
? await (0, webLocFixture_1.webLocResolver)("dropdown", field, page, pattern, actionTimeout, smartIQ_refreshLoc)
|
|
387
|
+
: field;
|
|
388
|
+
// Determine tag
|
|
389
|
+
const tag = await target.evaluate((el) => el.tagName.toLowerCase());
|
|
390
|
+
try {
|
|
391
|
+
if (tag === "select") {
|
|
392
|
+
// Native select dropdown
|
|
393
|
+
await target.selectOption({ label: resolvedValue }).catch(async () => {
|
|
394
|
+
await target.selectOption({ value: resolvedValue });
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
else {
|
|
398
|
+
await (0, commActions_1.waitInMilliSeconds)(2000);
|
|
399
|
+
// Custom dropdown: aria-haspopup or role-based
|
|
400
|
+
await target.click();
|
|
401
|
+
const dropdownOptions = page.locator(`role=option >> text="${resolvedValue}"`);
|
|
402
|
+
const visibleOption = dropdownOptions.first();
|
|
403
|
+
if (await visibleOption.isVisible()) {
|
|
404
|
+
await visibleOption.click();
|
|
405
|
+
}
|
|
406
|
+
else {
|
|
407
|
+
// Fallback to plain text match
|
|
408
|
+
await page.locator(`text="${resolvedValue}"`).first().click();
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
catch (e) {
|
|
413
|
+
throw new Error(`❌ Failed to select "${resolvedValue}" from dropdown: ${e}`);
|
|
414
|
+
}
|
|
415
|
+
await (0, screenshotActions_1.processScreenshot)(page, screenshot, screenshotText || `Select: ${resolvedValue}`, screenshotFullPage);
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
/**
|
|
419
|
+
* Alias: Select Dropdown by Index (wrapper to selectOptionByIndex)
|
|
420
|
+
*/
|
|
421
|
+
async function selectDropdownByIndex(page, field, index, options) {
|
|
422
|
+
return selectOptionByIndex(page, field, index, options);
|
|
423
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Page, Frame, Locator } from "playwright";
|
|
2
|
+
/**
|
|
3
|
+
* Web: Switch To Frame -selector: {param} -options: {param}
|
|
4
|
+
*
|
|
5
|
+
* Switches execution context to the specified iframe.
|
|
6
|
+
*
|
|
7
|
+
* @param page - Playwright Page instance
|
|
8
|
+
* @param frameSelector - Frame locator or string selector
|
|
9
|
+
* @param options - Optional JSON string or object ({ pattern, actionTimeout })
|
|
10
|
+
* @returns The resolved `Frame`
|
|
11
|
+
* @throws Error if page is not initialized or frame not found
|
|
12
|
+
*/
|
|
13
|
+
export declare function switchToFrame(page: Page, frameSelector: string | Locator, options?: string | Record<string, any>): Promise<Frame>;
|
|
14
|
+
/**
|
|
15
|
+
* Web: Switch To Main Content -options: {param}
|
|
16
|
+
*
|
|
17
|
+
* Returns to the main document context.
|
|
18
|
+
*
|
|
19
|
+
* @param page - Playwright Page instance
|
|
20
|
+
* @param options - Optional JSON string or object (reserved)
|
|
21
|
+
* @throws Error if page is not initialized
|
|
22
|
+
*/
|
|
23
|
+
export declare function switchToMainContent(page: Page, options?: string | Record<string, any>): Promise<void>;
|
|
@@ -0,0 +1,108 @@
|
|
|
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.switchToFrame = switchToFrame;
|
|
37
|
+
exports.switchToMainContent = switchToMainContent;
|
|
38
|
+
/**
|
|
39
|
+
* @file iframeActions.ts
|
|
40
|
+
*
|
|
41
|
+
* Frame switching helpers for PlayQ web actions.
|
|
42
|
+
* Provides utilities to switch to a specific iframe and back to main content
|
|
43
|
+
* with runner-aware step wrappers and robust error handling.
|
|
44
|
+
*
|
|
45
|
+
* Authors: PlayQ Team
|
|
46
|
+
* Version: v1.0.0
|
|
47
|
+
*/
|
|
48
|
+
const allure = __importStar(require("allure-js-commons"));
|
|
49
|
+
const global_1 = require("../../../global");
|
|
50
|
+
function isPlaywrightRunner() { return process.env.TEST_RUNNER === 'playwright'; }
|
|
51
|
+
const __allureAny_iframe = allure;
|
|
52
|
+
if (typeof __allureAny_iframe.step !== 'function') {
|
|
53
|
+
__allureAny_iframe.step = async (_n, f) => await f();
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Web: Switch To Frame -selector: {param} -options: {param}
|
|
57
|
+
*
|
|
58
|
+
* Switches execution context to the specified iframe.
|
|
59
|
+
*
|
|
60
|
+
* @param page - Playwright Page instance
|
|
61
|
+
* @param frameSelector - Frame locator or string selector
|
|
62
|
+
* @param options - Optional JSON string or object ({ pattern, actionTimeout })
|
|
63
|
+
* @returns The resolved `Frame`
|
|
64
|
+
* @throws Error if page is not initialized or frame not found
|
|
65
|
+
*/
|
|
66
|
+
async function switchToFrame(page, frameSelector, options) {
|
|
67
|
+
if (!page)
|
|
68
|
+
throw new Error("Page not initialized");
|
|
69
|
+
const options_json = typeof options === 'string' ? global_1.vars.parseLooseJson(options) : options || {};
|
|
70
|
+
const locator = typeof frameSelector === 'string'
|
|
71
|
+
? await (0, global_1.webLocResolver)((options_json === null || options_json === void 0 ? void 0 : options_json.fieldType) || '', frameSelector, 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) || '')
|
|
72
|
+
: frameSelector;
|
|
73
|
+
let frame = null;
|
|
74
|
+
const stepName = `Web: Switch To Frame -selector: ${typeof frameSelector === 'string' ? frameSelector : '<locator>'}`;
|
|
75
|
+
if (isPlaywrightRunner()) {
|
|
76
|
+
await __allureAny_iframe.step(stepName, async () => {
|
|
77
|
+
frame = await locator.elementHandle().then(h => (h === null || h === void 0 ? void 0 : h.contentFrame()) || null);
|
|
78
|
+
if (!frame)
|
|
79
|
+
throw new Error('Frame not found');
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
frame = await locator.elementHandle().then(h => (h === null || h === void 0 ? void 0 : h.contentFrame()) || null);
|
|
84
|
+
if (!frame)
|
|
85
|
+
throw new Error('Frame not found');
|
|
86
|
+
}
|
|
87
|
+
return frame;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Web: Switch To Main Content -options: {param}
|
|
91
|
+
*
|
|
92
|
+
* Returns to the main document context.
|
|
93
|
+
*
|
|
94
|
+
* @param page - Playwright Page instance
|
|
95
|
+
* @param options - Optional JSON string or object (reserved)
|
|
96
|
+
* @throws Error if page is not initialized
|
|
97
|
+
*/
|
|
98
|
+
async function switchToMainContent(page, options) {
|
|
99
|
+
if (!page)
|
|
100
|
+
throw new Error("Page not initialized");
|
|
101
|
+
const stepName = `Web: Switch To Main Content`;
|
|
102
|
+
if (isPlaywrightRunner()) {
|
|
103
|
+
await __allureAny_iframe.step(stepName, async () => { });
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
/* No-op */
|
|
107
|
+
}
|
|
108
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Page } from "playwright";
|
|
2
|
+
/**
|
|
3
|
+
* Web: Execute Script -options: {param}
|
|
4
|
+
*
|
|
5
|
+
* Executes a function in the browser context via `page.evaluate`.
|
|
6
|
+
*
|
|
7
|
+
* @param page - Playwright Page instance
|
|
8
|
+
* @param fn - Function to execute in the page context
|
|
9
|
+
* @param args - Optional array passed as a single argument to the function
|
|
10
|
+
* @returns The function result
|
|
11
|
+
* @throws Error if page is not initialized or `fn` is not a function
|
|
12
|
+
*/
|
|
13
|
+
export declare function execute<T>(page: Page, fn: (...args: any[]) => any, args?: any[]): Promise<any>;
|
|
14
|
+
export declare const executeScript: typeof execute;
|
|
@@ -0,0 +1,77 @@
|
|
|
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.executeScript = void 0;
|
|
37
|
+
exports.execute = execute;
|
|
38
|
+
/**
|
|
39
|
+
* @file javascriptActions.ts
|
|
40
|
+
*
|
|
41
|
+
* Execute custom JavaScript in the page context with PlayQ.
|
|
42
|
+
* Wraps page.evaluate with reporting-friendly step wrappers.
|
|
43
|
+
*
|
|
44
|
+
* Authors: PlayQ Team
|
|
45
|
+
* Version: v1.0.0
|
|
46
|
+
*/
|
|
47
|
+
const allure = __importStar(require("allure-js-commons"));
|
|
48
|
+
function isPlaywrightRunner() { return process.env.TEST_RUNNER === 'playwright'; }
|
|
49
|
+
const __allureAny_js = allure;
|
|
50
|
+
if (typeof __allureAny_js.step !== 'function') {
|
|
51
|
+
__allureAny_js.step = async (_n, f) => await f();
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Web: Execute Script -options: {param}
|
|
55
|
+
*
|
|
56
|
+
* Executes a function in the browser context via `page.evaluate`.
|
|
57
|
+
*
|
|
58
|
+
* @param page - Playwright Page instance
|
|
59
|
+
* @param fn - Function to execute in the page context
|
|
60
|
+
* @param args - Optional array passed as a single argument to the function
|
|
61
|
+
* @returns The function result
|
|
62
|
+
* @throws Error if page is not initialized or `fn` is not a function
|
|
63
|
+
*/
|
|
64
|
+
async function execute(page, fn, args) {
|
|
65
|
+
if (!page)
|
|
66
|
+
throw new Error("Page not initialized");
|
|
67
|
+
if (typeof fn !== 'function')
|
|
68
|
+
throw new Error("javascript.execute: 'fn' must be a function");
|
|
69
|
+
const stepName = `Web: Execute Script`;
|
|
70
|
+
const run = async () => page.evaluate(fn, ...(args ? [args] : []));
|
|
71
|
+
if (isPlaywrightRunner()) {
|
|
72
|
+
return __allureAny_js.step(stepName, run);
|
|
73
|
+
}
|
|
74
|
+
return run();
|
|
75
|
+
}
|
|
76
|
+
// Friendly aliases
|
|
77
|
+
exports.executeScript = execute;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Page } from "@playwright/test";
|
|
2
|
+
/**
|
|
3
|
+
* Web: Press Key -key: {param} -options: {param}
|
|
4
|
+
*
|
|
5
|
+
* Presses a keyboard key on the page or a specific element.
|
|
6
|
+
*
|
|
7
|
+
* @param page - Playwright Page instance
|
|
8
|
+
* @param key - The key to press (e.g., "Enter", "Tab", "ArrowDown", "a", etc.)
|
|
9
|
+
* @param options - Optional string or object:
|
|
10
|
+
* - screenshot: [boolean] Capture screenshot after pressing the key. Default: false.
|
|
11
|
+
* - screenshotText: [string] Description for the screenshot. Default: "".
|
|
12
|
+
* - screenshotFullPage: [boolean] Full page screenshot. Default: true.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* await pressKey(page, 'Enter', { field: 'Username', screenshot: true });
|
|
16
|
+
*/
|
|
17
|
+
export declare function pressKey(page: Page, key: string, options?: string | Record<string, any>): Promise<void>;
|
|
18
|
+
/**
|
|
19
|
+
* Web: Press Enter -options: {param}
|
|
20
|
+
*
|
|
21
|
+
* Convenience wrapper to press the Enter key.
|
|
22
|
+
*
|
|
23
|
+
* @param page Playwright Page instance
|
|
24
|
+
* @param options Optional JSON string or object ({ delay })
|
|
25
|
+
*/
|
|
26
|
+
export declare function pressEnter(page: Page, options?: string | Record<string, any>): Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* Web: Press Tab -options: {param}
|
|
29
|
+
*
|
|
30
|
+
* Convenience wrapper to press the Tab key.
|
|
31
|
+
*
|
|
32
|
+
* @param page Playwright Page instance
|
|
33
|
+
* @param options Optional JSON string or object ({ delay })
|
|
34
|
+
*/
|
|
35
|
+
export declare function pressTab(page: Page, options?: string | Record<string, any>): Promise<void>;
|