@auxcode/auxta 1.3.78-beta.108 → 1.3.78-beta.110

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.
@@ -13,7 +13,6 @@ export interface Step {
13
13
  };
14
14
  }
15
15
  export declare class LogSteps {
16
- AuxTA_FAILED: boolean;
17
16
  private stepLog;
18
17
  private lastStepTime;
19
18
  statusCounter: {
@@ -4,7 +4,6 @@ exports.LogSteps = void 0;
4
4
  const status_of_step_1 = require("../enums/status-of.step");
5
5
  class LogSteps {
6
6
  constructor() {
7
- this.AuxTA_FAILED = false;
8
7
  this.stepLog = [];
9
8
  this.lastStepTime = new Date().getTime();
10
9
  this.statusCounter = {
@@ -30,9 +29,6 @@ class LogSteps {
30
29
  };
31
30
  }
32
31
  push(keyword, name, status, screenshot = '', imageCompareKey = '') {
33
- if (status == status_of_step_1.StatusOfStep.FAILED) {
34
- this.AuxTA_FAILED = true;
35
- }
36
32
  console.log(`System log -- status: ${status} -- : ${name} `);
37
33
  this.statusCounter[status]++;
38
34
  const currentStep = new Date().getTime();
@@ -45,11 +41,11 @@ class LogSteps {
45
41
  keyword,
46
42
  name,
47
43
  imageCompareKey,
48
- result: { status: (this.AuxTA_FAILED ? status_of_step_1.StatusOfStep.SKIPPED : status), duration: currentStep - this.lastStepTime, embedding: embedding }
44
+ result: { status, duration: currentStep - this.lastStepTime, embedding: embedding }
49
45
  });
50
46
  }
51
47
  else {
52
- this.stepLog.push({ keyword, name, imageCompareKey, result: { status: (this.AuxTA_FAILED ? status_of_step_1.StatusOfStep.SKIPPED : status), duration: currentStep - this.lastStepTime } });
48
+ this.stepLog.push({ keyword, name, imageCompareKey, result: { status, duration: currentStep - this.lastStepTime } });
53
49
  }
54
50
  this.lastStepTime = currentStep;
55
51
  }
@@ -8,7 +8,7 @@ export declare class FunctionHelper extends ExtendDefaultPage {
8
8
  private getEscapedText;
9
9
  clickByText(selector: string, text: string, dotOrText?: string, options?: {}, page?: import("puppeteer").Page, time?: number, log_message?: boolean): Promise<void>;
10
10
  clickByTextWithClass(class_selector: string, class_name: string, selector: string, text: string, dotOrText?: string, page?: import("puppeteer").Page): Promise<void>;
11
- waitForSelectorWithText(selector: string, text: string, dotOrText?: string, page?: import("puppeteer").Page): Promise<true | undefined>;
11
+ waitForSelectorWithText(selector: string, text: string, dotOrText?: string, page?: import("puppeteer").Page): Promise<boolean>;
12
12
  timeout(timeout?: number, page?: import("puppeteer").Page): Promise<void>;
13
13
  waitForSelector(option: string, selector: string, time?: number, page?: import("puppeteer").Page, log_message?: boolean): Promise<void>;
14
14
  urlContains(selector: string, page?: import("puppeteer").Page): Promise<void>;
@@ -27,9 +27,6 @@ class FunctionHelper extends extend_default_page_1.ExtendDefaultPage {
27
27
  }
28
28
  screenshot(page = puppeteer_1.default.defaultPage) {
29
29
  return __awaiter(this, void 0, void 0, function* () {
30
- if (log_service_1.default.AuxTA_FAILED) {
31
- return;
32
- }
33
30
  const screenshotBuffer = yield (0, screenshot_helper_1.captureScreenshotPage)(page);
34
31
  if (screenshotBuffer) {
35
32
  return screenshotBuffer.toString('base64');
@@ -38,10 +35,6 @@ class FunctionHelper extends extend_default_page_1.ExtendDefaultPage {
38
35
  }
39
36
  screenshotCompare(key, threshold = 0.1, page = puppeteer_1.default.defaultPage) {
40
37
  return __awaiter(this, void 0, void 0, function* () {
41
- if (log_service_1.default.AuxTA_FAILED) {
42
- log_service_1.default.push('Then', `I compare screenshots with key ${key}`, status_of_step_1.StatusOfStep.SKIPPED, undefined, key);
43
- return;
44
- }
45
38
  if (process.env.ENVIRONMENT !== 'LOCAL') {
46
39
  const screenshotBuffer = yield (0, screenshot_helper_1.captureScreenshotPage)(page);
47
40
  if (screenshotBuffer) {
@@ -70,10 +63,6 @@ class FunctionHelper extends extend_default_page_1.ExtendDefaultPage {
70
63
  clickByText(selector, text, dotOrText = '.', options = {}, page = puppeteer_1.default.defaultPage, time = this.defaultTimeout, log_message = true) {
71
64
  return __awaiter(this, void 0, void 0, function* () {
72
65
  const message = `I clicked on the '${text}' '${selector}'`;
73
- if (log_service_1.default.AuxTA_FAILED) {
74
- log_service_1.default.push('And', `${message}, but it didn't appear in ${time / 1000} seconds.`, status_of_step_1.StatusOfStep.FAILED);
75
- return;
76
- }
77
66
  try {
78
67
  const [linkHandlers] = yield page.$x(`//${selector}[contains(${dotOrText},"${text}")]`);
79
68
  if (linkHandlers) {
@@ -85,6 +74,7 @@ class FunctionHelper extends extend_default_page_1.ExtendDefaultPage {
85
74
  if (log_message) {
86
75
  log_service_1.default.push('And', `${message}, but it didn't appear in ${time / 1000} seconds.`, status_of_step_1.StatusOfStep.FAILED);
87
76
  }
77
+ throw new Error(message);
88
78
  }
89
79
  if (log_message) {
90
80
  log_service_1.default.push('And', message, status_of_step_1.StatusOfStep.PASSED);
@@ -94,10 +84,6 @@ class FunctionHelper extends extend_default_page_1.ExtendDefaultPage {
94
84
  clickByTextWithClass(class_selector, class_name, selector, text, dotOrText = '.', page = puppeteer_1.default.defaultPage) {
95
85
  return __awaiter(this, void 0, void 0, function* () {
96
86
  const message = `I click on the '${text}' '${selector}'`;
97
- if (log_service_1.default.AuxTA_FAILED) {
98
- log_service_1.default.push('And', `${message}`, status_of_step_1.StatusOfStep.SKIPPED);
99
- return;
100
- }
101
87
  try {
102
88
  const [linkHandlers] = yield page.$x(`//${class_selector}[contains(@class,${this.getEscapedText(class_name)})]//${selector}[contains(${dotOrText},"${text}")]`);
103
89
  if (linkHandlers) {
@@ -109,15 +95,12 @@ class FunctionHelper extends extend_default_page_1.ExtendDefaultPage {
109
95
  catch (e) {
110
96
  }
111
97
  log_service_1.default.push('Then', message, status_of_step_1.StatusOfStep.FAILED);
98
+ throw new Error(message);
112
99
  });
113
100
  }
114
101
  waitForSelectorWithText(selector, text, dotOrText = '.', page = puppeteer_1.default.defaultPage) {
115
102
  return __awaiter(this, void 0, void 0, function* () {
116
103
  const message = `I check for '${text}' on the current page`;
117
- if (log_service_1.default.AuxTA_FAILED) {
118
- log_service_1.default.push('And', `${message}`, status_of_step_1.StatusOfStep.SKIPPED);
119
- return;
120
- }
121
104
  try {
122
105
  yield page.waitForSelector(selector, {
123
106
  timeout: this.defaultTimeout
@@ -131,23 +114,17 @@ class FunctionHelper extends extend_default_page_1.ExtendDefaultPage {
131
114
  catch (e) {
132
115
  }
133
116
  log_service_1.default.push('And', message, status_of_step_1.StatusOfStep.FAILED);
117
+ throw new Error(message);
134
118
  });
135
119
  }
136
120
  timeout(timeout = this.defaultTimeout, page = puppeteer_1.default.defaultPage) {
137
121
  return __awaiter(this, void 0, void 0, function* () {
138
- if (log_service_1.default.AuxTA_FAILED) {
139
- return;
140
- }
141
122
  yield new Promise(r => setTimeout(r, timeout));
142
123
  });
143
124
  }
144
125
  waitForSelector(option, selector, time = this.defaultTimeout, page = puppeteer_1.default.defaultPage, log_message = true) {
145
126
  return __awaiter(this, void 0, void 0, function* () {
146
127
  const message = `I checked for the '${selector}' element to be ${option}`;
147
- if (log_service_1.default.AuxTA_FAILED) {
148
- log_service_1.default.push('And', `${message}, but it didn't appear in ${time / 1000} seconds.`, status_of_step_1.StatusOfStep.SKIPPED);
149
- return;
150
- }
151
128
  try {
152
129
  yield page.waitForSelector(selector, {
153
130
  [option]: true,
@@ -158,6 +135,7 @@ class FunctionHelper extends extend_default_page_1.ExtendDefaultPage {
158
135
  if (log_message) {
159
136
  log_service_1.default.push('And', `${message}, but it didn't appear in ${time / 1000} seconds.`, status_of_step_1.StatusOfStep.FAILED);
160
137
  }
138
+ throw new Error(message);
161
139
  }
162
140
  if (log_message) {
163
141
  log_service_1.default.push('And', message, status_of_step_1.StatusOfStep.PASSED);
@@ -166,14 +144,11 @@ class FunctionHelper extends extend_default_page_1.ExtendDefaultPage {
166
144
  }
167
145
  urlContains(selector, page = puppeteer_1.default.defaultPage) {
168
146
  return __awaiter(this, void 0, void 0, function* () {
169
- if (log_service_1.default.AuxTA_FAILED) {
170
- log_service_1.default.push('And', `I am on the ${selector} page`, status_of_step_1.StatusOfStep.SKIPPED);
171
- return;
172
- }
173
147
  const url = page.url();
174
148
  let message = `I am on the ${selector} page`;
175
149
  if (!url.includes(selector)) {
176
150
  log_service_1.default.push('And', message, status_of_step_1.StatusOfStep.FAILED);
151
+ throw new Error(message);
177
152
  }
178
153
  log_service_1.default.push('And', message, status_of_step_1.StatusOfStep.PASSED);
179
154
  });
@@ -185,9 +160,6 @@ class FunctionHelper extends extend_default_page_1.ExtendDefaultPage {
185
160
  }
186
161
  emulate(phone_name, page = puppeteer_1.default.defaultPage) {
187
162
  return __awaiter(this, void 0, void 0, function* () {
188
- if (log_service_1.default.AuxTA_FAILED) {
189
- return;
190
- }
191
163
  const phone = puppeteer_2.KnownDevices[phone_name];
192
164
  yield page.emulate(phone);
193
165
  });
@@ -200,10 +172,6 @@ class FunctionHelper extends extend_default_page_1.ExtendDefaultPage {
200
172
  }
201
173
  clickAndWaitForPageToBeCreated(selector, page = puppeteer_1.default.defaultPage, newPage) {
202
174
  return __awaiter(this, void 0, void 0, function* () {
203
- if (log_service_1.default.AuxTA_FAILED) {
204
- yield page.click(selector);
205
- return;
206
- }
207
175
  if (newPage) {
208
176
  const nav = new Promise(res => page.browser().on('targetcreated', res));
209
177
  yield page.click(selector);
@@ -266,6 +234,7 @@ class FunctionHelper extends extend_default_page_1.ExtendDefaultPage {
266
234
  }
267
235
  catch (e) {
268
236
  yield this.log('Then', `I type password into the ${password_input}`, AuxTA_1.StepStatus.FAILED);
237
+ throw new Error(`I type password into the ${password_input}`);
269
238
  }
270
239
  yield this.timeout(4000);
271
240
  yield loginPage.keyboard.press('Enter');
@@ -2,7 +2,7 @@ export declare class EmailHelper {
2
2
  verifyEmail(from_name: string, from_email: string, subject: string, body: string, link?: boolean): Promise<{
3
3
  id: string;
4
4
  threadId: string;
5
- link: string | undefined;
5
+ link: string;
6
6
  } | undefined>;
7
7
  sendEmail(to: string, subject: string, body: string): Promise<void>;
8
8
  replyEmail(id: string, threadId: string, body: string): Promise<void>;
@@ -22,20 +22,6 @@ class EmailHelper {
22
22
  verifyEmail(from_name, from_email, subject, body, link = false) {
23
23
  return __awaiter(this, void 0, void 0, function* () {
24
24
  try {
25
- if (log_service_1.default.AuxTA_FAILED) {
26
- log_service_1.default.push('Then', `Logging in two google or getting the token`, AuxTA_1.StepStatus.SKIPPED);
27
- log_service_1.default.push('Then', `Done logging in and waiting 35 seconds`, AuxTA_1.StepStatus.SKIPPED);
28
- log_service_1.default.push('Then', `Getting the last 20 emails`, AuxTA_1.StepStatus.SKIPPED);
29
- log_service_1.default.push('Then', `Entering main for`, AuxTA_1.StepStatus.SKIPPED);
30
- log_service_1.default.push('Then', `I check payload && id && threadId`, AuxTA_1.StepStatus.SKIPPED);
31
- log_service_1.default.push('Then', `I got message_sender`, AuxTA_1.StepStatus.SKIPPED);
32
- log_service_1.default.push('Then', `I got message_body`, AuxTA_1.StepStatus.SKIPPED);
33
- log_service_1.default.push('Then', `I got message_body`, AuxTA_1.StepStatus.SKIPPED);
34
- log_service_1.default.push('Then', `Email from: ${from_name} ${from_email} with subject: ${subject} and body: ${body} is found`, AuxTA_1.StepStatus.SKIPPED);
35
- log_service_1.default.push('Then', `I got modify email`, AuxTA_1.StepStatus.SKIPPED);
36
- log_service_1.default.push('Then', `I get html lik`, AuxTA_1.StepStatus.SKIPPED);
37
- log_service_1.default.push('Then', `I deleted email`, AuxTA_1.StepStatus.SKIPPED);
38
- }
39
25
  log_service_1.default.push('Then', `Logging in two google or getting the token`, AuxTA_1.StepStatus.PASSED);
40
26
  yield AuxGoogleAuth_1.AuxGoogleAuth.setupHeadless();
41
27
  log_service_1.default.push('Then', `Done logging in and waiting 35 seconds`, AuxTA_1.StepStatus.PASSED);
@@ -119,9 +105,6 @@ class EmailHelper {
119
105
  }
120
106
  sendEmail(to, subject, body) {
121
107
  return __awaiter(this, void 0, void 0, function* () {
122
- if (log_service_1.default.AuxTA_FAILED) {
123
- return;
124
- }
125
108
  yield AuxGoogleAuth_1.AuxGoogleAuth.setupHeadless();
126
109
  const options = {
127
110
  to: to,
@@ -134,9 +117,6 @@ class EmailHelper {
134
117
  }
135
118
  replyEmail(id, threadId, body) {
136
119
  return __awaiter(this, void 0, void 0, function* () {
137
- if (log_service_1.default.AuxTA_FAILED) {
138
- return;
139
- }
140
120
  yield AuxGoogleAuth_1.AuxGoogleAuth.setupHeadless();
141
121
  const gmailResponse = yield AuxGoogleAuth_1.AuxGoogleAuth.gmailClient.users.messages.get({
142
122
  userId: "me",
@@ -161,9 +141,6 @@ class EmailHelper {
161
141
  }
162
142
  static send(options, threadId) {
163
143
  return __awaiter(this, void 0, void 0, function* () {
164
- if (log_service_1.default.AuxTA_FAILED) {
165
- return;
166
- }
167
144
  const mailComposer = new MailComposer(options);
168
145
  const message = yield mailComposer.compile().build();
169
146
  const encodeMessage = Buffer.from(message).toString('base64').replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
@@ -213,9 +190,6 @@ class EmailHelper {
213
190
  }
214
191
  getUrl(body) {
215
192
  return __awaiter(this, void 0, void 0, function* () {
216
- if (log_service_1.default.AuxTA_FAILED) {
217
- return;
218
- }
219
193
  const httpsStartIndex = body.indexOf('https');
220
194
  const bodyHttpsStartIndexString = body.toString().substring(httpsStartIndex);
221
195
  return bodyHttpsStartIndexString.substring(0, bodyHttpsStartIndexString.indexOf(' ')).replace('"', '');
@@ -23,55 +23,14 @@ class ExtendDefaultPage {
23
23
  extend_page_functions(page, time = this.defaultTimeout) {
24
24
  return __awaiter(this, void 0, void 0, function* () {
25
25
  this.defaultTimeout = config_1.config.timeout;
26
- const { goto: original_goto, $: original_$, $$: original_$$, click: original_click, type: original_type, waitForNetworkIdle: original_waitForNetworkIdle } = page;
26
+ const { goto: original_goto, click: original_click, type: original_type, waitForNetworkIdle: original_waitForNetworkIdle } = page;
27
27
  page.goto = function goto(url, options) {
28
- log_service_1.default.push('Then', `I go to the '${url}' page`, log_service_1.default.AuxTA_FAILED ? status_of_step_1.StatusOfStep.SKIPPED : status_of_step_1.StatusOfStep.PASSED);
29
- if (log_service_1.default.AuxTA_FAILED) {
30
- return;
31
- }
28
+ log_service_1.default.push('Then', `I go to the '${url}' page`, status_of_step_1.StatusOfStep.PASSED);
32
29
  return original_goto.apply(page, arguments);
33
30
  };
34
- page.$ = function $(selector) {
35
- if (log_service_1.default.AuxTA_FAILED) {
36
- return;
37
- }
38
- return original_$.apply(page, arguments);
39
- };
40
- page.$$ = function $$(selector) {
41
- if (log_service_1.default.AuxTA_FAILED) {
42
- return;
43
- }
44
- original_$$.click = function click(selector, options) {
45
- return __awaiter(this, arguments, void 0, function* () {
46
- try {
47
- if (log_service_1.default.AuxTA_FAILED) {
48
- log_service_1.default.push('Then', `I click on the '${selector}'`, status_of_step_1.StatusOfStep.SKIPPED);
49
- return;
50
- }
51
- yield page.waitForSelector(selector, {
52
- timeout: time
53
- });
54
- let elementName = yield page.$eval(selector, (e) => e.textContent);
55
- if (!elementName || elementName === ' ')
56
- elementName = selector;
57
- yield original_$$.apply(page, arguments);
58
- log_service_1.default.push('Then', `I click on the '${elementName}'`, status_of_step_1.StatusOfStep.PASSED);
59
- }
60
- catch (e) {
61
- const msg = `I click on the '${selector}'`;
62
- log_service_1.default.push('Then', msg, status_of_step_1.StatusOfStep.FAILED);
63
- }
64
- });
65
- };
66
- return original_$$.apply(page, arguments);
67
- };
68
31
  page.click = function click(selector, options) {
69
32
  return __awaiter(this, arguments, void 0, function* () {
70
33
  try {
71
- if (log_service_1.default.AuxTA_FAILED) {
72
- log_service_1.default.push('Then', `I click on the '${selector}'`, status_of_step_1.StatusOfStep.SKIPPED);
73
- return;
74
- }
75
34
  yield page.waitForSelector(selector, {
76
35
  timeout: time
77
36
  });
@@ -84,6 +43,7 @@ class ExtendDefaultPage {
84
43
  catch (e) {
85
44
  const msg = `I click on the '${selector}'`;
86
45
  log_service_1.default.push('Then', msg, status_of_step_1.StatusOfStep.FAILED);
46
+ throw new Error(msg);
87
47
  }
88
48
  });
89
49
  };
@@ -91,26 +51,19 @@ class ExtendDefaultPage {
91
51
  return __awaiter(this, arguments, void 0, function* () {
92
52
  let message = 'I wait for the page to load';
93
53
  let result;
94
- if (log_service_1.default.AuxTA_FAILED) {
95
- log_service_1.default.push('Then', message, status_of_step_1.StatusOfStep.SKIPPED);
96
- return;
97
- }
98
54
  try {
99
55
  result = yield original_waitForNetworkIdle.apply(page, arguments);
100
56
  log_service_1.default.push('Then', message, status_of_step_1.StatusOfStep.PASSED);
101
57
  }
102
58
  catch (e) {
103
59
  log_service_1.default.push('Then', message, status_of_step_1.StatusOfStep.FAILED);
60
+ throw new Error(message);
104
61
  }
105
62
  return result;
106
63
  });
107
64
  };
108
65
  page.type = function type(field, value) {
109
66
  return __awaiter(this, arguments, void 0, function* () {
110
- if (log_service_1.default.AuxTA_FAILED) {
111
- log_service_1.default.push('Then', `I type '${value}' into the '${field}' field`, status_of_step_1.StatusOfStep.SKIPPED);
112
- return;
113
- }
114
67
  try {
115
68
  yield page.waitForSelector(field, {
116
69
  timeout: time
@@ -124,6 +77,7 @@ class ExtendDefaultPage {
124
77
  catch (e) {
125
78
  const msg = `I type '${value}' into the '${field}' field`;
126
79
  log_service_1.default.push('Then', msg, status_of_step_1.StatusOfStep.FAILED);
80
+ throw new Error(msg);
127
81
  }
128
82
  });
129
83
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@auxcode/auxta",
3
- "version": "1.3.78-beta.108",
3
+ "version": "1.3.78-beta.110",
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.5.2",
27
+ "puppeteer": "^21.6.0",
28
28
  "readline": "^1.3.0",
29
29
  "typescript": "^5.2.2",
30
30
  "puppeteer-extra": "^3.3.6",