@auxcode/auxta 1.3.60 → 1.3.61

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.
Files changed (33) hide show
  1. package/build/macros/helpers/emailHelper.d.ts +0 -3
  2. package/build/macros/helpers/emailHelper.js +56 -51
  3. package/package.json +1 -1
  4. package/build/auxta/configs/config.d.ts +0 -57
  5. package/build/auxta/configs/config.js +0 -69
  6. package/build/auxta/enums/status-of.step.d.ts +0 -7
  7. package/build/auxta/enums/status-of.step.js +0 -11
  8. package/build/auxta/helpers/response.helper.d.ts +0 -10
  9. package/build/auxta/helpers/response.helper.js +0 -15
  10. package/build/auxta/helpers/start.helper.d.ts +0 -1
  11. package/build/auxta/helpers/start.helper.js +0 -26
  12. package/build/auxta/hooks/report.hook.d.ts +0 -14
  13. package/build/auxta/hooks/report.hook.js +0 -67
  14. package/build/auxta/models/upload.model.d.ts +0 -35
  15. package/build/auxta/models/upload.model.js +0 -82
  16. package/build/auxta/services/log.service.d.ts +0 -31
  17. package/build/auxta/services/log.service.js +0 -61
  18. package/build/auxta/services/report.service.d.ts +0 -31
  19. package/build/auxta/services/report.service.js +0 -183
  20. package/build/auxta/services/runtime.service.d.ts +0 -16
  21. package/build/auxta/services/runtime.service.js +0 -41
  22. package/build/auxta/utilities/runtime.helper.d.ts +0 -15
  23. package/build/auxta/utilities/runtime.helper.js +0 -19
  24. package/build/auxta/utilities/screenshot.helper.js +0 -59
  25. package/build/auxta/utilities/start-suite.helper.d.ts +0 -17
  26. package/build/auxta/utilities/start-suite.helper.js +0 -31
  27. package/build/macros/helpers/Aux2faAuth.d.ts +0 -7
  28. package/build/macros/helpers/Aux2faAuth.js +0 -29
  29. package/build/macros/helpers/AuxGoogleAuth.js +0 -231
  30. package/build/macros/helpers/code.helper.js +0 -230
  31. package/build/macros/helpers/extend-default-page.d.ts +0 -6
  32. package/build/macros/helpers/extend-default-page.js +0 -89
  33. package/build/puppeteer/puppeteer.js +0 -213
@@ -1,231 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
- return new (P || (P = Promise))(function (resolve, reject) {
28
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
- step((generator = generator.apply(thisArg, _arguments || [])).next());
32
- });
33
- };
34
- var __importDefault = (this && this.__importDefault) || function (mod) {
35
- return (mod && mod.__esModule) ? mod : { "default": mod };
36
- };
37
- Object.defineProperty(exports, "__esModule", { value: true });
38
- exports.AuxGoogleAuth = void 0;
39
- const config_1 = require("../../auxta/configs/config");
40
- const puppeteer_1 = __importDefault(require("../../puppeteer/puppeteer"));
41
- const code_helper_1 = __importDefault(require("../helpers/code.helper"));
42
- const status_of_step_1 = __importDefault(require("../../auxta/enums/status-of.step"));
43
- const fs = require('fs');
44
- const readline = require('readline');
45
- const process = __importStar(require("process"));
46
- const { google } = require("googleapis");
47
- const SCOPES = [
48
- 'https://www.googleapis.com/auth/gmail.addons.current.action.compose',
49
- 'https://www.googleapis.com/auth/gmail.addons.current.message.action',
50
- 'https://www.googleapis.com/auth/gmail.labels',
51
- 'https://www.googleapis.com/auth/gmail.addons.current.message.metadata',
52
- 'https://www.googleapis.com/auth/gmail.addons.current.message.readonly',
53
- 'https://www.googleapis.com/auth/gmail.send',
54
- 'https://mail.google.com/',
55
- 'https://www.googleapis.com/auth/gmail.modify',
56
- 'https://www.googleapis.com/auth/gmail.compose',
57
- 'https://www.googleapis.com/auth/gmail.readonly',
58
- 'https://www.googleapis.com/auth/gmail.insert',
59
- ];
60
- const TOKEN_PATH = 'token.json';
61
- let TOKEN;
62
- let EMAIL;
63
- let PASSWORD;
64
- class AuxGoogleAuth {
65
- static get oAuth2Client() {
66
- return this._oAuth2Client;
67
- }
68
- static get googleClient() {
69
- return google;
70
- }
71
- static get gmailClient() {
72
- return google.gmail({ version: 'v1', auth: this._oAuth2Client });
73
- }
74
- static setupBrowser() {
75
- return __awaiter(this, void 0, void 0, function* () {
76
- yield this.authorize(this.credentialsJson);
77
- });
78
- }
79
- static setEmailPassword(email, password) {
80
- return __awaiter(this, void 0, void 0, function* () {
81
- EMAIL = email;
82
- PASSWORD = password;
83
- });
84
- }
85
- static setupHeadless() {
86
- return __awaiter(this, void 0, void 0, function* () {
87
- yield this.authorizeHeadless(this.credentialsJson);
88
- });
89
- }
90
- static authorize(credentials) {
91
- return __awaiter(this, void 0, void 0, function* () {
92
- const { client_secret, client_id, redirect_uris } = credentials.installed;
93
- const oAuth2Client = new google.auth.OAuth2(client_id, client_secret, redirect_uris[0]);
94
- try {
95
- let token = fs.readFileSync(TOKEN_PATH);
96
- if (token.length > 0 && token !== undefined) {
97
- oAuth2Client.setCredentials(JSON.parse(token));
98
- this._oAuth2Client = oAuth2Client;
99
- return;
100
- }
101
- yield this.getNewToken(oAuth2Client);
102
- }
103
- catch (e) {
104
- yield this.getNewToken(oAuth2Client);
105
- }
106
- });
107
- }
108
- static authorizeHeadless(credentials) {
109
- return __awaiter(this, void 0, void 0, function* () {
110
- const { client_secret, client_id, redirect_uris } = credentials.installed;
111
- const oAuth2Client = new google.auth.OAuth2(client_id, client_secret, redirect_uris[0]);
112
- try {
113
- if (TOKEN) {
114
- oAuth2Client.setCredentials(TOKEN);
115
- this._oAuth2Client = oAuth2Client;
116
- return;
117
- }
118
- yield this.getNewTokenHeadless(oAuth2Client);
119
- }
120
- catch (e) {
121
- yield this.getNewTokenHeadless(oAuth2Client);
122
- }
123
- });
124
- }
125
- static getNewToken(oAuth2Client) {
126
- return __awaiter(this, void 0, void 0, function* () {
127
- const authUrl = oAuth2Client.generateAuthUrl({
128
- access_type: 'offline',
129
- prompt: 'consent',
130
- scope: SCOPES,
131
- });
132
- console.log('Authorize this app by visiting this url:', authUrl);
133
- const rl = readline.createInterface({
134
- input: process.stdin,
135
- output: process.stdout,
136
- });
137
- rl.question('Enter the code from that page here: ', (code) => {
138
- rl.close();
139
- oAuth2Client.getToken(code, (err, token) => {
140
- if (err)
141
- return console.error('Error retrieving access token', err);
142
- oAuth2Client.setCredentials(token);
143
- fs.writeFile(TOKEN_PATH, JSON.stringify(token), (err) => {
144
- if (err)
145
- return console.error(err);
146
- console.log('Token stored to', TOKEN_PATH);
147
- });
148
- this._oAuth2Client = oAuth2Client;
149
- });
150
- });
151
- });
152
- }
153
- static getNewTokenHeadless(oAuth2Client) {
154
- return __awaiter(this, void 0, void 0, function* () {
155
- const authUrl = oAuth2Client.generateAuthUrl({
156
- access_type: 'offline',
157
- prompt: 'consent',
158
- scope: SCOPES,
159
- });
160
- const code = yield this.LogIn(authUrl);
161
- this._oAuth2Client = yield (new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
162
- yield oAuth2Client.getToken(code, (err, token) => {
163
- if (err)
164
- return console.error('Error retrieving access token', err);
165
- oAuth2Client.setCredentials(token);
166
- TOKEN = token;
167
- this._oAuth2Client = oAuth2Client;
168
- code_helper_1.default.log('Then', 'I login with the google account', status_of_step_1.default.PASSED);
169
- resolve(oAuth2Client);
170
- });
171
- })));
172
- });
173
- }
174
- static LogIn(authUrl) {
175
- var _a, _b;
176
- return __awaiter(this, void 0, void 0, function* () {
177
- const email = EMAIL ? EMAIL : process.env.google_account;
178
- const password = PASSWORD ? PASSWORD : process.env.google_password;
179
- if (email && password) {
180
- const context = yield puppeteer_1.default.defaultPage.browser().createIncognitoBrowserContext();
181
- const page = yield context.newPage();
182
- yield page.goto(authUrl);
183
- yield code_helper_1.default.waitForSelector('visible', '#identifierId', config_1.config.timeout, page);
184
- yield ((_a = (yield page.$('#identifierId'))) === null || _a === void 0 ? void 0 : _a.type(email));
185
- yield (yield page.$$('button'))[3].click();
186
- yield code_helper_1.default.timeout(4000);
187
- yield code_helper_1.default.waitForSelector('visible', 'input[type="password"]', config_1.config.timeout, page);
188
- yield ((_b = (yield page.$('input[type="password"]'))) === null || _b === void 0 ? void 0 : _b.type(password));
189
- yield (yield page.$$('button'))[1].click();
190
- yield code_helper_1.default.timeout(4000);
191
- yield code_helper_1.default.waitForSelector('visible', '#headingText', config_1.config.timeout, page);
192
- yield (yield page.$$('button'))[2].click();
193
- yield code_helper_1.default.timeout(4000);
194
- const checkbox = yield page.$$('input[type="checkbox"]');
195
- if (checkbox.length > 0) {
196
- yield code_helper_1.default.waitForSelector('visible', 'input[type="checkbox"]', config_1.config.timeout, page);
197
- yield checkbox[0].click();
198
- yield (yield page.$$('button'))[2].click();
199
- }
200
- else {
201
- yield code_helper_1.default.waitForSelector('visible', `div[data-email="${email.toLocaleLowerCase()}"]`, config_1.config.timeout, page);
202
- yield code_helper_1.default.timeout(4000);
203
- yield (yield page.$$('button'))[2].click();
204
- }
205
- yield code_helper_1.default.timeout(4000);
206
- yield code_helper_1.default.waitForSelector('visible', 'body', config_1.config.timeout, page);
207
- const currentUrl = page.url();
208
- const code = currentUrl.substring(currentUrl.indexOf("code=") + 5, currentUrl.lastIndexOf("&"));
209
- code_helper_1.default.log('Then', 'I get the code form the url', status_of_step_1.default.PASSED);
210
- yield page.close();
211
- return decodeURIComponent(code);
212
- }
213
- else {
214
- throw new Error('The email or password for the google account are empty');
215
- }
216
- });
217
- }
218
- }
219
- exports.AuxGoogleAuth = AuxGoogleAuth;
220
- AuxGoogleAuth.credentialsJson = {
221
- "installed": {
222
- "client_id": "120362272213-usevfijf76jj5nsr502i2lai6nu71oq8.apps.googleusercontent.com",
223
- "project_id": "auxta-library",
224
- "auth_uri": "https://accounts.google.com/o/oauth2/auth",
225
- "token_uri": "https://oauth2.googleapis.com/token",
226
- "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
227
- "client_secret": "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",
228
- "redirect_uris": ["https://auxcode.com"]
229
- }
230
- };
231
- exports.default = new AuxGoogleAuth();
@@ -1,230 +0,0 @@
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.FunctionHelper = void 0;
16
- const log_service_1 = __importDefault(require("../../auxta/services/log.service"));
17
- const puppeteer_1 = __importDefault(require("../../puppeteer/puppeteer"));
18
- const status_of_step_1 = require("../../auxta/enums/status-of.step");
19
- const AuxTA_1 = require("../../AuxTA");
20
- const extend_default_page_1 = require("./extend-default-page");
21
- const puppeteer_2 = require("puppeteer");
22
- const screenshot_helper_1 = require("../../auxta/utilities/screenshot.helper");
23
- const report_service_1 = require("../../auxta/services/report.service");
24
- class FunctionHelper extends extend_default_page_1.ExtendDefaultPage {
25
- log(keyword, name, status, screenshot) {
26
- log_service_1.default.push(keyword, name, status, screenshot);
27
- }
28
- screenshot(page = puppeteer_1.default.defaultPage) {
29
- return __awaiter(this, void 0, void 0, function* () {
30
- const screenshotBuffer = yield (0, screenshot_helper_1.captureScreenshotPage)(page);
31
- if (screenshotBuffer) {
32
- return screenshotBuffer.toString('base64');
33
- }
34
- });
35
- }
36
- screenshotCompare(key, page = puppeteer_1.default.defaultPage) {
37
- return __awaiter(this, void 0, void 0, function* () {
38
- if (process.env.ENVIRONMENT !== 'LOCAL') {
39
- const screenshotBuffer = yield (0, screenshot_helper_1.captureScreenshotPage)(page);
40
- if (screenshotBuffer) {
41
- const screenshot = screenshotBuffer.toString('base64');
42
- const result = yield (0, report_service_1.compareScreenshots)(key, screenshot);
43
- if (result.presentDifference && Number(result.presentDifference) > 1) {
44
- log_service_1.default.push('Then', `I compare screenshots with key ${key}, and difference is: ${result.presentDifference}%`, status_of_step_1.StatusOfStep.FAILED, screenshot, key);
45
- }
46
- else {
47
- log_service_1.default.push('Then', `I compare screenshots with key ${key}`, status_of_step_1.StatusOfStep.PASSED, screenshot, key);
48
- }
49
- }
50
- }
51
- else {
52
- log_service_1.default.push('Then', `I compare screenshots with key ${key}`, status_of_step_1.StatusOfStep.PASSED, undefined, key);
53
- }
54
- });
55
- }
56
- suggest(name) {
57
- log_service_1.default.addSuggestion(name);
58
- }
59
- getEscapedText(text) {
60
- const splitedQuotes = text.replace(/'/g, `', "'", '`);
61
- return `concat('${splitedQuotes}', '')`;
62
- }
63
- clickByText(selector, text, dotOrText = '.', options = {}, page = puppeteer_1.default.defaultPage, time = this.defaultTimeout, log_message = true) {
64
- return __awaiter(this, void 0, void 0, function* () {
65
- const message = `I clicked on the '${text}' '${selector}'`;
66
- try {
67
- const [linkHandlers] = yield page.$x(`//${selector}[contains(${dotOrText},"${text}")]`);
68
- if (linkHandlers) {
69
- yield linkHandlers.click(options);
70
- log_service_1.default.push('Then', message, status_of_step_1.StatusOfStep.PASSED);
71
- }
72
- }
73
- catch (e) {
74
- if (log_message) {
75
- log_service_1.default.push('And', `${message}, but it didn't appear in ${time / 1000} seconds.`, status_of_step_1.StatusOfStep.FAILED);
76
- }
77
- throw new Error(message);
78
- }
79
- if (log_message) {
80
- log_service_1.default.push('And', message, status_of_step_1.StatusOfStep.PASSED);
81
- }
82
- });
83
- }
84
- clickByTextWithClass(class_selector, class_name, selector, text, dotOrText = '.', page = puppeteer_1.default.defaultPage) {
85
- return __awaiter(this, void 0, void 0, function* () {
86
- const message = `I click on the '${text}' '${selector}'`;
87
- try {
88
- const [linkHandlers] = yield page.$x(`//${class_selector}[contains(@class,${this.getEscapedText(class_name)})]//${selector}[contains(${dotOrText},"${text}")]`);
89
- if (linkHandlers) {
90
- yield linkHandlers.click();
91
- log_service_1.default.push('Then', message, status_of_step_1.StatusOfStep.PASSED);
92
- return;
93
- }
94
- }
95
- catch (e) {
96
- }
97
- log_service_1.default.push('Then', message, status_of_step_1.StatusOfStep.FAILED);
98
- throw new Error(message);
99
- });
100
- }
101
- waitForSelectorWithText(selector, text, dotOrText = '.', page = puppeteer_1.default.defaultPage) {
102
- return __awaiter(this, void 0, void 0, function* () {
103
- const message = `I check for '${text}' on the current page`;
104
- try {
105
- yield page.waitForSelector(selector, {
106
- timeout: this.defaultTimeout
107
- });
108
- const linkHandlers = yield page.$x(`//${selector}[contains(${dotOrText},"${text}")]`);
109
- if (linkHandlers.length > 0) {
110
- log_service_1.default.push('And', message, status_of_step_1.StatusOfStep.PASSED);
111
- return true;
112
- }
113
- }
114
- catch (e) {
115
- }
116
- log_service_1.default.push('And', message, status_of_step_1.StatusOfStep.FAILED);
117
- throw new Error(message);
118
- });
119
- }
120
- timeout(timeout = this.defaultTimeout, page = puppeteer_1.default.defaultPage) {
121
- return __awaiter(this, void 0, void 0, function* () {
122
- yield new Promise(r => setTimeout(r, timeout));
123
- });
124
- }
125
- waitForSelector(option, selector, time = this.defaultTimeout, page = puppeteer_1.default.defaultPage, log_message = true) {
126
- return __awaiter(this, void 0, void 0, function* () {
127
- const message = `I checked for the '${selector}' element to be ${option}`;
128
- try {
129
- yield page.waitForSelector(selector, {
130
- [option]: true,
131
- timeout: time
132
- });
133
- }
134
- catch (e) {
135
- if (log_message) {
136
- log_service_1.default.push('And', `${message}, but it didn't appear in ${time / 1000} seconds.`, status_of_step_1.StatusOfStep.FAILED);
137
- }
138
- throw new Error(message);
139
- }
140
- if (log_message) {
141
- log_service_1.default.push('And', message, status_of_step_1.StatusOfStep.PASSED);
142
- }
143
- });
144
- }
145
- urlContains(selector, page = puppeteer_1.default.defaultPage) {
146
- return __awaiter(this, void 0, void 0, function* () {
147
- const url = page.url();
148
- let message = `I am on the ${selector} page`;
149
- if (!url.includes(selector)) {
150
- log_service_1.default.push('And', message, status_of_step_1.StatusOfStep.FAILED);
151
- throw new Error(message);
152
- }
153
- log_service_1.default.push('And', message, status_of_step_1.StatusOfStep.PASSED);
154
- });
155
- }
156
- pressEnter(page = puppeteer_1.default.defaultPage) {
157
- return __awaiter(this, void 0, void 0, function* () {
158
- yield page.keyboard.press('Enter');
159
- });
160
- }
161
- emulate(phone_name, page = puppeteer_1.default.defaultPage) {
162
- return __awaiter(this, void 0, void 0, function* () {
163
- const phone = puppeteer_2.KnownDevices[phone_name];
164
- yield page.emulate(phone);
165
- });
166
- }
167
- restartBrowser() {
168
- return __awaiter(this, void 0, void 0, function* () {
169
- yield puppeteer_1.default.close();
170
- yield puppeteer_1.default.startBrowser();
171
- });
172
- }
173
- clickAndWaitForPageToBeCreated(selector, page = puppeteer_1.default.defaultPage) {
174
- return __awaiter(this, void 0, void 0, function* () {
175
- const nav = new Promise(res => page.browser().on('targetcreated', res));
176
- yield page.click(selector);
177
- yield nav;
178
- });
179
- }
180
- closeLastPage(page = puppeteer_1.default.defaultPage) {
181
- return __awaiter(this, void 0, void 0, function* () {
182
- const pages = yield page.browser().pages();
183
- yield pages[pages.length - 1].close();
184
- });
185
- }
186
- microsoftLogin(button, email, password, page = puppeteer_1.default.defaultPage) {
187
- var _a;
188
- return __awaiter(this, void 0, void 0, function* () {
189
- const email_input = 'input[type="email"]';
190
- const password_input = 'input[type="password"]';
191
- const next_button = 'input[value="Next"]';
192
- const sign_in_button = 'input[value="Sign in"]';
193
- const no_button = 'input.ext-secondary';
194
- yield this.clickAndWaitForPageToBeCreated(button, page);
195
- const pages = yield page.browser().pages();
196
- const loginPage = pages[pages.length - 1];
197
- yield this.extend_page_functions(loginPage);
198
- yield loginPage.waitForNetworkIdle();
199
- yield this.waitForSelector('visible', next_button, 60000, loginPage);
200
- yield loginPage.type(email_input, email, { delay: 0 });
201
- yield loginPage.keyboard.press('Enter');
202
- yield loginPage.waitForNetworkIdle();
203
- let isWorkOrPersonalVisible = yield page.$('div.table');
204
- if (!!isWorkOrPersonalVisible) {
205
- yield (yield page.$$('div.table'))[0].click();
206
- console.log('Then', 'I clicked Work or school account', AuxTA_1.StepStatus.PASSED);
207
- yield page.waitForNetworkIdle();
208
- }
209
- else {
210
- yield page.waitForNetworkIdle();
211
- }
212
- yield this.waitForSelector('visible', sign_in_button, 60000, loginPage);
213
- yield this.waitForSelector('visible', password_input, 6000, loginPage);
214
- try {
215
- (_a = (yield loginPage.$(password_input))) === null || _a === void 0 ? void 0 : _a.type(password);
216
- yield this.log('Then', `I type password into the ${password_input}`, AuxTA_1.StepStatus.PASSED);
217
- }
218
- catch (e) {
219
- yield this.log('Then', `I type password into the ${password_input}`, AuxTA_1.StepStatus.FAILED);
220
- throw new Error(`I type password into the ${password_input}`);
221
- }
222
- yield this.timeout(3000);
223
- yield loginPage.keyboard.press('Enter');
224
- yield this.waitForSelector('visible', no_button, 60000, loginPage);
225
- yield loginPage.keyboard.press('Enter');
226
- });
227
- }
228
- }
229
- exports.FunctionHelper = FunctionHelper;
230
- exports.default = new FunctionHelper();
@@ -1,6 +0,0 @@
1
- export declare class ExtendDefaultPage {
2
- defaultTimeout: number;
3
- extend_page_functions(page: any, time?: number): Promise<any>;
4
- }
5
- declare const _default: ExtendDefaultPage;
6
- export default _default;
@@ -1,89 +0,0 @@
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.ExtendDefaultPage = void 0;
16
- const log_service_1 = __importDefault(require("../../auxta/services/log.service"));
17
- const status_of_step_1 = require("../../auxta/enums/status-of.step");
18
- const config_1 = require("../../auxta/configs/config");
19
- class ExtendDefaultPage {
20
- constructor() {
21
- this.defaultTimeout = config_1.config.timeout;
22
- }
23
- extend_page_functions(page, time = this.defaultTimeout) {
24
- return __awaiter(this, void 0, void 0, function* () {
25
- this.defaultTimeout = config_1.config.timeout;
26
- const { goto: original_goto, click: original_click, type: original_type, waitForNetworkIdle: original_waitForNetworkIdle } = page;
27
- page.goto = function goto(url, options) {
28
- log_service_1.default.push('Then', `I go to the '${url}' page`, status_of_step_1.StatusOfStep.PASSED);
29
- return original_goto.apply(page, arguments);
30
- };
31
- page.click = function click(selector, options) {
32
- return __awaiter(this, arguments, void 0, function* () {
33
- try {
34
- yield page.waitForSelector(selector, {
35
- timeout: time
36
- });
37
- let elementName = yield page.$eval(selector, (e) => e.textContent);
38
- if (!elementName || elementName === ' ')
39
- elementName = selector;
40
- yield original_click.apply(page, arguments);
41
- log_service_1.default.push('Then', `I click on the '${elementName}'`, status_of_step_1.StatusOfStep.PASSED);
42
- }
43
- catch (e) {
44
- const msg = `I click on the '${selector}'`;
45
- log_service_1.default.push('Then', msg, status_of_step_1.StatusOfStep.FAILED);
46
- throw new Error(msg);
47
- }
48
- });
49
- };
50
- page.waitForNetworkIdle = function waitForNetworkIdle(selector, option) {
51
- return __awaiter(this, arguments, void 0, function* () {
52
- let message = 'I wait for the page to load';
53
- let result;
54
- try {
55
- result = yield original_waitForNetworkIdle.apply(page, arguments);
56
- log_service_1.default.push('Then', message, status_of_step_1.StatusOfStep.PASSED);
57
- }
58
- catch (e) {
59
- log_service_1.default.push('Then', message, status_of_step_1.StatusOfStep.FAILED);
60
- throw new Error(message);
61
- }
62
- return result;
63
- });
64
- };
65
- page.type = function type(field, value) {
66
- return __awaiter(this, arguments, void 0, function* () {
67
- try {
68
- yield page.waitForSelector(field, {
69
- timeout: time
70
- });
71
- yield original_type.apply(page, arguments);
72
- let elementName = yield page.$eval(field, (e) => e.textContent);
73
- if (!elementName || elementName === ' ')
74
- elementName = field;
75
- log_service_1.default.push('Then', `I type '${value}' into the '${elementName}' field`, status_of_step_1.StatusOfStep.PASSED);
76
- }
77
- catch (e) {
78
- const msg = `I type '${value}' into the '${field}' field`;
79
- log_service_1.default.push('Then', msg, status_of_step_1.StatusOfStep.FAILED);
80
- throw new Error(msg);
81
- }
82
- });
83
- };
84
- return page;
85
- });
86
- }
87
- }
88
- exports.ExtendDefaultPage = ExtendDefaultPage;
89
- exports.default = new ExtendDefaultPage();