@auxcode/auxta 0.6.6 → 0.7.0
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/tsconfig-cjs.tsbuildinfo +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -5
- package/build/AuxTA.d.ts +0 -43
- package/build/AuxTA.js +0 -112
- package/build/auxta/configs/config.d.ts +0 -51
- package/build/auxta/configs/config.js +0 -61
- package/build/auxta/enums/status-of.step.d.ts +0 -7
- package/build/auxta/enums/status-of.step.js +0 -8
- package/build/auxta/helpers/response.helper.d.ts +0 -10
- package/build/auxta/helpers/response.helper.js +0 -11
- package/build/auxta/helpers/start.helper.d.ts +0 -1
- package/build/auxta/helpers/start.helper.js +0 -24
- package/build/auxta/hooks/report.hook.d.ts +0 -4
- package/build/auxta/hooks/report.hook.js +0 -58
- package/build/auxta/models/upload.model.d.ts +0 -20
- package/build/auxta/models/upload.model.js +0 -43
- package/build/auxta/services/log.service.d.ts +0 -26
- package/build/auxta/services/log.service.js +0 -43
- package/build/auxta/services/report.service.d.ts +0 -36
- package/build/auxta/services/report.service.js +0 -148
- package/build/auxta/services/runtime.service.d.ts +0 -16
- package/build/auxta/services/runtime.service.js +0 -37
- package/build/auxta/utilities/runtime.helper.d.ts +0 -15
- package/build/auxta/utilities/runtime.helper.js +0 -15
- package/build/auxta/utilities/screenshot.helper.d.ts +0 -2
- package/build/auxta/utilities/screenshot.helper.js +0 -29
- package/build/auxta/utilities/start-suite.helper.d.ts +0 -1
- package/build/auxta/utilities/start-suite.helper.js +0 -25
- package/build/macros/helpers/code.helper.d.ts +0 -22
- package/build/macros/helpers/code.helper.js +0 -193
- package/build/puppeteer/puppeteer.d.ts +0 -13
- package/build/puppeteer/puppeteer.js +0 -153
|
@@ -1,193 +0,0 @@
|
|
|
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
|
-
};
|
|
10
|
-
import log from "../../auxta/services/log.service";
|
|
11
|
-
import puppeteer from "../../puppeteer/puppeteer";
|
|
12
|
-
import { StatusOfStep } from "../../auxta/enums/status-of.step";
|
|
13
|
-
import { config } from "../../auxta/configs/config";
|
|
14
|
-
export class FunctionHelper {
|
|
15
|
-
constructor() {
|
|
16
|
-
this.defaultTimeout = config.timeout;
|
|
17
|
-
}
|
|
18
|
-
log(keyword, name, status) {
|
|
19
|
-
log.push(keyword, name, status);
|
|
20
|
-
}
|
|
21
|
-
suggest(name) {
|
|
22
|
-
log.addSuggestion(name);
|
|
23
|
-
}
|
|
24
|
-
getEscapedText(text) {
|
|
25
|
-
const splitedQuotes = text.replace(/'/g, `', "'", '`);
|
|
26
|
-
return `concat('${splitedQuotes}', '')`;
|
|
27
|
-
}
|
|
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
|
-
}
|
|
41
|
-
log.push('Then', message, StatusOfStep.FAILED);
|
|
42
|
-
throw new Error(message);
|
|
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
|
-
}
|
|
55
|
-
}
|
|
56
|
-
catch (e) {
|
|
57
|
-
}
|
|
58
|
-
log.push('Then', message, StatusOfStep.FAILED);
|
|
59
|
-
throw new Error(message);
|
|
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
|
-
}
|
|
77
|
-
log.push('And', message, StatusOfStep.FAILED);
|
|
78
|
-
throw new Error(message);
|
|
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
|
-
});
|
|
105
|
-
}
|
|
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
|
-
});
|
|
162
|
-
}
|
|
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
|
-
});
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
export default new FunctionHelper();
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { UploadModel } from "../auxta/models/upload.model";
|
|
2
|
-
import puppeteer_core from 'puppeteer-core';
|
|
3
|
-
export declare class Puppeteer {
|
|
4
|
-
defaultPage: puppeteer_core.Page;
|
|
5
|
-
private browser;
|
|
6
|
-
startBrowser(): Promise<void>;
|
|
7
|
-
close(): Promise<void>;
|
|
8
|
-
run(event: any, callback: any, featureName?: string, scenarioName?: string, uploadModel?: UploadModel, close?: boolean): Promise<void>;
|
|
9
|
-
runRPA(event: any, callback: any, close?: boolean): Promise<any>;
|
|
10
|
-
private static setupHeader;
|
|
11
|
-
}
|
|
12
|
-
declare const _default: Puppeteer;
|
|
13
|
-
export default _default;
|
|
@@ -1,153 +0,0 @@
|
|
|
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
|
-
};
|
|
10
|
-
import chromium from 'chrome-aws-lambda';
|
|
11
|
-
import log from "../auxta/services/log.service";
|
|
12
|
-
import { captureScreenshot } from "../auxta/utilities/screenshot.helper";
|
|
13
|
-
import { onTestEnd } from "../auxta/hooks/report.hook";
|
|
14
|
-
import auxta from "../AuxTA";
|
|
15
|
-
import { StatusOfStep } from "../auxta/enums/status-of.step";
|
|
16
|
-
import { config } from "./../auxta/configs/config";
|
|
17
|
-
import { postNotificationsOnFail } from "../auxta/services/report.service";
|
|
18
|
-
export class Puppeteer {
|
|
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 : yield chromium.executablePath,
|
|
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();
|
|
43
|
-
});
|
|
44
|
-
}
|
|
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
|
-
});
|
|
53
|
-
}
|
|
54
|
-
run(event, callback, featureName = 'Test feature', scenarioName = 'Test scenario', uploadModel, close) {
|
|
55
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
56
|
-
try {
|
|
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
|
-
});
|
|
91
|
-
}
|
|
92
|
-
catch (e) {
|
|
93
|
-
console.log("Lib error:", e);
|
|
94
|
-
}
|
|
95
|
-
finally {
|
|
96
|
-
log.clear();
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
}
|
|
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);
|
|
122
|
-
}
|
|
123
|
-
catch (err) {
|
|
124
|
-
errMessage = err;
|
|
125
|
-
log.push('When', `Finished puppeteer process`, StatusOfStep.FAILED);
|
|
126
|
-
return errMessage;
|
|
127
|
-
}
|
|
128
|
-
if (close)
|
|
129
|
-
yield this.close();
|
|
130
|
-
}
|
|
131
|
-
catch (e) {
|
|
132
|
-
console.log("Lib error:", e);
|
|
133
|
-
}
|
|
134
|
-
finally {
|
|
135
|
-
log.clear();
|
|
136
|
-
}
|
|
137
|
-
return true;
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
static setupHeader(event, uploadModel) {
|
|
141
|
-
let close = true;
|
|
142
|
-
if (process.env.ENVIRONMENT !== 'LOCAL' && event.body) {
|
|
143
|
-
const body = JSON.parse(event.body);
|
|
144
|
-
uploadModel.reportId = body.reportId;
|
|
145
|
-
uploadModel.nextSuites = body.nextSuites;
|
|
146
|
-
}
|
|
147
|
-
else if (event.queryStringParameters.close) {
|
|
148
|
-
close = event.queryStringParameters.close === "true";
|
|
149
|
-
}
|
|
150
|
-
return close;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
export default new Puppeteer();
|