@auxcode/auxta 1.3.39 → 1.3.40

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 (79) hide show
  1. package/build/cjs/AuxTA.d.ts +62 -62
  2. package/build/cjs/AuxTA.js +154 -154
  3. package/build/cjs/auxta/configs/config.d.ts +57 -57
  4. package/build/cjs/auxta/configs/config.js +69 -69
  5. package/build/cjs/auxta/enums/status-of.step.d.ts +7 -7
  6. package/build/cjs/auxta/enums/status-of.step.js +11 -11
  7. package/build/cjs/auxta/helpers/response.helper.d.ts +10 -10
  8. package/build/cjs/auxta/helpers/response.helper.js +15 -15
  9. package/build/cjs/auxta/helpers/start.helper.d.ts +1 -1
  10. package/build/cjs/auxta/helpers/start.helper.js +26 -26
  11. package/build/cjs/auxta/hooks/report.hook.d.ts +14 -14
  12. package/build/cjs/auxta/hooks/report.hook.js +66 -66
  13. package/build/cjs/auxta/models/upload.model.d.ts +35 -35
  14. package/build/cjs/auxta/models/upload.model.js +82 -82
  15. package/build/cjs/auxta/services/log.service.d.ts +26 -26
  16. package/build/cjs/auxta/services/log.service.js +47 -47
  17. package/build/cjs/auxta/services/report.service.d.ts +36 -36
  18. package/build/cjs/auxta/services/report.service.js +167 -167
  19. package/build/cjs/auxta/services/runtime.service.d.ts +16 -16
  20. package/build/cjs/auxta/services/runtime.service.js +41 -41
  21. package/build/cjs/auxta/utilities/runtime.helper.d.ts +15 -15
  22. package/build/cjs/auxta/utilities/runtime.helper.js +19 -19
  23. package/build/cjs/auxta/utilities/screenshot.helper.d.ts +2 -2
  24. package/build/cjs/auxta/utilities/screenshot.helper.js +40 -40
  25. package/build/cjs/auxta/utilities/start-suite.helper.d.ts +17 -17
  26. package/build/cjs/auxta/utilities/start-suite.helper.js +31 -31
  27. package/build/cjs/macros/helpers/Aux2faAuth.d.ts +7 -7
  28. package/build/cjs/macros/helpers/Aux2faAuth.js +29 -29
  29. package/build/cjs/macros/helpers/AuxGoogleAuth.d.ts +17 -17
  30. package/build/cjs/macros/helpers/AuxGoogleAuth.js +104 -104
  31. package/build/cjs/macros/helpers/code.helper.d.ts +21 -21
  32. package/build/cjs/macros/helpers/code.helper.js +201 -201
  33. package/build/cjs/macros/helpers/emailHelper.d.ts +19 -19
  34. package/build/cjs/macros/helpers/emailHelper.js +177 -177
  35. package/build/cjs/macros/helpers/extend-default-page.d.ts +6 -6
  36. package/build/cjs/macros/helpers/extend-default-page.js +89 -89
  37. package/build/cjs/puppeteer/puppeteer.d.ts +25 -25
  38. package/build/cjs/puppeteer/puppeteer.js +209 -209
  39. package/build/esm/AuxTA.d.ts +62 -62
  40. package/build/esm/AuxTA.js +125 -125
  41. package/build/esm/auxta/configs/config.d.ts +57 -57
  42. package/build/esm/auxta/configs/config.js +64 -64
  43. package/build/esm/auxta/enums/status-of.step.d.ts +7 -7
  44. package/build/esm/auxta/enums/status-of.step.js +8 -8
  45. package/build/esm/auxta/helpers/response.helper.d.ts +10 -10
  46. package/build/esm/auxta/helpers/response.helper.js +11 -11
  47. package/build/esm/auxta/helpers/start.helper.d.ts +1 -1
  48. package/build/esm/auxta/helpers/start.helper.js +24 -24
  49. package/build/esm/auxta/hooks/report.hook.d.ts +14 -14
  50. package/build/esm/auxta/hooks/report.hook.js +58 -58
  51. package/build/esm/auxta/models/upload.model.d.ts +35 -35
  52. package/build/esm/auxta/models/upload.model.js +78 -78
  53. package/build/esm/auxta/services/log.service.d.ts +26 -26
  54. package/build/esm/auxta/services/log.service.js +43 -43
  55. package/build/esm/auxta/services/report.service.d.ts +36 -36
  56. package/build/esm/auxta/services/report.service.js +153 -153
  57. package/build/esm/auxta/services/runtime.service.d.ts +16 -16
  58. package/build/esm/auxta/services/runtime.service.js +37 -37
  59. package/build/esm/auxta/utilities/runtime.helper.d.ts +15 -15
  60. package/build/esm/auxta/utilities/runtime.helper.js +15 -15
  61. package/build/esm/auxta/utilities/screenshot.helper.d.ts +2 -2
  62. package/build/esm/auxta/utilities/screenshot.helper.js +33 -33
  63. package/build/esm/auxta/utilities/start-suite.helper.d.ts +17 -17
  64. package/build/esm/auxta/utilities/start-suite.helper.js +26 -26
  65. package/build/esm/macros/helpers/Aux2faAuth.d.ts +7 -7
  66. package/build/esm/macros/helpers/Aux2faAuth.js +25 -25
  67. package/build/esm/macros/helpers/AuxGoogleAuth.d.ts +17 -17
  68. package/build/esm/macros/helpers/AuxGoogleAuth.js +100 -100
  69. package/build/esm/macros/helpers/code.helper.d.ts +21 -21
  70. package/build/esm/macros/helpers/code.helper.js +194 -194
  71. package/build/esm/macros/helpers/emailHelper.d.ts +19 -19
  72. package/build/esm/macros/helpers/emailHelper.js +170 -170
  73. package/build/esm/macros/helpers/extend-default-page.d.ts +6 -6
  74. package/build/esm/macros/helpers/extend-default-page.js +82 -82
  75. package/build/esm/puppeteer/puppeteer.d.ts +25 -25
  76. package/build/esm/puppeteer/puppeteer.js +201 -201
  77. package/build/tsconfig-cjs.tsbuildinfo +1 -1
  78. package/build/tsconfig.tsbuildinfo +1 -1
  79. package/package.json +3 -3
@@ -1,177 +1,177 @@
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.EmailHelper = void 0;
16
- const log_service_1 = __importDefault(require("../../auxta/services/log.service"));
17
- const AuxGoogleAuth_1 = require("./AuxGoogleAuth");
18
- const AuxTA_1 = require("../../AuxTA");
19
- const base64 = require('js-base64');
20
- const MailComposer = require('nodemailer/lib/mail-composer');
21
- class EmailHelper {
22
- verifyEmail(from_name, from_email, subject, body, link = false) {
23
- return __awaiter(this, void 0, void 0, function* () {
24
- yield AuxGoogleAuth_1.AuxGoogleAuth.setup();
25
- let timeoutCount = 12000;
26
- while (timeoutCount <= 60000) {
27
- const res = yield AuxGoogleAuth_1.AuxGoogleAuth.gmailClient.users.messages.list({
28
- userId: "me",
29
- maxResults: 3
30
- });
31
- const messagesIds = res.data.messages;
32
- if (!messagesIds || messagesIds.length === 0) {
33
- throw new Error('No messagesIds found.');
34
- }
35
- for (const messageId of messagesIds) {
36
- if (messageId.id) {
37
- const gmailResponse = yield AuxGoogleAuth_1.AuxGoogleAuth.gmailClient.users.messages.get({
38
- userId: "me",
39
- id: messageId.id.toString(),
40
- format: 'FULL'
41
- });
42
- if (gmailResponse.data.payload && gmailResponse.data.id && gmailResponse.data.threadId) {
43
- const message_sender = this.getHeader('from', gmailResponse);
44
- const message_subject = this.getHeader('subject', gmailResponse);
45
- const message_body = this.getBody(subject, gmailResponse);
46
- if (message_sender.toLocaleLowerCase().includes(from_email) && message_sender.toLocaleLowerCase().includes(from_name.toLocaleLowerCase()) &&
47
- message_subject.toLocaleLowerCase().includes(subject.toLocaleLowerCase()) && message_body.toLocaleLowerCase().includes(body.toLocaleLowerCase())) {
48
- log_service_1.default.push('Then', `Email from: ${from_name} ${from_email} with subject: ${subject} and body: ${body} is found`, AuxTA_1.StepStatus.PASSED);
49
- yield AuxGoogleAuth_1.AuxGoogleAuth.gmailClient.users.messages.modify({
50
- userId: "me",
51
- id: gmailResponse.data.id,
52
- requestBody: {
53
- 'addLabelIds': [],
54
- 'removeLabelIds': ['UNREAD']
55
- }
56
- });
57
- if (link) {
58
- const html_link = yield this.getUrl(message_body);
59
- return {
60
- id: gmailResponse.data.id,
61
- threadId: gmailResponse.data.threadId,
62
- link: html_link
63
- };
64
- }
65
- return { id: gmailResponse.data.id, threadId: gmailResponse.data.threadId, link: '' };
66
- }
67
- }
68
- break;
69
- }
70
- }
71
- yield new Promise(r => setTimeout(r, timeoutCount));
72
- timeoutCount += 12000;
73
- }
74
- yield log_service_1.default.push('Then', `Email from: ${from_name} ${from_email} with subject: ${subject} and body: ${body} is found`, AuxTA_1.StepStatus.FAILED);
75
- });
76
- }
77
- sendEmail(to, subject, body) {
78
- return __awaiter(this, void 0, void 0, function* () {
79
- yield AuxGoogleAuth_1.AuxGoogleAuth.setup();
80
- const options = {
81
- to: to,
82
- from: this.getCurrentUserEmail(),
83
- subject: subject,
84
- html: body
85
- };
86
- yield EmailHelper.send(options);
87
- });
88
- }
89
- replyEmail(id, threadId, body) {
90
- return __awaiter(this, void 0, void 0, function* () {
91
- yield AuxGoogleAuth_1.AuxGoogleAuth.setup();
92
- const gmailResponse = yield AuxGoogleAuth_1.AuxGoogleAuth.gmailClient.users.messages.get({
93
- userId: "me",
94
- id: id,
95
- format: 'FULL'
96
- });
97
- if (gmailResponse.data.payload) {
98
- const message_subject = this.getHeader('subject', gmailResponse);
99
- const message_messageID = this.getHeader('Message-ID', gmailResponse);
100
- const reply_to = this.getHeader('reply-to', gmailResponse);
101
- const options = {
102
- to: reply_to,
103
- from: this.getCurrentUserEmail(),
104
- subject: `Re: ${message_subject}`,
105
- references: message_messageID,
106
- inReplyTo: [message_messageID],
107
- html: body
108
- };
109
- yield EmailHelper.send(options, threadId);
110
- }
111
- });
112
- }
113
- static send(options, threadId) {
114
- return __awaiter(this, void 0, void 0, function* () {
115
- const mailComposer = new MailComposer(options);
116
- const message = yield mailComposer.compile().build();
117
- const encodeMessage = Buffer.from(message).toString('base64').replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
118
- yield AuxGoogleAuth_1.AuxGoogleAuth.gmailClient.users.messages.send({
119
- userId: "me",
120
- requestBody: {
121
- threadId: threadId,
122
- raw: encodeMessage
123
- }
124
- });
125
- });
126
- }
127
- getHeader(value, headers) {
128
- for (const header of headers.data.payload.headers) {
129
- if (header.name.toLocaleLowerCase() === value.toLocaleLowerCase()) {
130
- return header.value;
131
- }
132
- }
133
- }
134
- getBody(subject, gmailResponse) {
135
- try {
136
- const body = gmailResponse.data.payload.parts[0].body.data;
137
- if (body) {
138
- return base64.decode(body);
139
- }
140
- else {
141
- return '';
142
- }
143
- }
144
- catch (e) {
145
- console.log(e);
146
- throw new Error(`Email with subject: ${subject} body ${gmailResponse.data.payload.parts[0].body.data} is empty`);
147
- }
148
- }
149
- getCurrentUserEmail() {
150
- return __awaiter(this, void 0, void 0, function* () {
151
- yield AuxGoogleAuth_1.AuxGoogleAuth.setup();
152
- const profile = yield AuxGoogleAuth_1.AuxGoogleAuth.gmailClient.users.getProfile({ userId: "me" });
153
- return profile.data.emailAddress;
154
- });
155
- }
156
- getUrl(body) {
157
- return __awaiter(this, void 0, void 0, function* () {
158
- const links = [];
159
- const split = body.split('\r\n\r\n');
160
- for (const splitElement of split) {
161
- if (splitElement.toString().startsWith('https')) {
162
- links.push(splitElement);
163
- }
164
- }
165
- if (links.length > 1) {
166
- return links.sort(function (a, b) {
167
- return b.length - a.length;
168
- })[0];
169
- }
170
- else {
171
- return links[0];
172
- }
173
- });
174
- }
175
- }
176
- exports.EmailHelper = EmailHelper;
177
- exports.default = new EmailHelper();
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.EmailHelper = void 0;
16
+ const log_service_1 = __importDefault(require("../../auxta/services/log.service"));
17
+ const AuxGoogleAuth_1 = require("./AuxGoogleAuth");
18
+ const AuxTA_1 = require("../../AuxTA");
19
+ const base64 = require('js-base64');
20
+ const MailComposer = require('nodemailer/lib/mail-composer');
21
+ class EmailHelper {
22
+ verifyEmail(from_name, from_email, subject, body, link = false) {
23
+ return __awaiter(this, void 0, void 0, function* () {
24
+ yield AuxGoogleAuth_1.AuxGoogleAuth.setup();
25
+ let timeoutCount = 12000;
26
+ while (timeoutCount <= 60000) {
27
+ const res = yield AuxGoogleAuth_1.AuxGoogleAuth.gmailClient.users.messages.list({
28
+ userId: "me",
29
+ maxResults: 3
30
+ });
31
+ const messagesIds = res.data.messages;
32
+ if (!messagesIds || messagesIds.length === 0) {
33
+ throw new Error('No messagesIds found.');
34
+ }
35
+ for (const messageId of messagesIds) {
36
+ if (messageId.id) {
37
+ const gmailResponse = yield AuxGoogleAuth_1.AuxGoogleAuth.gmailClient.users.messages.get({
38
+ userId: "me",
39
+ id: messageId.id.toString(),
40
+ format: 'FULL'
41
+ });
42
+ if (gmailResponse.data.payload && gmailResponse.data.id && gmailResponse.data.threadId) {
43
+ const message_sender = this.getHeader('from', gmailResponse);
44
+ const message_subject = this.getHeader('subject', gmailResponse);
45
+ const message_body = this.getBody(subject, gmailResponse);
46
+ if (message_sender.toLocaleLowerCase().includes(from_email) && message_sender.toLocaleLowerCase().includes(from_name.toLocaleLowerCase()) &&
47
+ message_subject.toLocaleLowerCase().includes(subject.toLocaleLowerCase()) && message_body.toLocaleLowerCase().includes(body.toLocaleLowerCase())) {
48
+ log_service_1.default.push('Then', `Email from: ${from_name} ${from_email} with subject: ${subject} and body: ${body} is found`, AuxTA_1.StepStatus.PASSED);
49
+ yield AuxGoogleAuth_1.AuxGoogleAuth.gmailClient.users.messages.modify({
50
+ userId: "me",
51
+ id: gmailResponse.data.id,
52
+ requestBody: {
53
+ 'addLabelIds': [],
54
+ 'removeLabelIds': ['UNREAD']
55
+ }
56
+ });
57
+ if (link) {
58
+ const html_link = yield this.getUrl(message_body);
59
+ return {
60
+ id: gmailResponse.data.id,
61
+ threadId: gmailResponse.data.threadId,
62
+ link: html_link
63
+ };
64
+ }
65
+ return { id: gmailResponse.data.id, threadId: gmailResponse.data.threadId, link: '' };
66
+ }
67
+ }
68
+ break;
69
+ }
70
+ }
71
+ yield new Promise(r => setTimeout(r, timeoutCount));
72
+ timeoutCount += 12000;
73
+ }
74
+ yield log_service_1.default.push('Then', `Email from: ${from_name} ${from_email} with subject: ${subject} and body: ${body} is found`, AuxTA_1.StepStatus.FAILED);
75
+ });
76
+ }
77
+ sendEmail(to, subject, body) {
78
+ return __awaiter(this, void 0, void 0, function* () {
79
+ yield AuxGoogleAuth_1.AuxGoogleAuth.setup();
80
+ const options = {
81
+ to: to,
82
+ from: this.getCurrentUserEmail(),
83
+ subject: subject,
84
+ html: body
85
+ };
86
+ yield EmailHelper.send(options);
87
+ });
88
+ }
89
+ replyEmail(id, threadId, body) {
90
+ return __awaiter(this, void 0, void 0, function* () {
91
+ yield AuxGoogleAuth_1.AuxGoogleAuth.setup();
92
+ const gmailResponse = yield AuxGoogleAuth_1.AuxGoogleAuth.gmailClient.users.messages.get({
93
+ userId: "me",
94
+ id: id,
95
+ format: 'FULL'
96
+ });
97
+ if (gmailResponse.data.payload) {
98
+ const message_subject = this.getHeader('subject', gmailResponse);
99
+ const message_messageID = this.getHeader('Message-ID', gmailResponse);
100
+ const reply_to = this.getHeader('reply-to', gmailResponse);
101
+ const options = {
102
+ to: reply_to,
103
+ from: this.getCurrentUserEmail(),
104
+ subject: `Re: ${message_subject}`,
105
+ references: message_messageID,
106
+ inReplyTo: [message_messageID],
107
+ html: body
108
+ };
109
+ yield EmailHelper.send(options, threadId);
110
+ }
111
+ });
112
+ }
113
+ static send(options, threadId) {
114
+ return __awaiter(this, void 0, void 0, function* () {
115
+ const mailComposer = new MailComposer(options);
116
+ const message = yield mailComposer.compile().build();
117
+ const encodeMessage = Buffer.from(message).toString('base64').replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
118
+ yield AuxGoogleAuth_1.AuxGoogleAuth.gmailClient.users.messages.send({
119
+ userId: "me",
120
+ requestBody: {
121
+ threadId: threadId,
122
+ raw: encodeMessage
123
+ }
124
+ });
125
+ });
126
+ }
127
+ getHeader(value, headers) {
128
+ for (const header of headers.data.payload.headers) {
129
+ if (header.name.toLocaleLowerCase() === value.toLocaleLowerCase()) {
130
+ return header.value;
131
+ }
132
+ }
133
+ }
134
+ getBody(subject, gmailResponse) {
135
+ try {
136
+ const body = gmailResponse.data.payload.parts[0].body.data;
137
+ if (body) {
138
+ return base64.decode(body);
139
+ }
140
+ else {
141
+ return '';
142
+ }
143
+ }
144
+ catch (e) {
145
+ console.log(e);
146
+ throw new Error(`Email with subject: ${subject} body ${gmailResponse.data.payload.parts[0].body.data} is empty`);
147
+ }
148
+ }
149
+ getCurrentUserEmail() {
150
+ return __awaiter(this, void 0, void 0, function* () {
151
+ yield AuxGoogleAuth_1.AuxGoogleAuth.setup();
152
+ const profile = yield AuxGoogleAuth_1.AuxGoogleAuth.gmailClient.users.getProfile({ userId: "me" });
153
+ return profile.data.emailAddress;
154
+ });
155
+ }
156
+ getUrl(body) {
157
+ return __awaiter(this, void 0, void 0, function* () {
158
+ const links = [];
159
+ const split = body.split('\r\n\r\n');
160
+ for (const splitElement of split) {
161
+ if (splitElement.toString().startsWith('https')) {
162
+ links.push(splitElement);
163
+ }
164
+ }
165
+ if (links.length > 1) {
166
+ return links.sort(function (a, b) {
167
+ return b.length - a.length;
168
+ })[0];
169
+ }
170
+ else {
171
+ return links[0];
172
+ }
173
+ });
174
+ }
175
+ }
176
+ exports.EmailHelper = EmailHelper;
177
+ exports.default = new EmailHelper();
@@ -1,6 +1,6 @@
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
+ 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 +1,89 @@
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();
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();
@@ -1,25 +1,25 @@
1
- import { UploadModel } from "../auxta/models/upload.model";
2
- import puppeteer = require("puppeteer");
3
- export declare class Puppeteer {
4
- defaultPage: puppeteer.Page;
5
- private browser;
6
- startBrowser(): Promise<void>;
7
- close(): Promise<void>;
8
- run(event: any, callback: any, featureName?: string, scenarioName?: string, uploadModel?: UploadModel): Promise<{
9
- nextSuites?: undefined;
10
- reportId?: undefined;
11
- currentSuite?: undefined;
12
- retries?: undefined;
13
- } | {
14
- nextSuites: string[];
15
- reportId: string | undefined;
16
- currentSuite: string | undefined;
17
- retries: string;
18
- } | {
19
- statusCode: number;
20
- } | undefined>;
21
- runRPA(event: any, callback: any, uploadModel?: UploadModel, close?: boolean): Promise<any>;
22
- private static setupHeader;
23
- }
24
- declare const _default: Puppeteer;
25
- export default _default;
1
+ import { UploadModel } from "../auxta/models/upload.model";
2
+ import puppeteer = require("puppeteer");
3
+ export declare class Puppeteer {
4
+ defaultPage: puppeteer.Page;
5
+ private browser;
6
+ startBrowser(): Promise<void>;
7
+ close(): Promise<void>;
8
+ run(event: any, callback: any, featureName?: string, scenarioName?: string, uploadModel?: UploadModel): Promise<{
9
+ nextSuites?: undefined;
10
+ reportId?: undefined;
11
+ currentSuite?: undefined;
12
+ retries?: undefined;
13
+ } | {
14
+ nextSuites: string[];
15
+ reportId: string | undefined;
16
+ currentSuite: string | undefined;
17
+ retries: string;
18
+ } | {
19
+ statusCode: number;
20
+ } | undefined>;
21
+ runRPA(event: any, callback: any, uploadModel?: UploadModel, close?: boolean): Promise<any>;
22
+ private static setupHeader;
23
+ }
24
+ declare const _default: Puppeteer;
25
+ export default _default;