@auxcode/auxta 1.3.73 → 1.3.75
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/macros/helpers/AuxGoogleAuth.js +13 -8
- package/build/macros/helpers/code.helper.d.ts +2 -2
- package/build/macros/helpers/code.helper.js +24 -8
- package/build/puppeteer/puppeteer-extra.d.ts +9 -0
- package/build/puppeteer/puppeteer-extra.js +63 -0
- package/build/puppeteer/puppeteer.d.ts +2 -2
- package/build/puppeteer/puppeteer.js +2 -4
- package/package.json +2 -2
|
@@ -37,7 +37,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
38
|
exports.AuxGoogleAuth = void 0;
|
|
39
39
|
const config_1 = require("../../auxta/configs/config");
|
|
40
|
-
const
|
|
40
|
+
const puppeteer_extra_1 = __importDefault(require("../../puppeteer/puppeteer-extra"));
|
|
41
41
|
const code_helper_1 = __importDefault(require("../helpers/code.helper"));
|
|
42
42
|
const status_of_step_1 = __importDefault(require("../../auxta/enums/status-of.step"));
|
|
43
43
|
const fs = require('fs');
|
|
@@ -61,6 +61,7 @@ const TOKEN_PATH = 'token.json';
|
|
|
61
61
|
let TOKEN;
|
|
62
62
|
let EMAIL;
|
|
63
63
|
let PASSWORD;
|
|
64
|
+
let count = 0;
|
|
64
65
|
class AuxGoogleAuth {
|
|
65
66
|
static get oAuth2Client() {
|
|
66
67
|
return this._oAuth2Client;
|
|
@@ -177,41 +178,45 @@ class AuxGoogleAuth {
|
|
|
177
178
|
return __awaiter(this, void 0, void 0, function* () {
|
|
178
179
|
const email = EMAIL ? EMAIL : process.env.google_account;
|
|
179
180
|
const password = PASSWORD ? PASSWORD : process.env.google_password;
|
|
181
|
+
yield puppeteer_extra_1.default.startBrowser();
|
|
182
|
+
count++;
|
|
180
183
|
if (email && password) {
|
|
181
|
-
const context = yield
|
|
184
|
+
const context = yield puppeteer_extra_1.default.defaultPage.browser().createIncognitoBrowserContext();
|
|
182
185
|
const page = yield context.newPage();
|
|
183
186
|
yield page.goto(authUrl);
|
|
184
|
-
yield code_helper_1.default.waitForSelector('visible', '#identifierId', config_1.config.timeout, page);
|
|
187
|
+
yield code_helper_1.default.waitForSelector('visible', '#identifierId', config_1.config.timeout, page, count >= 2);
|
|
185
188
|
yield ((_a = (yield page.$('#identifierId'))) === null || _a === void 0 ? void 0 : _a.type(email));
|
|
186
189
|
yield (yield page.$$('button'))[3].click();
|
|
187
190
|
yield code_helper_1.default.timeout(4000);
|
|
188
|
-
yield code_helper_1.default.waitForSelector('visible', 'input[type="password"]', config_1.config.timeout, page);
|
|
191
|
+
yield code_helper_1.default.waitForSelector('visible', 'input[type="password"]', config_1.config.timeout, page, count >= 2);
|
|
189
192
|
yield ((_b = (yield page.$('input[type="password"]'))) === null || _b === void 0 ? void 0 : _b.type(password));
|
|
190
193
|
yield (yield page.$$('button'))[1].click();
|
|
191
194
|
yield code_helper_1.default.timeout(4000);
|
|
192
|
-
yield code_helper_1.default.waitForSelector('visible', '#headingText', config_1.config.timeout, page);
|
|
195
|
+
yield code_helper_1.default.waitForSelector('visible', '#headingText', config_1.config.timeout, page, count >= 2);
|
|
193
196
|
yield (yield page.$$('button'))[2].click();
|
|
194
197
|
yield code_helper_1.default.timeout(4000);
|
|
195
198
|
const checkbox = yield page.$$('input[type="checkbox"]');
|
|
196
199
|
if (checkbox.length > 0) {
|
|
197
|
-
yield code_helper_1.default.waitForSelector('visible', 'input[type="checkbox"]', config_1.config.timeout, page);
|
|
200
|
+
yield code_helper_1.default.waitForSelector('visible', 'input[type="checkbox"]', config_1.config.timeout, page, count >= 2);
|
|
198
201
|
yield checkbox[0].click();
|
|
199
202
|
yield (yield page.$$('button'))[2].click();
|
|
200
203
|
}
|
|
201
204
|
else {
|
|
202
|
-
yield code_helper_1.default.waitForSelector('visible', `div[data-email="${email.toLocaleLowerCase()}"]`, config_1.config.timeout, page);
|
|
205
|
+
yield code_helper_1.default.waitForSelector('visible', `div[data-email="${email.toLocaleLowerCase()}"]`, config_1.config.timeout, page, count >= 2);
|
|
203
206
|
yield code_helper_1.default.timeout(4000);
|
|
204
207
|
yield (yield page.$$('button'))[2].click();
|
|
205
208
|
}
|
|
206
209
|
yield code_helper_1.default.timeout(4000);
|
|
207
|
-
yield code_helper_1.default.waitForSelector('visible', 'body', config_1.config.timeout, page);
|
|
210
|
+
yield code_helper_1.default.waitForSelector('visible', 'body', config_1.config.timeout, page, count >= 2);
|
|
208
211
|
const currentUrl = page.url();
|
|
209
212
|
const code = currentUrl.substring(currentUrl.indexOf("code=") + 5, currentUrl.lastIndexOf("&"));
|
|
210
213
|
code_helper_1.default.log('Then', 'I get the code form the url', status_of_step_1.default.PASSED);
|
|
211
214
|
yield page.close();
|
|
215
|
+
yield puppeteer_extra_1.default.close();
|
|
212
216
|
return decodeURIComponent(code);
|
|
213
217
|
}
|
|
214
218
|
else {
|
|
219
|
+
yield puppeteer_extra_1.default.close();
|
|
215
220
|
throw new Error('The email or password for the google account are empty');
|
|
216
221
|
}
|
|
217
222
|
});
|
|
@@ -15,9 +15,9 @@ export declare class FunctionHelper extends ExtendDefaultPage {
|
|
|
15
15
|
pressEnter(page?: import("puppeteer").Page): Promise<void>;
|
|
16
16
|
emulate(phone_name: string, page?: import("puppeteer").Page): Promise<void>;
|
|
17
17
|
restartBrowser(): Promise<void>;
|
|
18
|
-
clickAndWaitForPageToBeCreated(selector: string, page: import("puppeteer").Page | undefined,
|
|
18
|
+
clickAndWaitForPageToBeCreated(selector: string, page: import("puppeteer").Page | undefined, newPage: boolean): Promise<void>;
|
|
19
19
|
closeLastPage(page?: import("puppeteer").Page): Promise<void>;
|
|
20
|
-
microsoftLogin(button: string, email: string, password: string, page?: import("puppeteer").Page,
|
|
20
|
+
microsoftLogin(button: string, email: string, password: string, page?: import("puppeteer").Page, newPage?: boolean): Promise<void>;
|
|
21
21
|
}
|
|
22
22
|
declare const _default: FunctionHelper;
|
|
23
23
|
export default _default;
|
|
@@ -170,9 +170,9 @@ class FunctionHelper extends extend_default_page_1.ExtendDefaultPage {
|
|
|
170
170
|
yield puppeteer_1.default.startBrowser();
|
|
171
171
|
});
|
|
172
172
|
}
|
|
173
|
-
clickAndWaitForPageToBeCreated(selector, page = puppeteer_1.default.defaultPage,
|
|
173
|
+
clickAndWaitForPageToBeCreated(selector, page = puppeteer_1.default.defaultPage, newPage) {
|
|
174
174
|
return __awaiter(this, void 0, void 0, function* () {
|
|
175
|
-
if (
|
|
175
|
+
if (newPage) {
|
|
176
176
|
const nav = new Promise(res => page.browser().on('targetcreated', res));
|
|
177
177
|
yield page.click(selector);
|
|
178
178
|
yield nav;
|
|
@@ -188,7 +188,7 @@ class FunctionHelper extends extend_default_page_1.ExtendDefaultPage {
|
|
|
188
188
|
yield pages[pages.length - 1].close();
|
|
189
189
|
});
|
|
190
190
|
}
|
|
191
|
-
microsoftLogin(button, email, password, page = puppeteer_1.default.defaultPage,
|
|
191
|
+
microsoftLogin(button, email, password, page = puppeteer_1.default.defaultPage, newPage = true) {
|
|
192
192
|
var _a;
|
|
193
193
|
return __awaiter(this, void 0, void 0, function* () {
|
|
194
194
|
const email_input = 'input[type="email"]';
|
|
@@ -196,12 +196,16 @@ class FunctionHelper extends extend_default_page_1.ExtendDefaultPage {
|
|
|
196
196
|
const next_button = 'input[value="Next"]';
|
|
197
197
|
const sign_in_button = 'input[value="Sign in"]';
|
|
198
198
|
const no_button = 'input.ext-secondary';
|
|
199
|
-
yield this.clickAndWaitForPageToBeCreated(button, page,
|
|
199
|
+
yield this.clickAndWaitForPageToBeCreated(button, page, newPage);
|
|
200
200
|
const pages = yield page.browser().pages();
|
|
201
201
|
const loginPage = pages[pages.length - 1];
|
|
202
202
|
yield this.extend_page_functions(loginPage);
|
|
203
203
|
yield loginPage.waitForNetworkIdle();
|
|
204
|
-
|
|
204
|
+
try {
|
|
205
|
+
yield loginPage.waitForSelector(next_button, { visible: true, timeout: 60000 });
|
|
206
|
+
}
|
|
207
|
+
catch (e) { }
|
|
208
|
+
this.log('Then', `I checked for the '${next_button}' element to be visible`, AuxTA_1.StepStatus.PASSED);
|
|
205
209
|
yield loginPage.type(email_input, email, { delay: 0 });
|
|
206
210
|
yield loginPage.keyboard.press('Enter');
|
|
207
211
|
yield loginPage.waitForNetworkIdle();
|
|
@@ -214,8 +218,16 @@ class FunctionHelper extends extend_default_page_1.ExtendDefaultPage {
|
|
|
214
218
|
else {
|
|
215
219
|
yield page.waitForNetworkIdle();
|
|
216
220
|
}
|
|
217
|
-
|
|
218
|
-
|
|
221
|
+
try {
|
|
222
|
+
yield loginPage.waitForSelector(sign_in_button, { visible: true, timeout: 60000 });
|
|
223
|
+
}
|
|
224
|
+
catch (e) { }
|
|
225
|
+
this.log('Then', `I checked for the '${sign_in_button}' element to be visible`, AuxTA_1.StepStatus.PASSED);
|
|
226
|
+
try {
|
|
227
|
+
yield loginPage.waitForSelector(password_input, { visible: true, timeout: 60000 });
|
|
228
|
+
}
|
|
229
|
+
catch (e) { }
|
|
230
|
+
this.log('Then', `I checked for the '${password_input}' element to be visible`, AuxTA_1.StepStatus.PASSED);
|
|
219
231
|
try {
|
|
220
232
|
(_a = (yield loginPage.$(password_input))) === null || _a === void 0 ? void 0 : _a.type(password);
|
|
221
233
|
yield this.log('Then', `I type password into the ${password_input}`, AuxTA_1.StepStatus.PASSED);
|
|
@@ -226,7 +238,11 @@ class FunctionHelper extends extend_default_page_1.ExtendDefaultPage {
|
|
|
226
238
|
}
|
|
227
239
|
yield this.timeout(3000);
|
|
228
240
|
yield loginPage.keyboard.press('Enter');
|
|
229
|
-
|
|
241
|
+
try {
|
|
242
|
+
yield loginPage.waitForSelector(no_button, { visible: true, timeout: 60000 });
|
|
243
|
+
}
|
|
244
|
+
catch (e) { }
|
|
245
|
+
this.log('Then', `I checked for the '${no_button}' element to be visible`, AuxTA_1.StepStatus.PASSED);
|
|
230
246
|
yield loginPage.keyboard.press('Enter');
|
|
231
247
|
});
|
|
232
248
|
}
|
|
@@ -0,0 +1,63 @@
|
|
|
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
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.PuppeteerExtra = void 0;
|
|
16
|
+
const AuxTA_1 = __importDefault(require("../AuxTA"));
|
|
17
|
+
const config_1 = require("../auxta/configs/config");
|
|
18
|
+
const puppeteer_extra = require("puppeteer-extra");
|
|
19
|
+
class PuppeteerExtra {
|
|
20
|
+
startBrowser() {
|
|
21
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
let args = [];
|
|
23
|
+
let env = {};
|
|
24
|
+
if (process.env.ENVIRONMENT === 'LOCAL') {
|
|
25
|
+
args.push('--start-maximized');
|
|
26
|
+
}
|
|
27
|
+
if (process.env.ENVIRONMENT != 'LOCAL') {
|
|
28
|
+
args.push(`--window-size=${config_1.config.screenWidth ? config_1.config.screenWidth : 1920},${config_1.config.screenHeight ? config_1.config.screenHeight : 1080}`);
|
|
29
|
+
args.push("--no-sandbox", "--disable-setuid-sandbox", "--disable-gpu");
|
|
30
|
+
env = {
|
|
31
|
+
DISPLAY: ":10.0"
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
const StealthPlugin = require('puppeteer-extra-plugin-stealth');
|
|
35
|
+
puppeteer_extra.default.use(StealthPlugin());
|
|
36
|
+
this.browser = yield puppeteer_extra.default.launch({
|
|
37
|
+
slowMo: process.env.slowMo ? Number(process.env.slowMo) : 0,
|
|
38
|
+
executablePath: puppeteer_extra.default.executablePath(),
|
|
39
|
+
args,
|
|
40
|
+
env,
|
|
41
|
+
ignoreDefaultArgs: ["--enable-automation"],
|
|
42
|
+
defaultViewport: process.env.ENVIRONMENT === 'LOCAL' ? null : {
|
|
43
|
+
width: config_1.config.screenWidth,
|
|
44
|
+
height: config_1.config.screenHeight
|
|
45
|
+
},
|
|
46
|
+
headless: process.env.ENVIRONMENT === 'LOCAL' ? (process.env.headless === 'true' ? 'new' : false) : 'new'
|
|
47
|
+
});
|
|
48
|
+
this.defaultPage = (yield this.browser.pages())[0];
|
|
49
|
+
yield AuxTA_1.default.extend_page_functions(this.defaultPage);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
close() {
|
|
53
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
54
|
+
if (this.browser) {
|
|
55
|
+
let pages = yield this.browser.pages();
|
|
56
|
+
yield Promise.all(pages.map((page) => page.close()));
|
|
57
|
+
yield this.browser.close();
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.PuppeteerExtra = PuppeteerExtra;
|
|
63
|
+
exports.default = new PuppeteerExtra();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { UploadModel } from "../auxta/models/upload.model";
|
|
2
|
-
import
|
|
2
|
+
import puppeteer = require("puppeteer");
|
|
3
3
|
export declare class Puppeteer {
|
|
4
|
-
defaultPage:
|
|
4
|
+
defaultPage: puppeteer.Page;
|
|
5
5
|
private browser;
|
|
6
6
|
startBrowser(): Promise<void>;
|
|
7
7
|
close(): Promise<void>;
|
|
@@ -21,7 +21,7 @@ const status_of_step_1 = require("../auxta/enums/status-of.step");
|
|
|
21
21
|
const config_1 = require("../auxta/configs/config");
|
|
22
22
|
const start_suite_helper_1 = require("../auxta/utilities/start-suite.helper");
|
|
23
23
|
const report_service_1 = require("../auxta/services/report.service");
|
|
24
|
-
const puppeteer = require("puppeteer
|
|
24
|
+
const puppeteer = require("puppeteer");
|
|
25
25
|
class Puppeteer {
|
|
26
26
|
startBrowser() {
|
|
27
27
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -37,8 +37,6 @@ class Puppeteer {
|
|
|
37
37
|
DISPLAY: ":10.0"
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
|
-
const StealthPlugin = require('puppeteer-extra-plugin-stealth');
|
|
41
|
-
puppeteer.default.use(StealthPlugin());
|
|
42
40
|
this.browser = yield puppeteer.default.launch({
|
|
43
41
|
slowMo: process.env.slowMo ? Number(process.env.slowMo) : 0,
|
|
44
42
|
executablePath: puppeteer.default.executablePath(),
|
|
@@ -49,7 +47,7 @@ class Puppeteer {
|
|
|
49
47
|
width: config_1.config.screenWidth,
|
|
50
48
|
height: config_1.config.screenHeight
|
|
51
49
|
},
|
|
52
|
-
headless: process.env.ENVIRONMENT === 'LOCAL' ? (process.env.headless === 'true' ?
|
|
50
|
+
headless: process.env.ENVIRONMENT === 'LOCAL' ? (process.env.headless === 'true' ? true : false) : true
|
|
53
51
|
});
|
|
54
52
|
this.defaultPage = (yield this.browser.pages())[0];
|
|
55
53
|
yield AuxTA_1.default.extend_page_functions(this.defaultPage);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@auxcode/auxta",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.75",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./build/AuxTA.js",
|
|
6
6
|
"types": "./build/AuxTA.d.ts",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"js-base64": "^3.7.5",
|
|
25
25
|
"node-2fa": "^2.0.3",
|
|
26
26
|
"nodemailer": "^6.9.2",
|
|
27
|
-
"puppeteer": "^21.
|
|
27
|
+
"puppeteer": "^21.5.2",
|
|
28
28
|
"readline": "^1.3.0",
|
|
29
29
|
"typescript": "^5.2.2",
|
|
30
30
|
"puppeteer-extra": "^3.3.6",
|