@auxcode/auxta 0.2.7 → 0.2.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/package.json
CHANGED
|
@@ -12,7 +12,7 @@ import { startSuite } from '../utilities/start-suite.helper';
|
|
|
12
12
|
import { StatusOfStep } from "../enums/status-of.step";
|
|
13
13
|
import { UploadModel } from "../models/upload.model";
|
|
14
14
|
|
|
15
|
-
export async function onTestEnd(body: any, featureName: string, scenarioName: string, statusCode: number, screenshotBuffer
|
|
15
|
+
export async function onTestEnd(body: any, featureName: string, scenarioName: string, statusCode: number, screenshotBuffer?: Buffer, errMessage?: object) {
|
|
16
16
|
let isFinal: boolean = false;
|
|
17
17
|
if (process.env.ENVIRONMENT == "LIVE") {
|
|
18
18
|
console.log('asc ' + errMessage);
|
|
@@ -169,7 +169,7 @@ export async function getLastDayResults(): Promise<any> {
|
|
|
169
169
|
|
|
170
170
|
export async function postNotifications( body: UploadModel) {
|
|
171
171
|
let token = await auth();
|
|
172
|
-
await axios.post(`${config.auxtaURL}post-
|
|
172
|
+
await axios.post(`${config.auxtaURL}post-notification-after-run-background`, {
|
|
173
173
|
environmentName: body.environment,
|
|
174
174
|
digitalProductName: body.digitalProduct,
|
|
175
175
|
organizationName: body.organization,
|
|
@@ -180,7 +180,7 @@ export async function postNotifications( body: UploadModel) {
|
|
|
180
180
|
|
|
181
181
|
export async function postNotificationsOnFail( body: UploadModel) {
|
|
182
182
|
let token = await auth();
|
|
183
|
-
await axios.post(`${config.auxtaURL}post-
|
|
183
|
+
await axios.post(`${config.auxtaURL}post-notifications-after-case-fail-background`, {
|
|
184
184
|
environmentName: body.environment,
|
|
185
185
|
digitalProductName: body.digitalProduct,
|
|
186
186
|
organizationName: body.organization,
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import puppeteer from "../../puppeteer/puppeteer";
|
|
2
2
|
|
|
3
3
|
export async function captureScreenshot() {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
try{
|
|
5
|
+
const pages = await puppeteer.defaultPage.browser().pages();
|
|
6
|
+
if (!pages.length) return undefined;
|
|
7
|
+
const lastPage = pages[pages.length - 1] || puppeteer.defaultPage;
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
const screenshotBuffer = await lastPage.screenshot({
|
|
10
|
+
fullPage: true,
|
|
11
|
+
encoding: 'binary'
|
|
12
|
+
}
|
|
13
|
+
);
|
|
14
|
+
if (Buffer.isBuffer(screenshotBuffer))
|
|
15
|
+
return screenshotBuffer;
|
|
16
|
+
} catch (e){
|
|
17
|
+
}
|
|
18
|
+
return undefined
|
|
16
19
|
}
|
|
@@ -23,7 +23,7 @@ export class FunctionHelper {
|
|
|
23
23
|
await page.waitForTimeout(this.defaultTimeout);
|
|
24
24
|
const [linkHandlers] = await page.$x(`//${selector}[. = ${this.getEscapedText(text)}]`);
|
|
25
25
|
|
|
26
|
-
const message = `I click on the ${text} ${selector}`;
|
|
26
|
+
const message = `I click on the '${text}' '${selector}'`;
|
|
27
27
|
if (linkHandlers) {
|
|
28
28
|
log.push('Then', message, StatusOfStep.PASSED);
|
|
29
29
|
await linkHandlers.click();
|
|
@@ -35,7 +35,7 @@ export class FunctionHelper {
|
|
|
35
35
|
|
|
36
36
|
public async waitForSelectorWithText(selector: string, text: string, page = puppeteer.defaultPage) {
|
|
37
37
|
const linkHandlers = await page.$x(`//${selector}[. = ${this.getEscapedText(text)}]`);
|
|
38
|
-
const message = `I check for ${text}`;
|
|
38
|
+
const message = `I check for '${text}' on the current page`;
|
|
39
39
|
if (linkHandlers.length > 0) {
|
|
40
40
|
log.push('And', message, StatusOfStep.PASSED);
|
|
41
41
|
return true;
|
|
@@ -47,14 +47,20 @@ export class FunctionHelper {
|
|
|
47
47
|
|
|
48
48
|
public async goto(url: string, page = puppeteer.defaultPage) {
|
|
49
49
|
await page.goto(url);
|
|
50
|
-
log.push('Then', `I go to the ${url} page`, StatusOfStep.PASSED);
|
|
50
|
+
log.push('Then', `I go to the '${url}' page`, StatusOfStep.PASSED);
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
public async type(field: string, value: string, page = puppeteer.defaultPage) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
try{
|
|
55
|
+
await page.type(field, value);
|
|
56
|
+
let elementName = await page.$eval(field, (e) => e.textContent);
|
|
57
|
+
if (!elementName || elementName === ' ') elementName = field;
|
|
58
|
+
log.push('Then', `I type '${value}' into the '${elementName}' field`, StatusOfStep.PASSED);
|
|
59
|
+
} catch (e){
|
|
60
|
+
const msg = `I type '${value}' into the '${field}' field`
|
|
61
|
+
log.push('Then', msg, StatusOfStep.FAILED);
|
|
62
|
+
throw new Error(msg)
|
|
63
|
+
}
|
|
58
64
|
}
|
|
59
65
|
|
|
60
66
|
public async waitForNetwork(page = puppeteer.defaultPage) {
|
|
@@ -83,7 +89,7 @@ export class FunctionHelper {
|
|
|
83
89
|
*/
|
|
84
90
|
|
|
85
91
|
public async waitForSelector(option: string, selector: string, time: number = this.defaultTimeout, page = puppeteer.defaultPage) {
|
|
86
|
-
const message = `I check for the ${selector} element to be ${option}`;
|
|
92
|
+
const message = `I check for the '${selector}' element to be ${option}`;
|
|
87
93
|
try{
|
|
88
94
|
await page.waitForSelector(selector, {
|
|
89
95
|
[option]: true,
|
|
@@ -101,7 +107,7 @@ export class FunctionHelper {
|
|
|
101
107
|
let elementName = await puppeteer.defaultPage.$eval(className, (e) => e.textContent);
|
|
102
108
|
if (!elementName || elementName === ' ') elementName = className;
|
|
103
109
|
await page.click(className);
|
|
104
|
-
log.push('Then', `I click on ${elementName}`, StatusOfStep.PASSED);
|
|
110
|
+
log.push('Then', `I click on the '${elementName}'`, StatusOfStep.PASSED);
|
|
105
111
|
}
|
|
106
112
|
|
|
107
113
|
public async urlContains(selector: string) {
|
|
@@ -109,7 +115,7 @@ export class FunctionHelper {
|
|
|
109
115
|
let message = `I am on the ${selector} page`
|
|
110
116
|
if (!url.includes(selector)) {
|
|
111
117
|
log.push('And', message, StatusOfStep.FAILED);
|
|
112
|
-
throw new Error(`I am not at the ${selector} page`)
|
|
118
|
+
throw new Error(`I am not at the '${selector}' page`)
|
|
113
119
|
}
|
|
114
120
|
log.push('And', message, StatusOfStep.PASSED);
|
|
115
121
|
}
|
|
@@ -50,7 +50,7 @@ export class Puppeteer {
|
|
|
50
50
|
public async run(event: any, callback: any, featureName = 'Test feature', scenarioName = 'Test scenario', uploadModel?: UploadModel, close?: boolean) {
|
|
51
51
|
if (uploadModel === undefined) uploadModel = auxta.getUploadModel();
|
|
52
52
|
if (close === undefined) close = Puppeteer.setupHeader(event, uploadModel)
|
|
53
|
-
let screenshotBuffer: Buffer;
|
|
53
|
+
let screenshotBuffer: Buffer | undefined;
|
|
54
54
|
let errMessage: any;
|
|
55
55
|
let statusCode: number = 200;
|
|
56
56
|
|
|
@@ -66,7 +66,6 @@ export class Puppeteer {
|
|
|
66
66
|
.on('requestfailed', request =>
|
|
67
67
|
consoleStack.push(`${request.failure().errorText} ${request.url()}`))
|
|
68
68
|
await callback(event)
|
|
69
|
-
screenshotBuffer = await captureScreenshot();
|
|
70
69
|
log.push('When', `Finished puppeteer process`, StatusOfStep.PASSED);
|
|
71
70
|
} catch (err) {
|
|
72
71
|
console.log(`Error ${err}`);
|