@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,104 @@
|
|
|
1
|
+
import { Page } from "@playwright/test";
|
|
2
|
+
/**
|
|
3
|
+
* [ACTION] Open a browser page (Playwright/Cucumber hybrid support).
|
|
4
|
+
*
|
|
5
|
+
* Opens the given URL in a new browser page or reuses the existing page based on the runner context.
|
|
6
|
+
* Supports automatic screenshot and log attachments.
|
|
7
|
+
*
|
|
8
|
+
* @param pageOverride - Optional Playwright Page object (used in Playwright tests). Not required in Cucumber.
|
|
9
|
+
* @param url - The URL to open (e.g., "https://example.com").
|
|
10
|
+
* @param options - JSON string or object for additional behaviors:
|
|
11
|
+
* - screenshot [boolean]: Capture screenshot after navigation. Default: false.
|
|
12
|
+
* - screenshotText [string]: Description for screenshot attachment. Default: "".
|
|
13
|
+
* - screenshotFullPage [boolean]: Full page screenshot or viewport only. Default: true.
|
|
14
|
+
*
|
|
15
|
+
* @returns void
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* // Playwright Test
|
|
19
|
+
* test('Open Google', async ({ page }) => {
|
|
20
|
+
* await openBrowser('https://google.com', '{screenshot: true, screenshotText: "Homepage"}', page);
|
|
21
|
+
* });
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* // Cucumber Step
|
|
25
|
+
* Given("Web: Open Browser -url: {param} -options: {param}", openBrowser);
|
|
26
|
+
*
|
|
27
|
+
* @throws Error if page is not initialized or navigation fails.
|
|
28
|
+
*/
|
|
29
|
+
export declare function openBrowser(page: Page, url: string, options?: string | Record<string, any>): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* Web: Refresh Page -options: {param}
|
|
32
|
+
*
|
|
33
|
+
* Reloads the current page.
|
|
34
|
+
*
|
|
35
|
+
* @param page Playwright Page instance
|
|
36
|
+
* @param options Optional JSON string or object (reserved for consistency)
|
|
37
|
+
*/
|
|
38
|
+
export declare function refreshPage(page: Page, options?: string | Record<string, any>): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* Web: Switch Tab -index: {param} -options: {param}
|
|
41
|
+
*
|
|
42
|
+
* Brings the specified tab to the front by index.
|
|
43
|
+
*
|
|
44
|
+
* @param page Playwright Page instance
|
|
45
|
+
* @param index Zero-based tab index (default: 0)
|
|
46
|
+
* @param options Optional JSON string or object (reserved for consistency)
|
|
47
|
+
*/
|
|
48
|
+
export declare function switchTab(page: Page, index?: number, options?: string | Record<string, any>): Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* Web: Close Tab -options: {param}
|
|
51
|
+
*
|
|
52
|
+
* Closes the current tab.
|
|
53
|
+
*
|
|
54
|
+
* @param page Playwright Page instance
|
|
55
|
+
* @param options Optional JSON string or object (reserved for consistency)
|
|
56
|
+
*/
|
|
57
|
+
export declare function closeTab(page: Page, options?: string | Record<string, any>): Promise<void>;
|
|
58
|
+
/**
|
|
59
|
+
* Web: Open New Tab -url: {param} -options: {param}
|
|
60
|
+
*
|
|
61
|
+
* Opens a new tab within the current browser context and optionally navigates to a URL.
|
|
62
|
+
* Returns the created Page instance so tests can interact with it without direct Playwright APIs.
|
|
63
|
+
*
|
|
64
|
+
* @param page Playwright Page instance (used to derive the context)
|
|
65
|
+
* @param url Optional URL to navigate the new tab to
|
|
66
|
+
* @param options Optional JSON string or object:
|
|
67
|
+
* - screenshot: [boolean] Capture a screenshot after opening/navigating. Default: false.
|
|
68
|
+
* - screenshotText: [string] Description for the screenshot attachment. Default: "".
|
|
69
|
+
* - screenshotFullPage: [boolean] Capture full page screenshot. Default: true.
|
|
70
|
+
*
|
|
71
|
+
* @returns The newly opened Playwright Page
|
|
72
|
+
*/
|
|
73
|
+
export declare function openNewTab(page: Page, url?: string, options?: string | Record<string, any>): Promise<any>;
|
|
74
|
+
/**
|
|
75
|
+
* Web: Navigate by Path -relativePath: {param} -options: {param}
|
|
76
|
+
*
|
|
77
|
+
* Appends a relative path to the current page's URL and navigates to it.
|
|
78
|
+
*
|
|
79
|
+
* @param relativePath - The path to append (e.g., "/settings", "profile/edit")
|
|
80
|
+
* @param options - (optional) JSON string or object:
|
|
81
|
+
* - screenshot: [boolean] Capture a screenshot after navigation. Default: false.
|
|
82
|
+
* - screenshotText: [string] Text description for the screenshot. Default: "".
|
|
83
|
+
* - screenshotFullPage: [boolean] Capture full page screenshot. Default: true.
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* Web: Navigate by Path -relativePath: "/profile/edit" -options: "{screenshot: true, screenshotText: 'Profile Page'}"
|
|
87
|
+
*/
|
|
88
|
+
export declare function navigateByPath(page: Page, relativePath: string, options?: string | Record<string, any>): Promise<void>;
|
|
89
|
+
/**
|
|
90
|
+
* Web: Reload Page -options: {param}
|
|
91
|
+
*
|
|
92
|
+
* Reloads the current page and optionally takes a screenshot.
|
|
93
|
+
*
|
|
94
|
+
* @param page - Playwright Page instance
|
|
95
|
+
* @param options - Optional string or object:
|
|
96
|
+
* - actionTimeout: [number] Timeout in ms (default: 30000)
|
|
97
|
+
* - screenshot: [boolean] Capture screenshot after reload (default: false)
|
|
98
|
+
* - screenshotText: [string] Description for screenshot
|
|
99
|
+
* - screenshotFullPage: [boolean] Full page screenshot (default: true)
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* await reloadPage(page, { screenshot: true, screenshotText: "After reload" });
|
|
103
|
+
*/
|
|
104
|
+
export declare function reloadPage(page: Page, options?: string | Record<string, any>): Promise<void>;
|
|
@@ -0,0 +1,288 @@
|
|
|
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.openBrowser = openBrowser;
|
|
37
|
+
exports.refreshPage = refreshPage;
|
|
38
|
+
exports.switchTab = switchTab;
|
|
39
|
+
exports.closeTab = closeTab;
|
|
40
|
+
exports.openNewTab = openNewTab;
|
|
41
|
+
exports.navigateByPath = navigateByPath;
|
|
42
|
+
exports.reloadPage = reloadPage;
|
|
43
|
+
/**
|
|
44
|
+
* @file webNavigation.ts
|
|
45
|
+
*
|
|
46
|
+
* Navigation helpers for PlayQ web actions.
|
|
47
|
+
* Provides open/refresh/switch/close tab and path navigation utilities
|
|
48
|
+
* with runner-aware Allure step wrappers and screenshot options.
|
|
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 vars_1 = require("../../bundle/vars");
|
|
57
|
+
const commActions_1 = require("../commActions");
|
|
58
|
+
function isPlaywrightRunner() { return process.env.TEST_RUNNER === 'playwright'; }
|
|
59
|
+
const __allureAny_nav = allure;
|
|
60
|
+
if (typeof __allureAny_nav.step !== 'function') {
|
|
61
|
+
__allureAny_nav.step = async (_name, fn) => await fn();
|
|
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
|
+
* [ACTION] Open a browser page (Playwright/Cucumber hybrid support).
|
|
70
|
+
*
|
|
71
|
+
* Opens the given URL in a new browser page or reuses the existing page based on the runner context.
|
|
72
|
+
* Supports automatic screenshot and log attachments.
|
|
73
|
+
*
|
|
74
|
+
* @param pageOverride - Optional Playwright Page object (used in Playwright tests). Not required in Cucumber.
|
|
75
|
+
* @param url - The URL to open (e.g., "https://example.com").
|
|
76
|
+
* @param options - JSON string or object for additional behaviors:
|
|
77
|
+
* - screenshot [boolean]: Capture screenshot after navigation. Default: false.
|
|
78
|
+
* - screenshotText [string]: Description for screenshot attachment. Default: "".
|
|
79
|
+
* - screenshotFullPage [boolean]: Full page screenshot or viewport only. Default: true.
|
|
80
|
+
*
|
|
81
|
+
* @returns void
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* // Playwright Test
|
|
85
|
+
* test('Open Google', async ({ page }) => {
|
|
86
|
+
* await openBrowser('https://google.com', '{screenshot: true, screenshotText: "Homepage"}', page);
|
|
87
|
+
* });
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* // Cucumber Step
|
|
91
|
+
* Given("Web: Open Browser -url: {param} -options: {param}", openBrowser);
|
|
92
|
+
*
|
|
93
|
+
* @throws Error if page is not initialized or navigation fails.
|
|
94
|
+
*/
|
|
95
|
+
async function openBrowser(page, url, options) {
|
|
96
|
+
let resolvedUrl = global_1.vars.replaceVariables(url);
|
|
97
|
+
const options_json = typeof options === "string" ? (0, vars_1.parseLooseJson)(options) : options || {};
|
|
98
|
+
const { screenshot = false, screenshotText = "", screenshotFullPage = true, } = options_json !== null && options_json !== void 0 ? options_json : {};
|
|
99
|
+
if (isPlaywrightRunner()) {
|
|
100
|
+
await __allureAny_web.step(`Web: Open browser -url: ${resolvedUrl} -options: ${JSON.stringify(options_json)}`, async () => {
|
|
101
|
+
await doOpenBrowser();
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
await doOpenBrowser();
|
|
106
|
+
}
|
|
107
|
+
async function doOpenBrowser() {
|
|
108
|
+
if (!page)
|
|
109
|
+
throw new Error("Page not initialised");
|
|
110
|
+
await page.goto(resolvedUrl, { waitUntil: "domcontentloaded" });
|
|
111
|
+
await (0, screenshotActions_1.processScreenshot)(page, screenshot, screenshotText, screenshotFullPage);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Web: Refresh Page -options: {param}
|
|
116
|
+
*
|
|
117
|
+
* Reloads the current page.
|
|
118
|
+
*
|
|
119
|
+
* @param page Playwright Page instance
|
|
120
|
+
* @param options Optional JSON string or object (reserved for consistency)
|
|
121
|
+
*/
|
|
122
|
+
async function refreshPage(page, options) {
|
|
123
|
+
const options_json = typeof options === "string" ? global_1.vars.parseLooseJson(options) : options || {};
|
|
124
|
+
const stepName = `Web: Refresh Page -options: ${JSON.stringify(options_json)}`;
|
|
125
|
+
if (isPlaywrightRunner()) {
|
|
126
|
+
await __allureAny_nav.step(stepName, async () => { await page.reload(); });
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
await page.reload();
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Web: Switch Tab -index: {param} -options: {param}
|
|
134
|
+
*
|
|
135
|
+
* Brings the specified tab to the front by index.
|
|
136
|
+
*
|
|
137
|
+
* @param page Playwright Page instance
|
|
138
|
+
* @param index Zero-based tab index (default: 0)
|
|
139
|
+
* @param options Optional JSON string or object (reserved for consistency)
|
|
140
|
+
*/
|
|
141
|
+
async function switchTab(page, index = 0, options) {
|
|
142
|
+
const options_json = typeof options === "string" ? global_1.vars.parseLooseJson(options) : options || {};
|
|
143
|
+
const ctx = page.context();
|
|
144
|
+
const stepName = `Web: Switch Tab -index: ${index} -options: ${JSON.stringify(options_json)}`;
|
|
145
|
+
if (isPlaywrightRunner()) {
|
|
146
|
+
await __allureAny_nav.step(stepName, async () => {
|
|
147
|
+
const target = ctx.pages()[index];
|
|
148
|
+
if (!target)
|
|
149
|
+
throw new Error(`No tab at index ${index}`);
|
|
150
|
+
await target.bringToFront();
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
const target = ctx.pages()[index];
|
|
155
|
+
if (!target)
|
|
156
|
+
throw new Error(`No tab at index ${index}`);
|
|
157
|
+
await target.bringToFront();
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Web: Close Tab -options: {param}
|
|
162
|
+
*
|
|
163
|
+
* Closes the current tab.
|
|
164
|
+
*
|
|
165
|
+
* @param page Playwright Page instance
|
|
166
|
+
* @param options Optional JSON string or object (reserved for consistency)
|
|
167
|
+
*/
|
|
168
|
+
async function closeTab(page, options) {
|
|
169
|
+
const options_json = typeof options === "string" ? global_1.vars.parseLooseJson(options) : options || {};
|
|
170
|
+
const stepName = `Web: Close Tab -options: ${JSON.stringify(options_json)}`;
|
|
171
|
+
if (isPlaywrightRunner()) {
|
|
172
|
+
await __allureAny_nav.step(stepName, async () => { await page.close(); });
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
await page.close();
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Web: Open New Tab -url: {param} -options: {param}
|
|
180
|
+
*
|
|
181
|
+
* Opens a new tab within the current browser context and optionally navigates to a URL.
|
|
182
|
+
* Returns the created Page instance so tests can interact with it without direct Playwright APIs.
|
|
183
|
+
*
|
|
184
|
+
* @param page Playwright Page instance (used to derive the context)
|
|
185
|
+
* @param url Optional URL to navigate the new tab to
|
|
186
|
+
* @param options Optional JSON string or object:
|
|
187
|
+
* - screenshot: [boolean] Capture a screenshot after opening/navigating. Default: false.
|
|
188
|
+
* - screenshotText: [string] Description for the screenshot attachment. Default: "".
|
|
189
|
+
* - screenshotFullPage: [boolean] Capture full page screenshot. Default: true.
|
|
190
|
+
*
|
|
191
|
+
* @returns The newly opened Playwright Page
|
|
192
|
+
*/
|
|
193
|
+
async function openNewTab(page, url, options) {
|
|
194
|
+
const options_json = typeof options === "string" ? global_1.vars.parseLooseJson(options) : options || {};
|
|
195
|
+
const { screenshot = false, screenshotText = "", screenshotFullPage = true } = options_json !== null && options_json !== void 0 ? options_json : {};
|
|
196
|
+
const stepName = `Web: Open New Tab -url: ${url !== null && url !== void 0 ? url : ''} -options: ${JSON.stringify(options_json)}`;
|
|
197
|
+
async function run() {
|
|
198
|
+
if (!page)
|
|
199
|
+
throw new Error("Page not initialised");
|
|
200
|
+
const ctx = page.context();
|
|
201
|
+
const newPage = await ctx.newPage();
|
|
202
|
+
if (url && typeof url === 'string' && url.length > 0) {
|
|
203
|
+
const targetUrl = global_1.vars.replaceVariables(url);
|
|
204
|
+
await newPage.goto(targetUrl, { waitUntil: 'domcontentloaded' });
|
|
205
|
+
await newPage.waitForLoadState('networkidle');
|
|
206
|
+
}
|
|
207
|
+
await (0, screenshotActions_1.processScreenshot)(newPage, screenshot, screenshotText, screenshotFullPage);
|
|
208
|
+
return newPage;
|
|
209
|
+
}
|
|
210
|
+
if (isPlaywrightRunner()) {
|
|
211
|
+
return await __allureAny_nav.step(stepName, run);
|
|
212
|
+
}
|
|
213
|
+
else {
|
|
214
|
+
return await run();
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Web: Navigate by Path -relativePath: {param} -options: {param}
|
|
219
|
+
*
|
|
220
|
+
* Appends a relative path to the current page's URL and navigates to it.
|
|
221
|
+
*
|
|
222
|
+
* @param relativePath - The path to append (e.g., "/settings", "profile/edit")
|
|
223
|
+
* @param options - (optional) JSON string or object:
|
|
224
|
+
* - screenshot: [boolean] Capture a screenshot after navigation. Default: false.
|
|
225
|
+
* - screenshotText: [string] Text description for the screenshot. Default: "".
|
|
226
|
+
* - screenshotFullPage: [boolean] Capture full page screenshot. Default: true.
|
|
227
|
+
*
|
|
228
|
+
* @example
|
|
229
|
+
* Web: Navigate by Path -relativePath: "/profile/edit" -options: "{screenshot: true, screenshotText: 'Profile Page'}"
|
|
230
|
+
*/
|
|
231
|
+
async function navigateByPath(page, relativePath, options) {
|
|
232
|
+
let resolvedRelativePath = global_1.vars.getValue(relativePath);
|
|
233
|
+
const options_json = typeof options === "string" ? (0, vars_1.parseLooseJson)(options) : options || {};
|
|
234
|
+
const { screenshot = false, screenshotText = "", screenshotFullPage = true, } = options_json !== null && options_json !== void 0 ? options_json : {};
|
|
235
|
+
if (isPlaywrightRunner()) {
|
|
236
|
+
await __allureAny_web.step(`Web: Navigate by Path -relativePath: ${relativePath} -options: ${JSON.stringify(options_json)}`, async () => {
|
|
237
|
+
await doNavigateByPath();
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
await doNavigateByPath();
|
|
242
|
+
}
|
|
243
|
+
async function doNavigateByPath() {
|
|
244
|
+
if (!page)
|
|
245
|
+
throw new Error("Page not initialised");
|
|
246
|
+
const currentUrl = page.url();
|
|
247
|
+
const targetUrl = new URL(resolvedRelativePath, currentUrl).toString();
|
|
248
|
+
console.log(`🌐 Navigating to: ${targetUrl}`);
|
|
249
|
+
await page.goto(targetUrl, { waitUntil: "domcontentloaded" });
|
|
250
|
+
await page.waitForLoadState("networkidle");
|
|
251
|
+
await page.waitForLoadState("load");
|
|
252
|
+
await (0, screenshotActions_1.processScreenshot)(page, screenshot, screenshotText, screenshotFullPage);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Web: Reload Page -options: {param}
|
|
257
|
+
*
|
|
258
|
+
* Reloads the current page and optionally takes a screenshot.
|
|
259
|
+
*
|
|
260
|
+
* @param page - Playwright Page instance
|
|
261
|
+
* @param options - Optional string or object:
|
|
262
|
+
* - actionTimeout: [number] Timeout in ms (default: 30000)
|
|
263
|
+
* - screenshot: [boolean] Capture screenshot after reload (default: false)
|
|
264
|
+
* - screenshotText: [string] Description for screenshot
|
|
265
|
+
* - screenshotFullPage: [boolean] Full page screenshot (default: true)
|
|
266
|
+
*
|
|
267
|
+
* @example
|
|
268
|
+
* await reloadPage(page, { screenshot: true, screenshotText: "After reload" });
|
|
269
|
+
*/
|
|
270
|
+
async function reloadPage(page, options) {
|
|
271
|
+
const options_json = typeof options === "string" ? (0, vars_1.parseLooseJson)(options) : options || {};
|
|
272
|
+
const { actionTimeout = Number(global_1.vars.getConfigValue("testExecution.actionTimeout")) || 30000, screenshot = false, screenshotText = "", screenshotFullPage = true, } = options_json;
|
|
273
|
+
if (!page)
|
|
274
|
+
throw new Error("Page not initialized");
|
|
275
|
+
if (isPlaywrightRunner()) {
|
|
276
|
+
await __allureAny_web.step(`Web: Reload Page -options: ${JSON.stringify(options_json)}`, async () => {
|
|
277
|
+
await doReloadPage();
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
else {
|
|
281
|
+
await doReloadPage();
|
|
282
|
+
}
|
|
283
|
+
async function doReloadPage() {
|
|
284
|
+
await page.reload({ timeout: actionTimeout, waitUntil: "domcontentloaded" });
|
|
285
|
+
await (0, commActions_1.attachLog)("✅ Page reloaded.", "text/plain");
|
|
286
|
+
await (0, screenshotActions_1.processScreenshot)(page, screenshot, screenshotText || "Page reloaded", screenshotFullPage);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file webActions.ts
|
|
3
|
+
*
|
|
4
|
+
* Unified web actions bridging Playwright and Cucumber.
|
|
5
|
+
* Provides navigation, interaction, validation, and reporting helpers.
|
|
6
|
+
*
|
|
7
|
+
* Key Features:
|
|
8
|
+
* - Hybrid context: Playwright Runner (page) and Cucumber World (webFixture)
|
|
9
|
+
* - Rich options for screenshots, timeouts, locators, and assertions
|
|
10
|
+
* - Robust error handling, logging, and Allure-compatible step wrappers
|
|
11
|
+
*
|
|
12
|
+
* Authors: Renish Kozhithottathil [Lead Automation Principal, NCS]
|
|
13
|
+
* Version: v1.0.0
|
|
14
|
+
*
|
|
15
|
+
* Note: This file adheres to the PlayQ Enterprise Automation Standards.
|
|
16
|
+
*/
|
|
17
|
+
export * from "./web/alertActions";
|
|
18
|
+
export * from "./web/cookieActions";
|
|
19
|
+
export * from "./web/downloadActions";
|
|
20
|
+
export * from "./web/elementReaderActions";
|
|
21
|
+
export * from "./web/formActions";
|
|
22
|
+
export * from "./web/iframeActions";
|
|
23
|
+
export * from "./web/javascriptActions";
|
|
24
|
+
export * from "./web/keyboardActions";
|
|
25
|
+
export * from "./web/localStorageActions";
|
|
26
|
+
export * from "./web/mouseActions";
|
|
27
|
+
export * from "./web/reportingActions";
|
|
28
|
+
export * from "./web/screenshotActions";
|
|
29
|
+
export * from "./web/testDataActions";
|
|
30
|
+
export * from "./web/validationActions";
|
|
31
|
+
export * from "./web/waitActions";
|
|
32
|
+
export * from "./web/webNavigation";
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @file webActions.ts
|
|
4
|
+
*
|
|
5
|
+
* Unified web actions bridging Playwright and Cucumber.
|
|
6
|
+
* Provides navigation, interaction, validation, and reporting helpers.
|
|
7
|
+
*
|
|
8
|
+
* Key Features:
|
|
9
|
+
* - Hybrid context: Playwright Runner (page) and Cucumber World (webFixture)
|
|
10
|
+
* - Rich options for screenshots, timeouts, locators, and assertions
|
|
11
|
+
* - Robust error handling, logging, and Allure-compatible step wrappers
|
|
12
|
+
*
|
|
13
|
+
* Authors: Renish Kozhithottathil [Lead Automation Principal, NCS]
|
|
14
|
+
* Version: v1.0.0
|
|
15
|
+
*
|
|
16
|
+
* Note: This file adheres to the PlayQ Enterprise Automation Standards.
|
|
17
|
+
*/
|
|
18
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
19
|
+
if (k2 === undefined) k2 = k;
|
|
20
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
21
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
22
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
23
|
+
}
|
|
24
|
+
Object.defineProperty(o, k2, desc);
|
|
25
|
+
}) : (function(o, m, k, k2) {
|
|
26
|
+
if (k2 === undefined) k2 = k;
|
|
27
|
+
o[k2] = m[k];
|
|
28
|
+
}));
|
|
29
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
30
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
31
|
+
};
|
|
32
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
+
__exportStar(require("./web/alertActions"), exports);
|
|
34
|
+
__exportStar(require("./web/cookieActions"), exports);
|
|
35
|
+
__exportStar(require("./web/downloadActions"), exports);
|
|
36
|
+
__exportStar(require("./web/elementReaderActions"), exports);
|
|
37
|
+
__exportStar(require("./web/formActions"), exports);
|
|
38
|
+
__exportStar(require("./web/iframeActions"), exports);
|
|
39
|
+
__exportStar(require("./web/javascriptActions"), exports);
|
|
40
|
+
__exportStar(require("./web/keyboardActions"), exports);
|
|
41
|
+
__exportStar(require("./web/localStorageActions"), exports);
|
|
42
|
+
__exportStar(require("./web/mouseActions"), exports);
|
|
43
|
+
__exportStar(require("./web/reportingActions"), exports);
|
|
44
|
+
__exportStar(require("./web/screenshotActions"), exports);
|
|
45
|
+
__exportStar(require("./web/testDataActions"), exports);
|
|
46
|
+
__exportStar(require("./web/validationActions"), exports);
|
|
47
|
+
__exportStar(require("./web/waitActions"), exports);
|
|
48
|
+
__exportStar(require("./web/webNavigation"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|