@auxcode/auxta 0.5.4 → 0.5.8
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/build/AuxTA.d.ts +43 -0
- package/build/AuxTA.js +112 -0
- package/build/auxta/configs/config.d.ts +51 -0
- package/build/auxta/configs/config.js +61 -0
- package/build/auxta/enums/status-of.step.d.ts +7 -0
- package/build/auxta/enums/status-of.step.js +8 -0
- package/build/auxta/helpers/response.helper.d.ts +10 -0
- package/build/auxta/helpers/response.helper.js +11 -0
- package/build/auxta/helpers/start.helper.d.ts +1 -0
- package/build/auxta/helpers/start.helper.js +24 -0
- package/build/auxta/hooks/report.hook.d.ts +4 -0
- package/build/auxta/hooks/report.hook.js +58 -0
- package/build/auxta/models/upload.model.d.ts +20 -0
- package/build/auxta/models/upload.model.js +43 -0
- package/build/auxta/services/log.service.d.ts +26 -0
- package/build/auxta/services/log.service.js +43 -0
- package/build/auxta/services/report.service.d.ts +36 -0
- package/build/auxta/services/report.service.js +148 -0
- package/build/auxta/services/runtime.service.d.ts +16 -0
- package/build/auxta/services/runtime.service.js +37 -0
- package/build/auxta/utilities/runtime.helper.d.ts +15 -0
- package/build/auxta/utilities/runtime.helper.js +15 -0
- package/build/auxta/utilities/screenshot.helper.d.ts +2 -0
- package/build/auxta/utilities/screenshot.helper.js +29 -0
- package/build/auxta/utilities/start-suite.helper.d.ts +1 -0
- package/build/auxta/utilities/start-suite.helper.js +25 -0
- package/build/cjs/AuxTA.js +38 -23
- package/build/cjs/auxta/helpers/start.helper.js +12 -3
- package/build/cjs/auxta/hooks/report.hook.js +50 -37
- package/build/cjs/auxta/services/report.service.js +126 -105
- package/build/cjs/auxta/utilities/screenshot.helper.js +27 -16
- package/build/cjs/auxta/utilities/start-suite.helper.js +22 -11
- package/build/cjs/macros/helpers/code.helper.js +164 -129
- package/build/cjs/puppeteer/puppeteer.js +117 -100
- package/build/macros/helpers/code.helper.d.ts +22 -0
- package/build/macros/helpers/code.helper.js +193 -0
- package/build/puppeteer/puppeteer.d.ts +13 -0
- package/build/puppeteer/puppeteer.js +153 -0
- package/build/tsconfig-cjs.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
13
|
};
|
|
@@ -22,143 +31,169 @@ class FunctionHelper {
|
|
|
22
31
|
const splitedQuotes = text.replace(/'/g, `', "'", '`);
|
|
23
32
|
return `concat('${splitedQuotes}', '')`;
|
|
24
33
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
throw new Error(message);
|
|
39
|
-
}
|
|
40
|
-
async clickByTextWithClass(class_selector, class_name, selector, text, page = puppeteer_1.default.defaultPage, dotOrText = '.') {
|
|
41
|
-
const message = `I click on the '${text}' '${selector}'`;
|
|
42
|
-
try {
|
|
43
|
-
const [linkHandlers] = await page.$x(`//${class_selector}[contains(@class,${this.getEscapedText(class_name)})]//${selector}[${dotOrText} = ${this.getEscapedText(text)}]`);
|
|
44
|
-
if (linkHandlers) {
|
|
45
|
-
await linkHandlers.click();
|
|
46
|
-
log_service_1.default.push('Then', message, status_of_step_1.StatusOfStep.PASSED);
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
catch (e) {
|
|
51
|
-
}
|
|
52
|
-
log_service_1.default.push('Then', message, status_of_step_1.StatusOfStep.FAILED);
|
|
53
|
-
throw new Error(message);
|
|
54
|
-
}
|
|
55
|
-
async waitForSelectorWithText(selector, text, page = puppeteer_1.default.defaultPage, dotOrText = '.') {
|
|
56
|
-
const message = `I check for '${text}' on the current page`;
|
|
57
|
-
try {
|
|
58
|
-
await page.waitForSelector(selector, {
|
|
59
|
-
timeout: this.defaultTimeout
|
|
60
|
-
});
|
|
61
|
-
const linkHandlers = await page.$x(`//${selector}[${dotOrText} = ${this.getEscapedText(text)}]`);
|
|
62
|
-
if (linkHandlers.length > 0) {
|
|
63
|
-
log_service_1.default.push('And', message, status_of_step_1.StatusOfStep.PASSED);
|
|
64
|
-
return true;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
catch (e) {
|
|
68
|
-
}
|
|
69
|
-
log_service_1.default.push('And', message, status_of_step_1.StatusOfStep.FAILED);
|
|
70
|
-
throw new Error(message);
|
|
71
|
-
}
|
|
72
|
-
async goto(url, page = puppeteer_1.default.defaultPage) {
|
|
73
|
-
await page.goto(url);
|
|
74
|
-
log_service_1.default.push('Then', `I go to the '${url}' page`, status_of_step_1.StatusOfStep.PASSED);
|
|
75
|
-
}
|
|
76
|
-
async type(field, value, page = puppeteer_1.default.defaultPage) {
|
|
77
|
-
try {
|
|
78
|
-
await page.waitForSelector(field, {
|
|
79
|
-
timeout: this.defaultTimeout
|
|
80
|
-
});
|
|
81
|
-
await page.type(field, value);
|
|
82
|
-
let elementName = await page.$eval(field, (e) => e.textContent);
|
|
83
|
-
if (!elementName || elementName === ' ')
|
|
84
|
-
elementName = field;
|
|
85
|
-
log_service_1.default.push('Then', `I type '${value}' into the '${elementName}' field`, status_of_step_1.StatusOfStep.PASSED);
|
|
86
|
-
}
|
|
87
|
-
catch (e) {
|
|
88
|
-
const msg = `I type '${value}' into the '${field}' field`;
|
|
89
|
-
log_service_1.default.push('Then', msg, status_of_step_1.StatusOfStep.FAILED);
|
|
90
|
-
throw new Error(msg);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
async waitForNetwork(page = puppeteer_1.default.defaultPage) {
|
|
94
|
-
let message = 'I wait for the page to load';
|
|
95
|
-
try {
|
|
96
|
-
await page.waitForNetworkIdle();
|
|
97
|
-
log_service_1.default.push('Then', message, status_of_step_1.StatusOfStep.PASSED);
|
|
98
|
-
}
|
|
99
|
-
catch (e) {
|
|
34
|
+
clickByText(selector, text, page = puppeteer_1.default.defaultPage, dotOrText = '.') {
|
|
35
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
36
|
+
const message = `I click on the '${text}' '${selector}'`;
|
|
37
|
+
try {
|
|
38
|
+
const [linkHandlers] = yield page.$x(`//${selector}[${dotOrText} = ${this.getEscapedText(text)}]`);
|
|
39
|
+
if (linkHandlers) {
|
|
40
|
+
yield linkHandlers.click();
|
|
41
|
+
log_service_1.default.push('Then', message, status_of_step_1.StatusOfStep.PASSED);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
catch (e) {
|
|
46
|
+
}
|
|
100
47
|
log_service_1.default.push('Then', message, status_of_step_1.StatusOfStep.FAILED);
|
|
101
48
|
throw new Error(message);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}
|
|
115
|
-
catch (e) {
|
|
116
|
-
if (log_message) {
|
|
117
|
-
log_service_1.default.push('And', message, status_of_step_1.StatusOfStep.FAILED);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
clickByTextWithClass(class_selector, class_name, selector, text, page = puppeteer_1.default.defaultPage, dotOrText = '.') {
|
|
52
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
+
const message = `I click on the '${text}' '${selector}'`;
|
|
54
|
+
try {
|
|
55
|
+
const [linkHandlers] = yield page.$x(`//${class_selector}[contains(@class,${this.getEscapedText(class_name)})]//${selector}[${dotOrText} = ${this.getEscapedText(text)}]`);
|
|
56
|
+
if (linkHandlers) {
|
|
57
|
+
yield linkHandlers.click();
|
|
58
|
+
log_service_1.default.push('Then', message, status_of_step_1.StatusOfStep.PASSED);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
118
61
|
}
|
|
62
|
+
catch (e) {
|
|
63
|
+
}
|
|
64
|
+
log_service_1.default.push('Then', message, status_of_step_1.StatusOfStep.FAILED);
|
|
119
65
|
throw new Error(message);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
const msg = `I click on the '${selector}'`;
|
|
138
|
-
log_service_1.default.push('Then', msg, status_of_step_1.StatusOfStep.FAILED);
|
|
139
|
-
throw new Error(msg);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
async urlContains(selector, page = puppeteer_1.default.defaultPage) {
|
|
143
|
-
const url = page.url();
|
|
144
|
-
let message = `I am on the ${selector} page`;
|
|
145
|
-
if (!url.includes(selector)) {
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
waitForSelectorWithText(selector, text, page = puppeteer_1.default.defaultPage, dotOrText = '.') {
|
|
69
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
70
|
+
const message = `I check for '${text}' on the current page`;
|
|
71
|
+
try {
|
|
72
|
+
yield page.waitForSelector(selector, {
|
|
73
|
+
timeout: this.defaultTimeout
|
|
74
|
+
});
|
|
75
|
+
const linkHandlers = yield page.$x(`//${selector}[${dotOrText} = ${this.getEscapedText(text)}]`);
|
|
76
|
+
if (linkHandlers.length > 0) {
|
|
77
|
+
log_service_1.default.push('And', message, status_of_step_1.StatusOfStep.PASSED);
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
catch (e) {
|
|
82
|
+
}
|
|
146
83
|
log_service_1.default.push('And', message, status_of_step_1.StatusOfStep.FAILED);
|
|
147
84
|
throw new Error(message);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
goto(url, page = puppeteer_1.default.defaultPage) {
|
|
88
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
89
|
+
yield page.goto(url);
|
|
90
|
+
log_service_1.default.push('Then', `I go to the '${url}' page`, status_of_step_1.StatusOfStep.PASSED);
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
type(field, value, page = puppeteer_1.default.defaultPage) {
|
|
94
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
95
|
+
try {
|
|
96
|
+
yield page.waitForSelector(field, {
|
|
97
|
+
timeout: this.defaultTimeout
|
|
98
|
+
});
|
|
99
|
+
yield page.type(field, value);
|
|
100
|
+
let elementName = yield page.$eval(field, (e) => e.textContent);
|
|
101
|
+
if (!elementName || elementName === ' ')
|
|
102
|
+
elementName = field;
|
|
103
|
+
log_service_1.default.push('Then', `I type '${value}' into the '${elementName}' field`, status_of_step_1.StatusOfStep.PASSED);
|
|
104
|
+
}
|
|
105
|
+
catch (e) {
|
|
106
|
+
const msg = `I type '${value}' into the '${field}' field`;
|
|
107
|
+
log_service_1.default.push('Then', msg, status_of_step_1.StatusOfStep.FAILED);
|
|
108
|
+
throw new Error(msg);
|
|
109
|
+
}
|
|
110
|
+
});
|
|
153
111
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
112
|
+
waitForNetwork(page = puppeteer_1.default.defaultPage) {
|
|
113
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
114
|
+
let message = 'I wait for the page to load';
|
|
115
|
+
try {
|
|
116
|
+
yield page.waitForNetworkIdle();
|
|
117
|
+
log_service_1.default.push('Then', message, status_of_step_1.StatusOfStep.PASSED);
|
|
118
|
+
}
|
|
119
|
+
catch (e) {
|
|
120
|
+
log_service_1.default.push('Then', message, status_of_step_1.StatusOfStep.FAILED);
|
|
121
|
+
throw new Error(message);
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
timeout(timeout = this.defaultTimeout, page = puppeteer_1.default.defaultPage) {
|
|
126
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
127
|
+
yield page.waitForTimeout(timeout);
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
waitForSelector(option, selector, time = this.defaultTimeout, page = puppeteer_1.default.defaultPage, log_message = true) {
|
|
131
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
132
|
+
const message = `I check for the '${selector}' element to be ${option}`;
|
|
133
|
+
try {
|
|
134
|
+
yield page.waitForSelector(selector, {
|
|
135
|
+
[option]: true,
|
|
136
|
+
timeout: time
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
catch (e) {
|
|
140
|
+
if (log_message) {
|
|
141
|
+
log_service_1.default.push('And', message, status_of_step_1.StatusOfStep.FAILED);
|
|
142
|
+
}
|
|
143
|
+
throw new Error(message);
|
|
144
|
+
}
|
|
145
|
+
if (log_message) {
|
|
146
|
+
log_service_1.default.push('And', message, status_of_step_1.StatusOfStep.PASSED);
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
click(selector, logMessages = true, page = puppeteer_1.default.defaultPage) {
|
|
151
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
152
|
+
try {
|
|
153
|
+
yield page.waitForSelector(selector, {
|
|
154
|
+
timeout: this.defaultTimeout
|
|
155
|
+
});
|
|
156
|
+
let elementName = yield page.$eval(selector, (e) => e.textContent);
|
|
157
|
+
if (!elementName || elementName === ' ')
|
|
158
|
+
elementName = selector;
|
|
159
|
+
yield page.click(selector);
|
|
160
|
+
log_service_1.default.push('Then', `I click on the '${elementName}'`, status_of_step_1.StatusOfStep.PASSED);
|
|
161
|
+
}
|
|
162
|
+
catch (e) {
|
|
163
|
+
const msg = `I click on the '${selector}'`;
|
|
164
|
+
log_service_1.default.push('Then', msg, status_of_step_1.StatusOfStep.FAILED);
|
|
165
|
+
throw new Error(msg);
|
|
166
|
+
}
|
|
167
|
+
});
|
|
158
168
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
169
|
+
urlContains(selector, page = puppeteer_1.default.defaultPage) {
|
|
170
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
171
|
+
const url = page.url();
|
|
172
|
+
let message = `I am on the ${selector} page`;
|
|
173
|
+
if (!url.includes(selector)) {
|
|
174
|
+
log_service_1.default.push('And', message, status_of_step_1.StatusOfStep.FAILED);
|
|
175
|
+
throw new Error(message);
|
|
176
|
+
}
|
|
177
|
+
log_service_1.default.push('And', message, status_of_step_1.StatusOfStep.PASSED);
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
pressEnter(page = puppeteer_1.default.defaultPage) {
|
|
181
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
182
|
+
yield page.keyboard.press('Enter');
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
clickAndWaitForPageToBeCreated(selector, page = puppeteer_1.default.defaultPage) {
|
|
186
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
187
|
+
const nav = new Promise(res => page.browser().on('targetcreated', res));
|
|
188
|
+
yield this.click(selector);
|
|
189
|
+
yield nav;
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
closeLastPage(page = puppeteer_1.default.defaultPage) {
|
|
193
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
194
|
+
const pages = yield page.browser().pages();
|
|
195
|
+
yield pages[pages.length - 1].close();
|
|
196
|
+
});
|
|
162
197
|
}
|
|
163
198
|
}
|
|
164
199
|
exports.FunctionHelper = FunctionHelper;
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
13
|
};
|
|
@@ -13,118 +22,126 @@ const status_of_step_1 = require("../auxta/enums/status-of.step");
|
|
|
13
22
|
const config_1 = require("./../auxta/configs/config");
|
|
14
23
|
const report_service_1 = require("../auxta/services/report.service");
|
|
15
24
|
class Puppeteer {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
25
|
+
startBrowser() {
|
|
26
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
let args = [
|
|
28
|
+
'--start-maximized',
|
|
29
|
+
'--no-sandbox',
|
|
30
|
+
'--disable-setuid-sandbox',
|
|
31
|
+
'--disable-dev-shm-usage',
|
|
32
|
+
'--single-process'
|
|
33
|
+
];
|
|
34
|
+
if (process.env.ENVIRONMENT != 'LOCAL')
|
|
35
|
+
args.push(`--window-size=${config_1.config.screenWidth},${config_1.config.screenHeight}`);
|
|
36
|
+
this.browser = yield chrome_aws_lambda_1.default.puppeteer.launch({
|
|
37
|
+
executablePath: process.env.ENVIRONMENT === 'LOCAL' ? undefined : yield chrome_aws_lambda_1.default.executablePath,
|
|
38
|
+
args,
|
|
39
|
+
ignoreDefaultArgs: ["--enable-automation"],
|
|
40
|
+
defaultViewport: process.env.ENVIRONMENT === 'LOCAL' ? null : {
|
|
41
|
+
width: config_1.config.screenWidth,
|
|
42
|
+
height: config_1.config.screenHeight
|
|
43
|
+
},
|
|
44
|
+
headless: process.env.ENVIRONMENT == 'LOCAL' ? false : chrome_aws_lambda_1.default.headless
|
|
45
|
+
});
|
|
46
|
+
this.defaultPage = (yield this.browser.pages())[0];
|
|
47
|
+
yield this.defaultPage.goto(config_1.config.baseURL, { waitUntil: 'networkidle0' });
|
|
48
|
+
yield this.defaultPage.waitForNetworkIdle();
|
|
35
49
|
});
|
|
36
|
-
this.defaultPage = (await this.browser.pages())[0];
|
|
37
|
-
await this.defaultPage.goto(config_1.config.baseURL, { waitUntil: 'networkidle0' });
|
|
38
|
-
await this.defaultPage.waitForNetworkIdle();
|
|
39
50
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
51
|
+
close() {
|
|
52
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
+
if (this.browser) {
|
|
54
|
+
let pages = yield this.browser.pages();
|
|
55
|
+
yield Promise.all(pages.map((page) => page.close()));
|
|
56
|
+
yield this.browser.close();
|
|
57
|
+
}
|
|
58
|
+
});
|
|
46
59
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
if (uploadModel === undefined)
|
|
50
|
-
uploadModel = AuxTA_1.default.getUploadModel();
|
|
51
|
-
if (close === undefined)
|
|
52
|
-
close = Puppeteer.setupHeader(event, uploadModel);
|
|
53
|
-
let screenshotBuffer;
|
|
54
|
-
let errMessage;
|
|
55
|
-
let statusCode = 200;
|
|
56
|
-
let consoleStack = [];
|
|
60
|
+
run(event, callback, featureName = 'Test feature', scenarioName = 'Test scenario', uploadModel, close) {
|
|
61
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
57
62
|
try {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
.
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
if (uploadModel === undefined)
|
|
64
|
+
uploadModel = AuxTA_1.default.getUploadModel();
|
|
65
|
+
if (close === undefined)
|
|
66
|
+
close = Puppeteer.setupHeader(event, uploadModel);
|
|
67
|
+
let screenshotBuffer;
|
|
68
|
+
let errMessage;
|
|
69
|
+
let statusCode = 200;
|
|
70
|
+
let consoleStack = [];
|
|
71
|
+
try {
|
|
72
|
+
yield log_service_1.default.push('When', `Starting puppeteer process`, status_of_step_1.StatusOfStep.PASSED);
|
|
73
|
+
yield this.startBrowser();
|
|
74
|
+
this.defaultPage.on('console', message => consoleStack.push(`${message.type().substr(0, 3).toUpperCase()} ${message.text()}`))
|
|
75
|
+
.on('pageerror', ({ message }) => consoleStack.push(message))
|
|
76
|
+
.on('response', response => consoleStack.push(`${response.status()} ${response.url()}`))
|
|
77
|
+
.on('requestfailed', request => { var _a; return consoleStack.push(`${request.failure() !== null ? (_a = request.failure()) === null || _a === void 0 ? void 0 : _a.errorText : ""} ${request.url()}`); });
|
|
78
|
+
yield callback(event);
|
|
79
|
+
log_service_1.default.push('When', `Finished puppeteer process`, status_of_step_1.StatusOfStep.PASSED);
|
|
80
|
+
}
|
|
81
|
+
catch (err) {
|
|
82
|
+
console.log("Error", err);
|
|
83
|
+
errMessage = err;
|
|
84
|
+
statusCode = 500;
|
|
85
|
+
screenshotBuffer = yield (0, screenshot_helper_1.captureScreenshot)();
|
|
86
|
+
log_service_1.default.push('When', `Finished puppeteer process`, status_of_step_1.StatusOfStep.FAILED);
|
|
87
|
+
yield (0, report_service_1.postNotificationsOnFail)(uploadModel);
|
|
88
|
+
}
|
|
89
|
+
let url = this.defaultPage.url();
|
|
90
|
+
if (close)
|
|
91
|
+
yield this.close();
|
|
92
|
+
yield (0, report_hook_1.onTestEnd)(uploadModel, featureName, scenarioName, statusCode, screenshotBuffer, !errMessage ? undefined : {
|
|
93
|
+
currentPageUrl: url,
|
|
94
|
+
console: consoleStack,
|
|
95
|
+
error: errMessage
|
|
96
|
+
});
|
|
66
97
|
}
|
|
67
|
-
catch (
|
|
68
|
-
console.log("
|
|
69
|
-
errMessage = err;
|
|
70
|
-
statusCode = 500;
|
|
71
|
-
screenshotBuffer = await (0, screenshot_helper_1.captureScreenshot)();
|
|
72
|
-
log_service_1.default.push('When', `Finished puppeteer process`, status_of_step_1.StatusOfStep.FAILED);
|
|
73
|
-
await (0, report_service_1.postNotificationsOnFail)(uploadModel);
|
|
98
|
+
catch (e) {
|
|
99
|
+
console.log("Lib error:", e);
|
|
74
100
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
currentPageUrl: url,
|
|
80
|
-
console: consoleStack,
|
|
81
|
-
error: errMessage
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
catch (e) {
|
|
85
|
-
console.log("Lib error:", e);
|
|
86
|
-
}
|
|
87
|
-
finally {
|
|
88
|
-
log_service_1.default.clear();
|
|
89
|
-
}
|
|
101
|
+
finally {
|
|
102
|
+
log_service_1.default.clear();
|
|
103
|
+
}
|
|
104
|
+
});
|
|
90
105
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
if (
|
|
96
|
-
|
|
106
|
+
runRPA(event, callback, close) {
|
|
107
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
108
|
+
let errMessage;
|
|
109
|
+
try {
|
|
110
|
+
if (close === undefined) {
|
|
111
|
+
if (event.queryStringParameters.close) {
|
|
112
|
+
close = event.queryStringParameters.close === "true";
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
close = true;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
let consoleStack = [];
|
|
119
|
+
try {
|
|
120
|
+
yield log_service_1.default.push('When', `Starting puppeteer process`, status_of_step_1.StatusOfStep.PASSED);
|
|
121
|
+
yield this.startBrowser();
|
|
122
|
+
this.defaultPage.on('console', message => consoleStack.push(`${message.type().substr(0, 3).toUpperCase()} ${message.text()}`))
|
|
123
|
+
.on('pageerror', ({ message }) => consoleStack.push(message))
|
|
124
|
+
.on('response', response => consoleStack.push(`${response.status()} ${response.url()}`))
|
|
125
|
+
.on('requestfailed', request => { var _a; return consoleStack.push(`${request.failure() !== null ? (_a = request.failure()) === null || _a === void 0 ? void 0 : _a.errorText : ""} ${request.url()}`); });
|
|
126
|
+
yield callback(event);
|
|
127
|
+
log_service_1.default.push('When', `Finished puppeteer process`, status_of_step_1.StatusOfStep.PASSED);
|
|
97
128
|
}
|
|
98
|
-
|
|
99
|
-
|
|
129
|
+
catch (err) {
|
|
130
|
+
errMessage = err;
|
|
131
|
+
log_service_1.default.push('When', `Finished puppeteer process`, status_of_step_1.StatusOfStep.FAILED);
|
|
132
|
+
return errMessage;
|
|
100
133
|
}
|
|
134
|
+
if (close)
|
|
135
|
+
yield this.close();
|
|
101
136
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
await log_service_1.default.push('When', `Starting puppeteer process`, status_of_step_1.StatusOfStep.PASSED);
|
|
105
|
-
await this.startBrowser();
|
|
106
|
-
this.defaultPage.on('console', message => consoleStack.push(`${message.type().substr(0, 3).toUpperCase()} ${message.text()}`))
|
|
107
|
-
.on('pageerror', ({ message }) => consoleStack.push(message))
|
|
108
|
-
.on('response', response => consoleStack.push(`${response.status()} ${response.url()}`))
|
|
109
|
-
.on('requestfailed', request => consoleStack.push(`${request.failure() !== null ? request.failure()?.errorText : ""} ${request.url()}`));
|
|
110
|
-
await callback(event);
|
|
111
|
-
log_service_1.default.push('When', `Finished puppeteer process`, status_of_step_1.StatusOfStep.PASSED);
|
|
137
|
+
catch (e) {
|
|
138
|
+
console.log("Lib error:", e);
|
|
112
139
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
log_service_1.default.push('When', `Finished puppeteer process`, status_of_step_1.StatusOfStep.FAILED);
|
|
116
|
-
return errMessage;
|
|
140
|
+
finally {
|
|
141
|
+
log_service_1.default.clear();
|
|
117
142
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
}
|
|
121
|
-
catch (e) {
|
|
122
|
-
console.log("Lib error:", e);
|
|
123
|
-
}
|
|
124
|
-
finally {
|
|
125
|
-
log_service_1.default.clear();
|
|
126
|
-
}
|
|
127
|
-
return true;
|
|
143
|
+
return true;
|
|
144
|
+
});
|
|
128
145
|
}
|
|
129
146
|
static setupHeader(event, uploadModel) {
|
|
130
147
|
let close = true;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { StatusOfStep } from "../../auxta/enums/status-of.step";
|
|
2
|
+
export declare class FunctionHelper {
|
|
3
|
+
readonly defaultTimeout: number;
|
|
4
|
+
log(keyword: string, name: string, status: StatusOfStep): void;
|
|
5
|
+
suggest(name: string): void;
|
|
6
|
+
private getEscapedText;
|
|
7
|
+
clickByText(selector: string, text: string, page?: import("puppeteer-core").Page, dotOrText?: string): Promise<void>;
|
|
8
|
+
clickByTextWithClass(class_selector: string, class_name: string, selector: string, text: string, page?: import("puppeteer-core").Page, dotOrText?: string): Promise<void>;
|
|
9
|
+
waitForSelectorWithText(selector: string, text: string, page?: import("puppeteer-core").Page, dotOrText?: string): Promise<boolean>;
|
|
10
|
+
goto(url: string, page?: import("puppeteer-core").Page): Promise<void>;
|
|
11
|
+
type(field: string, value: string, page?: import("puppeteer-core").Page): Promise<void>;
|
|
12
|
+
waitForNetwork(page?: import("puppeteer-core").Page): Promise<void>;
|
|
13
|
+
timeout(timeout?: number, page?: import("puppeteer-core").Page): Promise<void>;
|
|
14
|
+
waitForSelector(option: string, selector: string, time?: number, page?: import("puppeteer-core").Page, log_message?: boolean): Promise<void>;
|
|
15
|
+
click(selector: string, logMessages?: boolean, page?: import("puppeteer-core").Page): Promise<void>;
|
|
16
|
+
urlContains(selector: string, page?: import("puppeteer-core").Page): Promise<void>;
|
|
17
|
+
pressEnter(page?: import("puppeteer-core").Page): Promise<void>;
|
|
18
|
+
clickAndWaitForPageToBeCreated(selector: string, page?: import("puppeteer-core").Page): Promise<void>;
|
|
19
|
+
closeLastPage(page?: import("puppeteer-core").Page): Promise<void>;
|
|
20
|
+
}
|
|
21
|
+
declare const _default: FunctionHelper;
|
|
22
|
+
export default _default;
|