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