@auxcode/auxta 1.3.15 → 1.3.17-beta.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/README.md +60 -60
- package/build/cjs/AuxTA.d.ts +57 -57
- package/build/cjs/AuxTA.js +148 -148
- package/build/cjs/auxta/configs/config.d.ts +51 -51
- package/build/cjs/auxta/configs/config.js +63 -63
- package/build/cjs/auxta/enums/status-of.step.d.ts +7 -7
- package/build/cjs/auxta/enums/status-of.step.js +11 -11
- package/build/cjs/auxta/helpers/response.helper.d.ts +10 -10
- package/build/cjs/auxta/helpers/response.helper.js +15 -15
- package/build/cjs/auxta/helpers/start.helper.d.ts +1 -1
- package/build/cjs/auxta/helpers/start.helper.js +26 -26
- package/build/cjs/auxta/hooks/report.hook.d.ts +14 -14
- package/build/cjs/auxta/hooks/report.hook.js +66 -66
- package/build/cjs/auxta/models/upload.model.d.ts +32 -32
- package/build/cjs/auxta/models/upload.model.js +75 -75
- package/build/cjs/auxta/services/log.service.d.ts +26 -26
- package/build/cjs/auxta/services/log.service.js +47 -47
- package/build/cjs/auxta/services/report.service.d.ts +36 -36
- package/build/cjs/auxta/services/report.service.js +164 -164
- package/build/cjs/auxta/services/runtime.service.d.ts +16 -16
- package/build/cjs/auxta/services/runtime.service.js +41 -41
- package/build/cjs/auxta/utilities/runtime.helper.d.ts +15 -15
- package/build/cjs/auxta/utilities/runtime.helper.js +19 -19
- package/build/cjs/auxta/utilities/screenshot.helper.d.ts +2 -2
- package/build/cjs/auxta/utilities/screenshot.helper.js +36 -36
- package/build/cjs/auxta/utilities/start-suite.helper.d.ts +17 -17
- package/build/cjs/auxta/utilities/start-suite.helper.js +31 -31
- package/build/cjs/macros/helpers/Aux2faAuth.d.ts +7 -7
- package/build/cjs/macros/helpers/Aux2faAuth.js +29 -29
- package/build/cjs/macros/helpers/code.helper.d.ts +23 -21
- package/build/cjs/macros/helpers/code.helper.js +166 -192
- package/build/cjs/macros/helpers/extend-default-page.d.ts +6 -6
- package/build/cjs/macros/helpers/extend-default-page.js +88 -88
- package/build/cjs/puppeteer/puppeteer.d.ts +25 -25
- package/build/cjs/puppeteer/puppeteer.js +200 -200
- package/build/esm/AuxTA.d.ts +57 -57
- package/build/esm/AuxTA.js +119 -119
- package/build/esm/auxta/configs/config.d.ts +51 -51
- package/build/esm/auxta/configs/config.js +58 -58
- package/build/esm/auxta/enums/status-of.step.d.ts +7 -7
- package/build/esm/auxta/enums/status-of.step.js +8 -8
- package/build/esm/auxta/helpers/response.helper.d.ts +10 -10
- package/build/esm/auxta/helpers/response.helper.js +11 -11
- package/build/esm/auxta/helpers/start.helper.d.ts +1 -1
- package/build/esm/auxta/helpers/start.helper.js +24 -24
- package/build/esm/auxta/hooks/report.hook.d.ts +14 -14
- package/build/esm/auxta/hooks/report.hook.js +58 -58
- package/build/esm/auxta/models/upload.model.d.ts +32 -32
- package/build/esm/auxta/models/upload.model.js +71 -71
- package/build/esm/auxta/services/log.service.d.ts +26 -26
- package/build/esm/auxta/services/log.service.js +43 -43
- package/build/esm/auxta/services/report.service.d.ts +36 -36
- package/build/esm/auxta/services/report.service.js +150 -150
- package/build/esm/auxta/services/runtime.service.d.ts +16 -16
- package/build/esm/auxta/services/runtime.service.js +37 -37
- package/build/esm/auxta/utilities/runtime.helper.d.ts +15 -15
- package/build/esm/auxta/utilities/runtime.helper.js +15 -15
- package/build/esm/auxta/utilities/screenshot.helper.d.ts +2 -2
- package/build/esm/auxta/utilities/screenshot.helper.js +29 -29
- package/build/esm/auxta/utilities/start-suite.helper.d.ts +17 -17
- package/build/esm/auxta/utilities/start-suite.helper.js +26 -26
- package/build/esm/macros/helpers/Aux2faAuth.d.ts +7 -7
- package/build/esm/macros/helpers/Aux2faAuth.js +25 -25
- package/build/esm/macros/helpers/code.helper.d.ts +23 -21
- package/build/esm/macros/helpers/code.helper.js +159 -185
- package/build/esm/macros/helpers/extend-default-page.d.ts +6 -6
- package/build/esm/macros/helpers/extend-default-page.js +81 -81
- package/build/esm/puppeteer/puppeteer.d.ts +25 -25
- package/build/esm/puppeteer/puppeteer.js +192 -192
- package/build/tsconfig-cjs.tsbuildinfo +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/package.json +29 -29
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
const twofactor = require("node-2fa");
|
|
2
|
-
export class Aux2faAuth {
|
|
3
|
-
authenticator() {
|
|
4
|
-
const aux2fe_secret = this.getSecret();
|
|
5
|
-
return twofactor.generateToken(aux2fe_secret).token;
|
|
6
|
-
}
|
|
7
|
-
verifyToken(token) {
|
|
8
|
-
const aux2fe_secret = this.getSecret();
|
|
9
|
-
const result = twofactor.verifyToken(aux2fe_secret, token);
|
|
10
|
-
if (result != null) {
|
|
11
|
-
if (result.delta == 0) {
|
|
12
|
-
return true;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
return false;
|
|
16
|
-
}
|
|
17
|
-
getSecret() {
|
|
18
|
-
const aux2fe_secret = process.env.aux2fe_secret;
|
|
19
|
-
if (!aux2fe_secret) {
|
|
20
|
-
throw new Error('No 2fe secret set');
|
|
21
|
-
}
|
|
22
|
-
return aux2fe_secret;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
export default new Aux2faAuth();
|
|
1
|
+
const twofactor = require("node-2fa");
|
|
2
|
+
export class Aux2faAuth {
|
|
3
|
+
authenticator() {
|
|
4
|
+
const aux2fe_secret = this.getSecret();
|
|
5
|
+
return twofactor.generateToken(aux2fe_secret).token;
|
|
6
|
+
}
|
|
7
|
+
verifyToken(token) {
|
|
8
|
+
const aux2fe_secret = this.getSecret();
|
|
9
|
+
const result = twofactor.verifyToken(aux2fe_secret, token);
|
|
10
|
+
if (result != null) {
|
|
11
|
+
if (result.delta == 0) {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
getSecret() {
|
|
18
|
+
const aux2fe_secret = process.env.aux2fe_secret;
|
|
19
|
+
if (!aux2fe_secret) {
|
|
20
|
+
throw new Error('No 2fe secret set');
|
|
21
|
+
}
|
|
22
|
+
return aux2fe_secret;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export default new Aux2faAuth();
|
|
@@ -1,21 +1,23 @@
|
|
|
1
|
-
import { StatusOfStep } from "../../auxta/enums/status-of.step";
|
|
2
|
-
import { ExtendDefaultPage } from "./extend-default-page";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
import { StatusOfStep } from "../../auxta/enums/status-of.step";
|
|
2
|
+
import { ExtendDefaultPage } from "./extend-default-page";
|
|
3
|
+
import { Page } from "puppeteer";
|
|
4
|
+
export declare class FunctionHelper extends ExtendDefaultPage {
|
|
5
|
+
log(keyword: string, name: string, status: StatusOfStep): void;
|
|
6
|
+
suggest(name: string): void;
|
|
7
|
+
private getEscapedText;
|
|
8
|
+
private waitClick;
|
|
9
|
+
clickByText(selector: string, text: string, dotOrText?: string, page?: Page, time?: number, log_message?: boolean): Promise<void>;
|
|
10
|
+
clickByTextWithClass(class_selector: string, class_name: string, selector: string, text: string, dotOrText?: string, page?: Page): Promise<void>;
|
|
11
|
+
waitForSelectorWithText(selector: string, text: string, dotOrText?: string, page?: Page): Promise<void>;
|
|
12
|
+
timeout(timeout?: number, page?: Page): Promise<void>;
|
|
13
|
+
waitForSelector(option: string, selector: string, time?: number, page?: Page, log_message?: boolean): Promise<void>;
|
|
14
|
+
urlContains(selector: string, page?: Page): Promise<void>;
|
|
15
|
+
pressEnter(page?: Page): Promise<void>;
|
|
16
|
+
emulate(phone_name: string, page?: Page): Promise<void>;
|
|
17
|
+
restartBrowser(): Promise<void>;
|
|
18
|
+
clickAndWaitForPageToBeCreated(selector: string, page?: Page): Promise<void>;
|
|
19
|
+
closeLastPage(page?: Page): Promise<void>;
|
|
20
|
+
microsoftLogin(button: string, email: string, password: string): Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
declare const _default: FunctionHelper;
|
|
23
|
+
export default _default;
|
|
@@ -1,185 +1,159 @@
|
|
|
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 { StepStatus } from "../../AuxTA";
|
|
14
|
-
import { ExtendDefaultPage } from "./extend-default-page";
|
|
15
|
-
import { KnownDevices } from "puppeteer";
|
|
16
|
-
export class FunctionHelper extends ExtendDefaultPage {
|
|
17
|
-
log(keyword, name, status) {
|
|
18
|
-
log.push(keyword, name, status);
|
|
19
|
-
}
|
|
20
|
-
suggest(name) {
|
|
21
|
-
log.addSuggestion(name);
|
|
22
|
-
}
|
|
23
|
-
getEscapedText(text) {
|
|
24
|
-
const splitedQuotes = text.replace(/'/g, `', "'", '`);
|
|
25
|
-
return `concat('${splitedQuotes}', '')`;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
clickByTextWithClass(class_selector, class_name, selector, text, dotOrText = '.', page = puppeteer.defaultPage) {
|
|
49
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
50
|
-
const message = `I click on the '${text}' '${selector}'`;
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
yield puppeteer.
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
yield
|
|
141
|
-
yield
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
const loginPage = pages[pages.length - 1];
|
|
161
|
-
yield this.extend_page_functions(loginPage);
|
|
162
|
-
yield loginPage.waitForNetworkIdle();
|
|
163
|
-
yield this.waitForSelector('visible', next_button, 60000, loginPage);
|
|
164
|
-
yield loginPage.type(email_input, email);
|
|
165
|
-
yield loginPage.keyboard.press('Enter');
|
|
166
|
-
yield loginPage.waitForNetworkIdle();
|
|
167
|
-
yield this.waitForSelector('visible', sign_in_button, 60000, loginPage);
|
|
168
|
-
yield this.waitForSelector('visible', password_input, 6000, loginPage);
|
|
169
|
-
try {
|
|
170
|
-
(_a = (yield loginPage.$(password_input))) === null || _a === void 0 ? void 0 : _a.type(password);
|
|
171
|
-
yield this.log('Then', `I type password into the ${password_input}`, StepStatus.PASSED);
|
|
172
|
-
}
|
|
173
|
-
catch (e) {
|
|
174
|
-
yield this.log('Then', `I type password into the ${password_input}`, StepStatus.FAILED);
|
|
175
|
-
throw new Error(`I type password into the ${password_input}`);
|
|
176
|
-
}
|
|
177
|
-
yield this.timeout(3000);
|
|
178
|
-
yield loginPage.keyboard.press('Enter');
|
|
179
|
-
yield this.waitForSelector('visible', no_button, 60000, loginPage);
|
|
180
|
-
yield loginPage.keyboard.press('Enter');
|
|
181
|
-
yield loginPage.waitForNetworkIdle();
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
export default new FunctionHelper();
|
|
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 { StepStatus } from "../../AuxTA";
|
|
14
|
+
import { ExtendDefaultPage } from "./extend-default-page";
|
|
15
|
+
import { KnownDevices } from "puppeteer";
|
|
16
|
+
export class FunctionHelper extends ExtendDefaultPage {
|
|
17
|
+
log(keyword, name, status) {
|
|
18
|
+
log.push(keyword, name, status);
|
|
19
|
+
}
|
|
20
|
+
suggest(name) {
|
|
21
|
+
log.addSuggestion(name);
|
|
22
|
+
}
|
|
23
|
+
getEscapedText(text) {
|
|
24
|
+
const splitedQuotes = text.replace(/'/g, `', "'", '`);
|
|
25
|
+
return `concat('${splitedQuotes}', '')`;
|
|
26
|
+
}
|
|
27
|
+
waitClick(message, xPath, page) {
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
const findElement = yield page.waitForXPath(xPath, { visible: true, timeout: this.defaultTimeout });
|
|
30
|
+
if (findElement) {
|
|
31
|
+
const linkHandlers = yield page.$x(xPath);
|
|
32
|
+
yield linkHandlers.click();
|
|
33
|
+
log.push('Then', message, StatusOfStep.PASSED);
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
log.push('Then', message + ", but it didn't appear in ${time / 1000}", StatusOfStep.FAILED);
|
|
37
|
+
throw Error(message + ", but it didn't appear in ${time / 1000}");
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
clickByText(selector, text, dotOrText = '.', page = puppeteer.defaultPage, time = this.defaultTimeout, log_message = true) {
|
|
42
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
const message = `I clicked on the '${text}' '${selector}'`;
|
|
44
|
+
const xPath = `//${selector}[contains(${dotOrText},"${text}")]`;
|
|
45
|
+
yield this.waitClick(message, xPath, page);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
clickByTextWithClass(class_selector, class_name, selector, text, dotOrText = '.', page = puppeteer.defaultPage) {
|
|
49
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
50
|
+
const message = `I click on the '${text}' '${selector}'`;
|
|
51
|
+
const xPath = `//${class_selector}[contains(@class,${this.getEscapedText(class_name)})]//${selector}[contains(${dotOrText},"${text}")]`;
|
|
52
|
+
yield this.waitClick(message, xPath, page);
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
waitForSelectorWithText(selector, text, dotOrText = '.', page = puppeteer.defaultPage) {
|
|
56
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
+
const message = `I check for '${text}' on the current page`;
|
|
58
|
+
const xPath = `//${selector}[contains(${dotOrText},"${text}")]`;
|
|
59
|
+
yield this.waitClick(message, xPath, page);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
timeout(timeout = this.defaultTimeout, page = puppeteer.defaultPage) {
|
|
63
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
64
|
+
yield page.waitForTimeout(timeout);
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
waitForSelector(option, selector, time = this.defaultTimeout, page = puppeteer.defaultPage, log_message = true) {
|
|
68
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
69
|
+
const message = `I checked for the '${selector}' element to be ${option}`;
|
|
70
|
+
const findSelector = yield page.waitForSelector(selector, {
|
|
71
|
+
[option]: true,
|
|
72
|
+
timeout: time
|
|
73
|
+
});
|
|
74
|
+
if (findSelector) {
|
|
75
|
+
log.push('And', message, StatusOfStep.PASSED);
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
log.push('And', `${message}, but it didn't appear in ${time / 1000} seconds.`, StatusOfStep.FAILED);
|
|
79
|
+
throw Error(`${message}, but it didn't appear in ${time / 1000} seconds.`);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
urlContains(selector, page = puppeteer.defaultPage) {
|
|
84
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
85
|
+
const url = page.url();
|
|
86
|
+
let message = `I am on the ${selector} page`;
|
|
87
|
+
if (!url.includes(selector)) {
|
|
88
|
+
log.push('And', message, StatusOfStep.FAILED);
|
|
89
|
+
throw new Error(message);
|
|
90
|
+
}
|
|
91
|
+
log.push('And', message, StatusOfStep.PASSED);
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
pressEnter(page = puppeteer.defaultPage) {
|
|
95
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
96
|
+
yield page.keyboard.press('Enter');
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
emulate(phone_name, page = puppeteer.defaultPage) {
|
|
100
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
101
|
+
const phone = KnownDevices[phone_name];
|
|
102
|
+
yield page.emulate(phone);
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
restartBrowser() {
|
|
106
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
107
|
+
yield puppeteer.close();
|
|
108
|
+
yield puppeteer.startBrowser();
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
clickAndWaitForPageToBeCreated(selector, page = puppeteer.defaultPage) {
|
|
112
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
113
|
+
const nav = new Promise(res => page.browser().on('targetcreated', res));
|
|
114
|
+
yield page.click(selector);
|
|
115
|
+
yield nav;
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
closeLastPage(page = puppeteer.defaultPage) {
|
|
119
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
120
|
+
const pages = yield page.browser().pages();
|
|
121
|
+
yield pages[pages.length - 1].close();
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
microsoftLogin(button, email, password) {
|
|
125
|
+
var _a;
|
|
126
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
127
|
+
const email_input = 'input[type="email"]';
|
|
128
|
+
const password_input = 'input[type="password"]';
|
|
129
|
+
const next_button = 'input[value="Next"]';
|
|
130
|
+
const sign_in_button = 'input[value="Sign in"]';
|
|
131
|
+
const no_button = 'input.ext-secondary';
|
|
132
|
+
yield this.clickAndWaitForPageToBeCreated(button);
|
|
133
|
+
const pages = yield puppeteer.defaultPage.browser().pages();
|
|
134
|
+
const loginPage = pages[pages.length - 1];
|
|
135
|
+
yield this.extend_page_functions(loginPage);
|
|
136
|
+
yield loginPage.waitForNetworkIdle();
|
|
137
|
+
yield this.waitForSelector('visible', next_button, 60000, loginPage);
|
|
138
|
+
yield loginPage.type(email_input, email);
|
|
139
|
+
yield loginPage.keyboard.press('Enter');
|
|
140
|
+
yield loginPage.waitForNetworkIdle();
|
|
141
|
+
yield this.waitForSelector('visible', sign_in_button, 60000, loginPage);
|
|
142
|
+
yield this.waitForSelector('visible', password_input, 6000, loginPage);
|
|
143
|
+
try {
|
|
144
|
+
(_a = (yield loginPage.$(password_input))) === null || _a === void 0 ? void 0 : _a.type(password);
|
|
145
|
+
yield this.log('Then', `I type password into the ${password_input}`, StepStatus.PASSED);
|
|
146
|
+
}
|
|
147
|
+
catch (e) {
|
|
148
|
+
yield this.log('Then', `I type password into the ${password_input}`, StepStatus.FAILED);
|
|
149
|
+
throw new Error(`I type password into the ${password_input}`);
|
|
150
|
+
}
|
|
151
|
+
yield this.timeout(3000);
|
|
152
|
+
yield loginPage.keyboard.press('Enter');
|
|
153
|
+
yield this.waitForSelector('visible', no_button, 60000, loginPage);
|
|
154
|
+
yield loginPage.keyboard.press('Enter');
|
|
155
|
+
yield loginPage.waitForNetworkIdle();
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
export default new FunctionHelper();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export declare class ExtendDefaultPage {
|
|
2
|
-
readonly defaultTimeout: number;
|
|
3
|
-
extend_page_functions(page: any, time?: number): Promise<any>;
|
|
4
|
-
}
|
|
5
|
-
declare const _default: ExtendDefaultPage;
|
|
6
|
-
export default _default;
|
|
1
|
+
export declare class ExtendDefaultPage {
|
|
2
|
+
readonly defaultTimeout: number;
|
|
3
|
+
extend_page_functions(page: any, time?: number): Promise<any>;
|
|
4
|
+
}
|
|
5
|
+
declare const _default: ExtendDefaultPage;
|
|
6
|
+
export default _default;
|
|
@@ -1,81 +1,81 @@
|
|
|
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 { StatusOfStep } from "../../auxta/enums/status-of.step";
|
|
12
|
-
import { config } from "../../auxta/configs/config";
|
|
13
|
-
export class ExtendDefaultPage {
|
|
14
|
-
constructor() {
|
|
15
|
-
this.defaultTimeout = config.timeout;
|
|
16
|
-
}
|
|
17
|
-
extend_page_functions(page, time = this.defaultTimeout) {
|
|
18
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
-
const { goto: original_goto, click: original_click, type: original_type, waitForNetworkIdle: original_waitForNetworkIdle } = page;
|
|
20
|
-
page.goto = function goto(url, options) {
|
|
21
|
-
log.push('Then', `I go to the '${url}' page`, StatusOfStep.PASSED);
|
|
22
|
-
return original_goto.apply(page, arguments);
|
|
23
|
-
};
|
|
24
|
-
page.click = function click(selector, options) {
|
|
25
|
-
return __awaiter(this, arguments, void 0, function* () {
|
|
26
|
-
try {
|
|
27
|
-
yield page.waitForSelector(selector, {
|
|
28
|
-
timeout: time
|
|
29
|
-
});
|
|
30
|
-
let elementName = yield page.$eval(selector, (e) => e.textContent);
|
|
31
|
-
if (!elementName || elementName === ' ')
|
|
32
|
-
elementName = selector;
|
|
33
|
-
yield original_click.apply(page, arguments);
|
|
34
|
-
log.push('Then', `I click on the '${elementName}'`, StatusOfStep.PASSED);
|
|
35
|
-
}
|
|
36
|
-
catch (e) {
|
|
37
|
-
const msg = `I click on the '${selector}'`;
|
|
38
|
-
log.push('Then', msg, StatusOfStep.FAILED);
|
|
39
|
-
throw new Error(msg);
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
};
|
|
43
|
-
page.waitForNetworkIdle = function waitForNetworkIdle(selector, option) {
|
|
44
|
-
return __awaiter(this, arguments, void 0, function* () {
|
|
45
|
-
let message = 'I wait for the page to load';
|
|
46
|
-
let result;
|
|
47
|
-
try {
|
|
48
|
-
result = yield original_waitForNetworkIdle.apply(page, arguments);
|
|
49
|
-
log.push('Then', message, StatusOfStep.PASSED);
|
|
50
|
-
}
|
|
51
|
-
catch (e) {
|
|
52
|
-
log.push('Then', message, StatusOfStep.FAILED);
|
|
53
|
-
throw new Error(message);
|
|
54
|
-
}
|
|
55
|
-
return result;
|
|
56
|
-
});
|
|
57
|
-
};
|
|
58
|
-
page.type = function type(field, value) {
|
|
59
|
-
return __awaiter(this, arguments, void 0, function* () {
|
|
60
|
-
try {
|
|
61
|
-
yield page.waitForSelector(field, {
|
|
62
|
-
timeout: time
|
|
63
|
-
});
|
|
64
|
-
yield original_type.apply(page, arguments);
|
|
65
|
-
let elementName = yield page.$eval(field, (e) => e.textContent);
|
|
66
|
-
if (!elementName || elementName === ' ')
|
|
67
|
-
elementName = field;
|
|
68
|
-
log.push('Then', `I type '${value}' into the '${elementName}' field`, StatusOfStep.PASSED);
|
|
69
|
-
}
|
|
70
|
-
catch (e) {
|
|
71
|
-
const msg = `I type '${value}' into the '${field}' field`;
|
|
72
|
-
log.push('Then', msg, StatusOfStep.FAILED);
|
|
73
|
-
throw new Error(msg);
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
};
|
|
77
|
-
return page;
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
export default new ExtendDefaultPage();
|
|
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 { StatusOfStep } from "../../auxta/enums/status-of.step";
|
|
12
|
+
import { config } from "../../auxta/configs/config";
|
|
13
|
+
export class ExtendDefaultPage {
|
|
14
|
+
constructor() {
|
|
15
|
+
this.defaultTimeout = config.timeout;
|
|
16
|
+
}
|
|
17
|
+
extend_page_functions(page, time = this.defaultTimeout) {
|
|
18
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
const { goto: original_goto, click: original_click, type: original_type, waitForNetworkIdle: original_waitForNetworkIdle } = page;
|
|
20
|
+
page.goto = function goto(url, options) {
|
|
21
|
+
log.push('Then', `I go to the '${url}' page`, StatusOfStep.PASSED);
|
|
22
|
+
return original_goto.apply(page, arguments);
|
|
23
|
+
};
|
|
24
|
+
page.click = function click(selector, options) {
|
|
25
|
+
return __awaiter(this, arguments, void 0, function* () {
|
|
26
|
+
try {
|
|
27
|
+
yield page.waitForSelector(selector, {
|
|
28
|
+
timeout: time
|
|
29
|
+
});
|
|
30
|
+
let elementName = yield page.$eval(selector, (e) => e.textContent);
|
|
31
|
+
if (!elementName || elementName === ' ')
|
|
32
|
+
elementName = selector;
|
|
33
|
+
yield original_click.apply(page, arguments);
|
|
34
|
+
log.push('Then', `I click on the '${elementName}'`, StatusOfStep.PASSED);
|
|
35
|
+
}
|
|
36
|
+
catch (e) {
|
|
37
|
+
const msg = `I click on the '${selector}'`;
|
|
38
|
+
log.push('Then', msg, StatusOfStep.FAILED);
|
|
39
|
+
throw new Error(msg);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
page.waitForNetworkIdle = function waitForNetworkIdle(selector, option) {
|
|
44
|
+
return __awaiter(this, arguments, void 0, function* () {
|
|
45
|
+
let message = 'I wait for the page to load';
|
|
46
|
+
let result;
|
|
47
|
+
try {
|
|
48
|
+
result = yield original_waitForNetworkIdle.apply(page, arguments);
|
|
49
|
+
log.push('Then', message, StatusOfStep.PASSED);
|
|
50
|
+
}
|
|
51
|
+
catch (e) {
|
|
52
|
+
log.push('Then', message, StatusOfStep.FAILED);
|
|
53
|
+
throw new Error(message);
|
|
54
|
+
}
|
|
55
|
+
return result;
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
page.type = function type(field, value) {
|
|
59
|
+
return __awaiter(this, arguments, void 0, function* () {
|
|
60
|
+
try {
|
|
61
|
+
yield page.waitForSelector(field, {
|
|
62
|
+
timeout: time
|
|
63
|
+
});
|
|
64
|
+
yield original_type.apply(page, arguments);
|
|
65
|
+
let elementName = yield page.$eval(field, (e) => e.textContent);
|
|
66
|
+
if (!elementName || elementName === ' ')
|
|
67
|
+
elementName = field;
|
|
68
|
+
log.push('Then', `I type '${value}' into the '${elementName}' field`, StatusOfStep.PASSED);
|
|
69
|
+
}
|
|
70
|
+
catch (e) {
|
|
71
|
+
const msg = `I type '${value}' into the '${field}' field`;
|
|
72
|
+
log.push('Then', msg, StatusOfStep.FAILED);
|
|
73
|
+
throw new Error(msg);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
return page;
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
export default new ExtendDefaultPage();
|