@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,505 @@
|
|
|
1
|
+
import { vars, webLocResolver, webFixture, logFixture } from "../../global";
|
|
2
|
+
import { Given, When, Then } from "@cucumber/cucumber";
|
|
3
|
+
import { warn } from "winston";
|
|
4
|
+
import * as webActions from './webActions';
|
|
5
|
+
|
|
6
|
+
// webNavigation.ts
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Web: Click Button -field: {param} -options: TESTIGN COMMENTS
|
|
10
|
+
*/
|
|
11
|
+
Given("Web: Open browser -url: {param} -options: {param}", async function (url, options) {
|
|
12
|
+
let page = webFixture.getCurrentPage();
|
|
13
|
+
await webActions.openBrowser(page, url, options);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
Given("Web: Navigate by path -relativePath: {param} -options: {param}", async function (relativePath, options) {
|
|
17
|
+
let page = webFixture.getCurrentPage();
|
|
18
|
+
await webActions.navigateByPath(page, relativePath, options);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
// mouseActions.ts
|
|
22
|
+
|
|
23
|
+
Given("Web: Click button -field: {param} -options: {param}", async function (field, options) {
|
|
24
|
+
let page = webFixture.getCurrentPage();
|
|
25
|
+
await webActions.clickButton(page, field, options);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
Given("Web: Click link -field: {param} -options: {param}", async function (field, options) {
|
|
29
|
+
let page = webFixture.getCurrentPage();
|
|
30
|
+
await webActions.clickLink(page, field, options);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
Given("Web: Click -field: {param} -options: {param}", async function (field, options) {
|
|
34
|
+
let page = webFixture.getCurrentPage();
|
|
35
|
+
await webActions.click(page, field, options);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
Given("Web: Click radio button -field: {param} -options: {param}", async function (field, options) {
|
|
39
|
+
let page = webFixture.getCurrentPage();
|
|
40
|
+
await webActions.clickRadioButton(page, field, options);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
Given("Web: Click checkbox -field: {param} -options: {param}", async function (field, options) {
|
|
44
|
+
let page = webFixture.getCurrentPage();
|
|
45
|
+
await webActions.clickCheckbox(page, field, options);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
Given("Web: Mouseover on link -field: {param} -options: {param}", async function (field, options) {
|
|
49
|
+
let page = webFixture.getCurrentPage();
|
|
50
|
+
await webActions.mouseoverOnLink(page, field, options);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
Given("Web: Fill input -field: {param} -value: {param} -options: {param}", async function (field, value, options) {
|
|
54
|
+
let page = webFixture.getCurrentPage();
|
|
55
|
+
await webActions.input(page, field, value, options);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
Given("Web: Fill -field: {param} -value: {param} -options: {param}", async function (field, value, options) {
|
|
59
|
+
let page = webFixture.getCurrentPage();
|
|
60
|
+
await webActions.fill(page, field, value, options);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
// keyboardActions.ts
|
|
64
|
+
Given("Web: Type -field: {param} -value: {param} -options: {param}", async function (field, value, options) {
|
|
65
|
+
let page = webFixture.getCurrentPage();
|
|
66
|
+
await webActions.type(page, field, value, options);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
// validationActions.ts
|
|
70
|
+
Given("Web: Verify header -text: {param} -options: {param}", async function (text, options) {
|
|
71
|
+
let page = webFixture.getCurrentPage();
|
|
72
|
+
await webActions.verifyHeaderText(page, text, options);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
Given("Web: Verify page title -text: {param} -options: {param}", async function (text, options) {
|
|
76
|
+
let page = webFixture.getCurrentPage();
|
|
77
|
+
await webActions.verifyPageTitle(page, text, options);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
// waitActions.ts
|
|
81
|
+
Given("Web: Wait for Input -field: {param} -state: {param} (enabled or disabled) -options: {param}", async function (field, state, options) {
|
|
82
|
+
let page = webFixture.getCurrentPage();
|
|
83
|
+
await webActions.waitForInputState(page, field, state, options);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
Given("Web: Wait for Text at Location -field: {param} -text: {param} -options: {param}", async function (field, expectedText, options) {
|
|
87
|
+
let page = webFixture.getCurrentPage();
|
|
88
|
+
await webActions.waitForTextAtLocation(page, field, expectedText, options);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
Given("Web: Click tab -field: {param} -options: {param}", async function (field, options) {
|
|
92
|
+
let page = webFixture.getCurrentPage();
|
|
93
|
+
await webActions.clickTab(page, field, options);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
// formActions.ts
|
|
97
|
+
Given("Web: Select Dropdown -field: {param} -value: {param} -options: {param}", async function (field, value, options) {
|
|
98
|
+
let page = webFixture.getCurrentPage();
|
|
99
|
+
await webActions.selectDropdown(page, field, value, options);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
Given("Web: Verify text on page -text: {param} -options: {param}", async function (text, options) {
|
|
103
|
+
let page = webFixture.getCurrentPage();
|
|
104
|
+
await webActions.verifyTextOnPage(page, text, options);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
Given("Web: Dont See -text: {param} -options: {param}", async function (text, options) {
|
|
108
|
+
let page = webFixture.getCurrentPage();
|
|
109
|
+
// Implement via page content check since action helper is internal
|
|
110
|
+
const opts = typeof options === 'string' ? vars.parseLooseJson(options) : (options || {});
|
|
111
|
+
const content = await page.content();
|
|
112
|
+
const present = content.includes(vars.replaceVariables(text));
|
|
113
|
+
if (present) throw new Error(`Text '${text}' should not be visible`);
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
Given("Web: Verify text at location -field: {param} -value: {param} -options: {param}", async function (field, expectedText, options) {
|
|
117
|
+
let page = webFixture.getCurrentPage();
|
|
118
|
+
await webActions.verifyTextAtLocation(page, field, expectedText, options);
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
Given("Web: Verify input field is present -field: {param} -options: {param}", async function (field, options) {
|
|
122
|
+
let page = webFixture.getCurrentPage();
|
|
123
|
+
await webActions.verifyInputFieldPresent(page, field, options);
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
Given("Web: Verify input field value -field: {param} -value: {param} -options: {param}", async function (field, expectedValue, options) {
|
|
127
|
+
let page = webFixture.getCurrentPage();
|
|
128
|
+
await webActions.verifyInputFieldValue(page, field, expectedValue, options);
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
Given("Web: Verify Tab field Present -field: {param} -options: {param}", async function (field, options) {
|
|
132
|
+
let page = webFixture.getCurrentPage();
|
|
133
|
+
await webActions.verifyTabField(page, field, options);
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
Given("Web: Verify toast text contains -text: {param} -options: {param}", async function (text, options) {
|
|
137
|
+
let page = webFixture.getCurrentPage();
|
|
138
|
+
await webActions.verifyToastTextContains(page, text, options);
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
Given("Web: Wait for URL -url: {param} -options: {param}", async function (url, options) {
|
|
142
|
+
let page = webFixture.getCurrentPage();
|
|
143
|
+
await webActions.waitForUrl(page, url, options);
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
Given("Web: Wait for Page Load -timeout: {int}", async function (timeout) {
|
|
147
|
+
let page = webFixture.getCurrentPage();
|
|
148
|
+
await webActions.waitForPageToLoad(page, timeout);
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
Given("Web: Wait For Enabled -field: {param} -timeout: {int} -options: {param}", async function (field, timeout, options) {
|
|
152
|
+
let page = webFixture.getCurrentPage();
|
|
153
|
+
const opts = typeof options === 'string' ? vars.parseLooseJson(options) : (options || {});
|
|
154
|
+
const locator = await webLocResolver(opts?.fieldType || 'input', field, page, opts?.pattern, opts?.actionTimeout);
|
|
155
|
+
await webActions.waitForEnabled(locator as any, timeout);
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
Given("Web: Press Key -key: {param} -options: {param}", async function (key, options) {
|
|
159
|
+
let page = webFixture.getCurrentPage();
|
|
160
|
+
await webActions.pressKey(page, key, options);
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
Given("Web: Wait for displayed -field: {param} -options: {param}", async function (field, options) {
|
|
164
|
+
let page = webFixture.getCurrentPage();
|
|
165
|
+
await webActions.waitForDisplayed(page, field, options);
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
Given("Web: Wait for disappear -field: {param} -options: {param}", async function (field, options) {
|
|
169
|
+
let page = webFixture.getCurrentPage();
|
|
170
|
+
await webActions.waitForDisappear(page, field, options);
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
Given("Web: Wait for Header -header: {param} -text: {param} -options: {param}", async function (header, headerText, options) {
|
|
174
|
+
let page = webFixture.getCurrentPage();
|
|
175
|
+
await webActions.waitForHeader(page, header, headerText, options);
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
Given("Web: Select Dropdown by Index -field: {param} -index: {int} -options: {param}", async function (field, index, options) {
|
|
179
|
+
let page = webFixture.getCurrentPage();
|
|
180
|
+
await webActions.selectDropdownByIndex(page, field, index, options);
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
Given("Web: Verify locked input field value -field: {param} -value: {param} -options: {param}", async function (field, expectedValue, options) {
|
|
184
|
+
let page = webFixture.getCurrentPage();
|
|
185
|
+
await webActions.verifyLockedInputFieldValue(page, field, expectedValue, options);
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
// screenshotActions.ts
|
|
189
|
+
Given("Web: Take Screenshot -options: {param}", async function (options) {
|
|
190
|
+
let page = webFixture.getCurrentPage();
|
|
191
|
+
await webActions.takeScreenshot(page, options);
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
Given("Web: Verify field is locked -field: {param} -options: {param}", async function (field, options) {
|
|
195
|
+
let page = webFixture.getCurrentPage();
|
|
196
|
+
await webActions.verifyFieldIsLocked(page, field, options);
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
Given("Web: Verify field is mandatory -field: {param} -options: {param}", async function (field, options) {
|
|
200
|
+
let page = webFixture.getCurrentPage();
|
|
201
|
+
await webActions.verifyFieldIsMandatory(page, field, options);
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
Given("Web: Verify field is secured -field: {param} -options: {param}", async function (field, options) {
|
|
205
|
+
let page = webFixture.getCurrentPage();
|
|
206
|
+
await webActions.verifyFieldIsSecured(page, field, options);
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
Given("Web: Verify select field value -field: {param} -value: {param} -options: {param}", async function (field, expectedValue, options) {
|
|
210
|
+
let page = webFixture.getCurrentPage();
|
|
211
|
+
await webActions.verifySelectDropdownValue(page, field, expectedValue, options);
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
Given("Web: Verify select list does not have given value -field: {param} -value: {param} -options: {param}", async function (field, excludedValue, options) {
|
|
215
|
+
let page = webFixture.getCurrentPage();
|
|
216
|
+
await webActions.verifySelectListNotHaveGivenValue(page, field, excludedValue, options);
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
// formActions.ts (upload)
|
|
220
|
+
Given("Web: Upload file at -field: {param} with filename: {param} -options: {param}", async function (fieldName, fileName, options) {
|
|
221
|
+
let page = webFixture.getCurrentPage();
|
|
222
|
+
await webActions.uploadFile(page, fieldName, fileName, options);
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
// elementReaderActions.ts
|
|
226
|
+
Given("Web: Store input value in variable -field: {param} -variableName: {param} -options: {param}", async function (field, variableName, options) {
|
|
227
|
+
let page = webFixture.getCurrentPage();
|
|
228
|
+
await webActions.storeElementTextInVariable(page, field, variableName, options);
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
// mouseActions.ts (additional)
|
|
232
|
+
Given("Web: Drag and Drop -source: {param} -target: {param} -options: {param}", async function (source, target, options) {
|
|
233
|
+
let page = webFixture.getCurrentPage();
|
|
234
|
+
await webActions.dragAndDrop(page, source, target, options);
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
// cookieActions.ts
|
|
238
|
+
Given("Web: Set Cookie -name: {param} -value: {param}", async function (name, value) {
|
|
239
|
+
let page = webFixture.getCurrentPage();
|
|
240
|
+
await webActions.setCookie(page, name, value);
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
Given("Web: Get Cookie -name: {param} -storeTo: {param}", async function (name, varName) {
|
|
244
|
+
let page = webFixture.getCurrentPage();
|
|
245
|
+
const val = await webActions.getCookie(page, name);
|
|
246
|
+
vars.setValue(varName, String(val ?? ''));
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
Given("Web: Delete Cookie -name: {param}", async function (name) {
|
|
250
|
+
let page = webFixture.getCurrentPage();
|
|
251
|
+
await webActions.deleteCookie(page, name);
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
Given("Web: Clear Cookies", async function () {
|
|
255
|
+
let page = webFixture.getCurrentPage();
|
|
256
|
+
await webActions.clearCookies(page);
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
// localStorageActions.ts
|
|
260
|
+
Given("Web: LocalStorage Set -key: {param} -value: {param}", async function (key, value) {
|
|
261
|
+
let page = webFixture.getCurrentPage();
|
|
262
|
+
await webActions.localStorageSet(page, key, value);
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
Given("Web: LocalStorage Get -key: {param} -storeTo: {param}", async function (key, varName) {
|
|
266
|
+
let page = webFixture.getCurrentPage();
|
|
267
|
+
const val = await webActions.localStorageGet(page, key);
|
|
268
|
+
vars.setValue(varName, String(val ?? ''));
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
Given("Web: LocalStorage Remove -key: {param}", async function (key) {
|
|
272
|
+
let page = webFixture.getCurrentPage();
|
|
273
|
+
await webActions.localStorageRemove(page, key);
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
Given("Web: LocalStorage Clear", async function () {
|
|
277
|
+
let page = webFixture.getCurrentPage();
|
|
278
|
+
await webActions.localStorageClear(page);
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
// iframeActions.ts
|
|
282
|
+
Given("Web: Switch to Frame -field: {param} -options: {param}", async function (field, options) {
|
|
283
|
+
let page = webFixture.getCurrentPage();
|
|
284
|
+
await webActions.switchToFrame(page, field, options);
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
Given("Web: Switch to Main Content", async function () {
|
|
288
|
+
let page = webFixture.getCurrentPage();
|
|
289
|
+
await webActions.switchToMainContent(page);
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
// screenshotActions.ts (full)
|
|
293
|
+
Given("Web: Take Full Screenshot -options: {param}", async function (options) {
|
|
294
|
+
let page = webFixture.getCurrentPage();
|
|
295
|
+
await webActions.takeFullScreenshot(page, options);
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
// javascriptActions.ts
|
|
299
|
+
Given("Web: Execute Script -code: {param}", async function (code) {
|
|
300
|
+
let page = webFixture.getCurrentPage();
|
|
301
|
+
await webActions.executeScript(page, (script: string) => eval(script), [code]);
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
// validationActions.ts helpers
|
|
305
|
+
Given("Web: Count Elements -field: {param} -storeTo: {param} -options: {param}", async function (field, varName, options) {
|
|
306
|
+
let page = webFixture.getCurrentPage();
|
|
307
|
+
const opts = typeof options === 'string' ? vars.parseLooseJson(options) : (options || {});
|
|
308
|
+
const locator = await webLocResolver(opts?.fieldType || '', field, page, opts?.pattern, opts?.actionTimeout);
|
|
309
|
+
const count = await (locator as any).count?.() ?? 0;
|
|
310
|
+
vars.setValue(varName, String(count));
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
// webNavigation.ts (tab management)
|
|
314
|
+
Given("Web: Refresh Page -options: {param}", async function (options) {
|
|
315
|
+
let page = webFixture.getCurrentPage();
|
|
316
|
+
await webActions.refreshPage(page, options);
|
|
317
|
+
});
|
|
318
|
+
|
|
319
|
+
Given("Web: Switch Tab -index: {int} -options: {param}", async function (index, options) {
|
|
320
|
+
let page = webFixture.getCurrentPage();
|
|
321
|
+
await webActions.switchTab(page, index, options);
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
Given("Web: Close Tab -options: {param}", async function (options) {
|
|
325
|
+
let page = webFixture.getCurrentPage();
|
|
326
|
+
await webActions.closeTab(page, options);
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
// webNavigation.ts (open new tab)
|
|
330
|
+
Given("Web: Open New Tab -url: {param} -options: {param}", async function (url, options) {
|
|
331
|
+
let page = webFixture.getCurrentPage();
|
|
332
|
+
const newPage = await webActions.openNewTab(page, url, options);
|
|
333
|
+
// Make the newly opened tab the current page for subsequent steps
|
|
334
|
+
webFixture.setPlaywrightPage(newPage);
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
// mouseActions.ts (scrolling)
|
|
338
|
+
Given("Web: Scroll To -x: {int} -y: {int} -options: {param}", async function (x, y, options) {
|
|
339
|
+
let page = webFixture.getCurrentPage();
|
|
340
|
+
await webActions.scrollTo(page, x, y, options);
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
Given("Web: Scroll Up -amount: {int} -options: {param}", async function (amount, options) {
|
|
344
|
+
let page = webFixture.getCurrentPage();
|
|
345
|
+
await webActions.scrollUp(page, amount, options);
|
|
346
|
+
});
|
|
347
|
+
|
|
348
|
+
Given("Web: Scroll Down -amount: {int} -options: {param}", async function (amount, options) {
|
|
349
|
+
let page = webFixture.getCurrentPage();
|
|
350
|
+
await webActions.scrollDown(page, amount, options);
|
|
351
|
+
});
|
|
352
|
+
|
|
353
|
+
// keyboardActions.ts (convenience)
|
|
354
|
+
Given("Web: Press Enter -options: {param}", async function (options) {
|
|
355
|
+
let page = webFixture.getCurrentPage();
|
|
356
|
+
await webActions.pressEnter(page, options);
|
|
357
|
+
});
|
|
358
|
+
|
|
359
|
+
Given("Web: Press Tab -options: {param}", async function (options) {
|
|
360
|
+
let page = webFixture.getCurrentPage();
|
|
361
|
+
await webActions.pressTab(page, options);
|
|
362
|
+
});
|
|
363
|
+
|
|
364
|
+
// elementReaderActions.ts (store to vars)
|
|
365
|
+
Given("Web: Get Text -field: {param} -storeTo: {param} -options: {param}", async function (field, varName, options) {
|
|
366
|
+
let page = webFixture.getCurrentPage();
|
|
367
|
+
const val = await webActions.getText(page, field, options);
|
|
368
|
+
vars.setValue(varName, typeof val === 'string' ? val : String(val ?? ''));
|
|
369
|
+
});
|
|
370
|
+
|
|
371
|
+
Given("Web: Get Value -field: {param} -storeTo: {param} -options: {param}", async function (field, varName, options) {
|
|
372
|
+
let page = webFixture.getCurrentPage();
|
|
373
|
+
const val = await webActions.getValue(page, field, options);
|
|
374
|
+
vars.setValue(varName, typeof val === 'string' ? val : String(val ?? ''));
|
|
375
|
+
});
|
|
376
|
+
|
|
377
|
+
Given("Web: Get Attribute -field: {param} -name: {param} -storeTo: {param} -options: {param}", async function (field, name, varName, options) {
|
|
378
|
+
let page = webFixture.getCurrentPage();
|
|
379
|
+
const val = await webActions.getAttribute(page, field, name, options);
|
|
380
|
+
vars.setValue(varName, typeof val === 'string' ? val : String(val ?? ''));
|
|
381
|
+
});
|
|
382
|
+
|
|
383
|
+
Given("Web: Has Class -field: {param} -className: {param} -storeTo: {param} -options: {param}", async function (field, className, varName, options) {
|
|
384
|
+
let page = webFixture.getCurrentPage();
|
|
385
|
+
const has = await webActions.hasClass(page, field, className, options);
|
|
386
|
+
vars.setValue(varName, String(!!has));
|
|
387
|
+
});
|
|
388
|
+
|
|
389
|
+
Given("Web: Get HTML -field: {param} -storeTo: {param} -options: {param}", async function (field, varName, options) {
|
|
390
|
+
let page = webFixture.getCurrentPage();
|
|
391
|
+
const html = await webActions.getHtml(page, field, options);
|
|
392
|
+
vars.setValue(varName, typeof html === 'string' ? html : String(html ?? ''));
|
|
393
|
+
});
|
|
394
|
+
|
|
395
|
+
// alertActions.ts
|
|
396
|
+
Given("Web: Accept Alert -options: {param}", async function (options) {
|
|
397
|
+
let page = webFixture.getCurrentPage();
|
|
398
|
+
await webActions.acceptAlert(page, options);
|
|
399
|
+
});
|
|
400
|
+
|
|
401
|
+
Given("Web: Dismiss Alert -options: {param}", async function (options) {
|
|
402
|
+
let page = webFixture.getCurrentPage();
|
|
403
|
+
await webActions.dismissAlert(page, options);
|
|
404
|
+
});
|
|
405
|
+
|
|
406
|
+
Given("Web: Fill Alert -text: {param} -options: {param}", async function (text, options) {
|
|
407
|
+
let page = webFixture.getCurrentPage();
|
|
408
|
+
await webActions.fillAlert(page, text, options);
|
|
409
|
+
});
|
|
410
|
+
|
|
411
|
+
Given("Web: See Alert Text -expected: {param} -options: {param}", async function (expected, options) {
|
|
412
|
+
let page = webFixture.getCurrentPage();
|
|
413
|
+
await webActions.seeAlertText(page, expected, options);
|
|
414
|
+
});
|
|
415
|
+
|
|
416
|
+
// downloadActions.ts
|
|
417
|
+
Given("Web: List Files -dir: {param} -storeTo: {param}", async function (dir, varName) {
|
|
418
|
+
const files = await webActions.listFiles(dir);
|
|
419
|
+
vars.setValue(varName, JSON.stringify(files));
|
|
420
|
+
});
|
|
421
|
+
|
|
422
|
+
Given("Web: Has File -dir: {param} -fileName: {param} -storeTo: {param}", async function (dir, fileName, varName) {
|
|
423
|
+
const has = await webActions.hasFile(dir, fileName);
|
|
424
|
+
vars.setValue(varName, String(!!has));
|
|
425
|
+
});
|
|
426
|
+
|
|
427
|
+
Given("Web: Download File -field: {param} -options: {param}", async function (field, options) {
|
|
428
|
+
let page = webFixture.getCurrentPage();
|
|
429
|
+
await webActions.downloadFile(page, field, options);
|
|
430
|
+
});
|
|
431
|
+
|
|
432
|
+
Given("Web: Download File -field: {param} -options: {param} -storeTo: {param}", async function (field, options, varName) {
|
|
433
|
+
let page = webFixture.getCurrentPage();
|
|
434
|
+
const saved = await webActions.downloadFile(page, field, options);
|
|
435
|
+
vars.setValue(varName, String(saved || ''));
|
|
436
|
+
});
|
|
437
|
+
|
|
438
|
+
// reportingActions.ts
|
|
439
|
+
Given("Web: Log Info -message: {param}", async function (message) {
|
|
440
|
+
await webActions.logInfo(message);
|
|
441
|
+
});
|
|
442
|
+
|
|
443
|
+
Given("Web: Log Pass -message: {param}", async function (message) {
|
|
444
|
+
await webActions.logPass(message);
|
|
445
|
+
});
|
|
446
|
+
|
|
447
|
+
Given("Web: Log Fail -message: {param}", async function (message) {
|
|
448
|
+
await webActions.logFail(message);
|
|
449
|
+
});
|
|
450
|
+
|
|
451
|
+
Given("Web: Assert -condition: {param} -message: {param}", async function (condition, message) {
|
|
452
|
+
const c = String(condition).toLowerCase().trim();
|
|
453
|
+
const ok = c === 'true' || c === '1' || c === 'yes';
|
|
454
|
+
await webActions.assertLog(ok, message);
|
|
455
|
+
});
|
|
456
|
+
|
|
457
|
+
// testDataActions.ts
|
|
458
|
+
Given("Web: Load Test Data JSON -file: {param} -storeTo: {param}", async function (filePath, varName) {
|
|
459
|
+
const data = await webActions.loadFromJson(filePath);
|
|
460
|
+
vars.setValue(varName, JSON.stringify(data));
|
|
461
|
+
});
|
|
462
|
+
|
|
463
|
+
Given("Web: Load Test Data CSV -file: {param} -storeTo: {param}", async function (filePath, varName) {
|
|
464
|
+
const data = await webActions.loadFromCsv(filePath);
|
|
465
|
+
vars.setValue(varName, JSON.stringify(data));
|
|
466
|
+
});
|
|
467
|
+
|
|
468
|
+
// formActions.ts (aliases)
|
|
469
|
+
Given("Web: Set -field: {param} -value: {param} -options: {param}", async function (field, value, options) {
|
|
470
|
+
let page = webFixture.getCurrentPage();
|
|
471
|
+
await webActions.set(page, field, value, options);
|
|
472
|
+
});
|
|
473
|
+
|
|
474
|
+
Given("Web: Enter -field: {param} -value: {param} -options: {param}", async function (field, value, options) {
|
|
475
|
+
let page = webFixture.getCurrentPage();
|
|
476
|
+
await webActions.enter(page, field, value, options);
|
|
477
|
+
});
|
|
478
|
+
|
|
479
|
+
// waitActions.ts (generic wait + condition)
|
|
480
|
+
Given("Web: Wait -ms: {int}", async function (ms) {
|
|
481
|
+
await webActions.wait(ms);
|
|
482
|
+
});
|
|
483
|
+
|
|
484
|
+
Given("Web: Wait For Condition -code: {param} -options: {param}", async function (code, options) {
|
|
485
|
+
let page = webFixture.getCurrentPage();
|
|
486
|
+
// Evaluate predicate code in page context until true
|
|
487
|
+
await webActions.waitForCondition(page, async (p) => {
|
|
488
|
+
const result = await p.evaluate((c) => { try { return !!eval(c); } catch { return false; } }, code);
|
|
489
|
+
return !!result;
|
|
490
|
+
}, options);
|
|
491
|
+
});
|
|
492
|
+
|
|
493
|
+
// screenshotActions.ts (process + save to disk)
|
|
494
|
+
Given("Web: Process Screenshot -shouldTake: {param} -text: {param} -fullPage: {param}", async function (shouldTake, text, fullPage) {
|
|
495
|
+
let page = webFixture.getCurrentPage();
|
|
496
|
+
const take = String(shouldTake).toLowerCase() === 'true';
|
|
497
|
+
const fp = String(fullPage).toLowerCase() !== 'false';
|
|
498
|
+
await webActions.processScreenshot(page, take, text, fp);
|
|
499
|
+
});
|
|
500
|
+
|
|
501
|
+
Given("Web: Generate Sample Data -schema: {param} -storeTo: {param}", async function (schema, varName) {
|
|
502
|
+
const schemaObj = typeof schema === 'string' ? vars.parseLooseJson(schema) : (schema || {});
|
|
503
|
+
const data = await webActions.generateSampleData(schemaObj);
|
|
504
|
+
vars.setValue(varName, JSON.stringify(data));
|
|
505
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { chromium, firefox, webkit } from "playwright";
|
|
2
|
+
import type { LaunchOptions } from "playwright";
|
|
3
|
+
import * as vars from "../bundle/vars";
|
|
4
|
+
|
|
5
|
+
const headlessConfig = vars.getConfigValue('browser.headless');
|
|
6
|
+
const options = {
|
|
7
|
+
headless: headlessConfig === 'false' ? false : true
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const invokeBrowser = () => {
|
|
11
|
+
const browserType = vars.getConfigValue('browser.browserType') || "chromium";
|
|
12
|
+
switch (browserType) {
|
|
13
|
+
case "chromium":
|
|
14
|
+
return chromium.launch(options);
|
|
15
|
+
case "firefox":
|
|
16
|
+
return firefox.launch(options);
|
|
17
|
+
case "webkit":
|
|
18
|
+
return webkit.launch(options);
|
|
19
|
+
default:
|
|
20
|
+
throw new Error("Please set the proper browser!")
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
}
|