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

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,6 +13,7 @@ export interface Step {
13
13
  };
14
14
  }
15
15
  export declare class LogSteps {
16
+ AuxTA_FAILED: boolean;
16
17
  private stepLog;
17
18
  private lastStepTime;
18
19
  statusCounter: {
@@ -4,6 +4,7 @@ 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;
7
8
  this.stepLog = [];
8
9
  this.lastStepTime = new Date().getTime();
9
10
  this.statusCounter = {
@@ -29,6 +30,9 @@ class LogSteps {
29
30
  };
30
31
  }
31
32
  push(keyword, name, status, screenshot = '', imageCompareKey = '') {
33
+ if (status == status_of_step_1.StatusOfStep.FAILED) {
34
+ this.AuxTA_FAILED = true;
35
+ }
32
36
  console.log(`System log -- status: ${status} -- : ${name} `);
33
37
  this.statusCounter[status]++;
34
38
  const currentStep = new Date().getTime();
@@ -41,11 +45,11 @@ class LogSteps {
41
45
  keyword,
42
46
  name,
43
47
  imageCompareKey,
44
- result: { status, duration: currentStep - this.lastStepTime, embedding: embedding }
48
+ result: { status: (this.AuxTA_FAILED ? status_of_step_1.StatusOfStep.SKIPPED : status), duration: currentStep - this.lastStepTime, embedding: embedding }
45
49
  });
46
50
  }
47
51
  else {
48
- this.stepLog.push({ keyword, name, imageCompareKey, result: { status, duration: currentStep - this.lastStepTime } });
52
+ this.stepLog.push({ keyword, name, imageCompareKey, result: { status: (this.AuxTA_FAILED ? status_of_step_1.StatusOfStep.SKIPPED : status), duration: currentStep - this.lastStepTime } });
49
53
  }
50
54
  this.lastStepTime = currentStep;
51
55
  }
@@ -12,7 +12,6 @@ export declare class AuxGoogleAuth {
12
12
  private static authorizeHeadless;
13
13
  private static getNewToken;
14
14
  private static getNewTokenHeadless;
15
- private static LogIn;
16
15
  }
17
16
  declare const _default: AuxGoogleAuth;
18
17
  export default _default;
@@ -36,13 +36,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
36
36
  };
37
37
  Object.defineProperty(exports, "__esModule", { value: true });
38
38
  exports.AuxGoogleAuth = void 0;
39
- const config_1 = require("../../auxta/configs/config");
40
- const puppeteer_extra_1 = __importDefault(require("../../puppeteer/puppeteer-extra"));
41
39
  const code_helper_1 = __importDefault(require("../helpers/code.helper"));
42
40
  const status_of_step_1 = __importDefault(require("../../auxta/enums/status-of.step"));
43
41
  const fs = require('fs');
44
42
  const readline = require('readline');
45
43
  const process = __importStar(require("process"));
44
+ const os = __importStar(require("os"));
46
45
  const { google } = require("googleapis");
47
46
  const SCOPES = [
48
47
  'https://www.googleapis.com/auth/gmail.addons.current.action.compose',
@@ -59,9 +58,10 @@ const SCOPES = [
59
58
  ];
60
59
  const TOKEN_PATH = 'token.json';
61
60
  let TOKEN;
61
+ let TOKEN_LOCAL = { "access_token": "ya29.a0AfB_byC3wrz-fq6dH4V1TtgLoRZYUWaz4bmfSmKhrZpJ8m3fGE57f-MlNjkmsXNQq1Vlod79HxZ2Kl1Gcd7dVAeJoZe0RTvv9SoA-Epg1MfYfkHmHqUAajn0tqelMQpU_nwZsf3JVd3_gBFKBy3OSKMVeMe9ypbSxcK4aCgYKAe0SARASFQHGX2MiUdpxBp978i0lcm4cMPGOmQ0171", "refresh_token": "1//09mXy9YbxS7M-CgYIARAAGAkSNwF-L9Ir_InxbeTeFnEW-9dokuVSEZZGhgumZyglH0ls4MXruOMdpQU6Jq4oZ2b1vhQCOmkvk4Q", "scope": "https://mail.google.com/ https://www.googleapis.com/auth/gmail.labels https://www.googleapis.com/auth/gmail.addons.current.message.metadata https://www.googleapis.com/auth/gmail.addons.current.action.compose https://www.googleapis.com/auth/gmail.compose https://www.googleapis.com/auth/gmail.send https://www.googleapis.com/auth/gmail.addons.current.message.action https://www.googleapis.com/auth/gmail.modify https://www.googleapis.com/auth/gmail.insert https://www.googleapis.com/auth/gmail.readonly https://www.googleapis.com/auth/gmail.addons.current.message.readonly", "token_type": "Bearer", "expiry_date": 1702312809725 };
62
+ let TOKEN_LIVE = { "access_token": "ya29.a0AfB_byDSMJG3P21NM_Yg2Smb4zqKzqHQqsebIxZdurEM0D6ZFJc83MIBqjbLrHunQARDMGlyds91pYxPwlG8TGHG92sVJOciRVKk1FajWDgV8NB2DUaR2C1VyqMvG6u_CNOAh8ipwkyl61IV9LQRUq68Pst4IgMUIE0vaCgYKAWQSARASFQHGX2MiupiNUzT4iPGG55veqTkvyg0171", "refresh_token": "1//09-NODQSczV7oCgYIARAAGAkSNwF-L9IrH4shG3hyGtXJdadMchVIjQs5yF6pbqJ9owKzuiq2agTtall0qsspNY5fhqMYoun48EY", "scope": "https://www.googleapis.com/auth/gmail.addons.current.message.action https://www.googleapis.com/auth/gmail.compose https://www.googleapis.com/auth/gmail.modify https://www.googleapis.com/auth/gmail.readonly https://www.googleapis.com/auth/gmail.insert https://mail.google.com/ https://www.googleapis.com/auth/gmail.addons.current.message.readonly https://www.googleapis.com/auth/gmail.labels https://www.googleapis.com/auth/gmail.addons.current.message.metadata https://www.googleapis.com/auth/gmail.addons.current.action.compose https://www.googleapis.com/auth/gmail.send", "token_type": "Bearer", "expiry_date": 1702312878701 };
62
63
  let EMAIL;
63
64
  let PASSWORD;
64
- let count = 0;
65
65
  class AuxGoogleAuth {
66
66
  static get oAuth2Client() {
67
67
  return this._oAuth2Client;
@@ -81,6 +81,7 @@ class AuxGoogleAuth {
81
81
  return __awaiter(this, void 0, void 0, function* () {
82
82
  EMAIL = email;
83
83
  PASSWORD = password;
84
+ console.log(EMAIL, PASSWORD);
84
85
  });
85
86
  }
86
87
  static setupHeadless() {
@@ -120,7 +121,7 @@ class AuxGoogleAuth {
120
121
  yield this.getNewTokenHeadless(oAuth2Client);
121
122
  }
122
123
  catch (e) {
123
- yield this.getNewTokenHeadless(oAuth2Client);
124
+ code_helper_1.default.log('Then', 'Getting the existing token', status_of_step_1.default.FAILED);
124
125
  }
125
126
  });
126
127
  }
@@ -154,95 +155,22 @@ class AuxGoogleAuth {
154
155
  }
155
156
  static getNewTokenHeadless(oAuth2Client) {
156
157
  return __awaiter(this, void 0, void 0, function* () {
157
- const authUrl = oAuth2Client.generateAuthUrl({
158
- access_type: 'offline',
159
- prompt: 'consent',
160
- scope: SCOPES,
161
- });
162
- const code = yield this.LogIn(authUrl);
163
- this._oAuth2Client = yield (new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
164
- yield oAuth2Client.getToken(code, (err, token) => {
165
- if (err)
166
- return console.error('Error retrieving access token', err);
167
- oAuth2Client.setCredentials(token);
168
- TOKEN = token;
158
+ const platform = os.platform();
159
+ if (process.env.ENVIRONMENT === 'LOCAL') {
160
+ oAuth2Client.setCredentials(TOKEN_LOCAL);
161
+ this._oAuth2Client = oAuth2Client;
162
+ code_helper_1.default.log('Then', 'I login with the google account', status_of_step_1.default.PASSED);
163
+ }
164
+ if (process.env.ENVIRONMENT !== 'LOCAL') {
165
+ if (platform.includes("win32") || platform.includes("darwin")) {
166
+ oAuth2Client.setCredentials(TOKEN_LOCAL);
169
167
  this._oAuth2Client = oAuth2Client;
170
- code_helper_1.default.log('Then', 'I login with the google account', status_of_step_1.default.PASSED);
171
- resolve(oAuth2Client);
172
- });
173
- })));
174
- });
175
- }
176
- static LogIn(authUrl) {
177
- var _a, _b;
178
- return __awaiter(this, void 0, void 0, function* () {
179
- const email = EMAIL ? EMAIL : process.env.google_account;
180
- const password = PASSWORD ? PASSWORD : process.env.google_password;
181
- yield puppeteer_extra_1.default.startBrowser();
182
- let screenshot;
183
- count++;
184
- if (email && password) {
185
- const context = yield puppeteer_extra_1.default.defaultPage.browser().createIncognitoBrowserContext();
186
- const page = yield context.newPage();
187
- yield page.goto(authUrl);
188
- yield code_helper_1.default.waitForSelector('visible', '#identifierId', config_1.config.timeout, page, count >= 2);
189
- yield ((_a = (yield page.$('#identifierId'))) === null || _a === void 0 ? void 0 : _a.type(email));
190
- if (count >= 2) {
191
- screenshot = yield code_helper_1.default.screenshot(page);
192
- code_helper_1.default.log('Then', 'screenshot after #identifierId', status_of_step_1.default.PASSED, screenshot);
193
- }
194
- yield (yield page.$$('button'))[3].click();
195
- yield code_helper_1.default.timeout(5000);
196
- yield code_helper_1.default.waitForSelector('visible', 'input[type="password"]', config_1.config.timeout, page, count >= 2);
197
- yield ((_b = (yield page.$('input[type="password"]'))) === null || _b === void 0 ? void 0 : _b.type(password));
198
- if (count >= 2) {
199
- screenshot = yield code_helper_1.default.screenshot(page);
200
- code_helper_1.default.log('Then', 'screenshot after #password', status_of_step_1.default.PASSED, screenshot);
201
- }
202
- yield (yield page.$$('button'))[1].click();
203
- yield code_helper_1.default.timeout(5000);
204
- yield code_helper_1.default.waitForSelector('visible', '#headingText', config_1.config.timeout, page, count >= 2);
205
- yield code_helper_1.default.timeout(5000);
206
- if (count >= 2) {
207
- screenshot = yield code_helper_1.default.screenshot(page);
208
- code_helper_1.default.log('Then', 'screenshot after #headingText', status_of_step_1.default.PASSED, screenshot);
209
- }
210
- yield code_helper_1.default.waitForSelector('visible', 'button', config_1.config.timeout, page, count >= 2);
211
- yield (yield page.$$('button'))[2].click();
212
- yield code_helper_1.default.timeout(5000);
213
- const checkbox = yield page.$$('input[type="checkbox"]');
214
- if (checkbox.length > 0) {
215
- yield code_helper_1.default.waitForSelector('visible', 'input[type="checkbox"]', config_1.config.timeout, page, count >= 2);
216
- yield code_helper_1.default.timeout(5000);
217
- yield checkbox[0].click();
218
- if (count >= 2) {
219
- screenshot = yield code_helper_1.default.screenshot(page);
220
- code_helper_1.default.log('Then', 'screenshot after input[type="checkbox"]', status_of_step_1.default.PASSED, screenshot);
221
- }
222
- yield (yield page.$$('button'))[2].click();
223
168
  }
224
169
  else {
225
- yield code_helper_1.default.waitForSelector('visible', `div[data-email="${email.toLocaleLowerCase()}"]`, config_1.config.timeout, page, count >= 2);
226
- yield code_helper_1.default.timeout(5000);
227
- if (count >= 2) {
228
- screenshot = yield code_helper_1.default.screenshot(page);
229
- code_helper_1.default.log('Then', 'screenshot after div email', status_of_step_1.default.PASSED, screenshot);
230
- }
231
- yield code_helper_1.default.waitForSelector('visible', 'button', config_1.config.timeout, page, count >= 2);
232
- yield (yield page.$$('button'))[2].click();
170
+ oAuth2Client.setCredentials(TOKEN_LIVE);
171
+ this._oAuth2Client = oAuth2Client;
233
172
  }
234
- yield code_helper_1.default.timeout(5000);
235
- yield code_helper_1.default.waitForSelector('visible', 'body', config_1.config.timeout, page, count >= 2);
236
- const currentUrl = page.url();
237
- const code = currentUrl.substring(currentUrl.indexOf("code=") + 5, currentUrl.lastIndexOf("&"));
238
- code_helper_1.default.log('Then', 'I get the code form the url', status_of_step_1.default.PASSED);
239
- yield page.close();
240
- yield puppeteer_extra_1.default.close();
241
- return decodeURIComponent(code);
242
- }
243
- else {
244
- yield puppeteer_extra_1.default.close();
245
- throw new Error('The email or password for the google account are empty');
173
+ code_helper_1.default.log('Then', 'I login with the google account', status_of_step_1.default.PASSED);
246
174
  }
247
175
  });
248
176
  }
@@ -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<boolean>;
11
+ waitForSelectorWithText(selector: string, text: string, dotOrText?: string, page?: import("puppeteer").Page): Promise<true | undefined>;
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,6 +27,9 @@ 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
+ }
30
33
  const screenshotBuffer = yield (0, screenshot_helper_1.captureScreenshotPage)(page);
31
34
  if (screenshotBuffer) {
32
35
  return screenshotBuffer.toString('base64');
@@ -35,6 +38,10 @@ class FunctionHelper extends extend_default_page_1.ExtendDefaultPage {
35
38
  }
36
39
  screenshotCompare(key, threshold = 0.1, page = puppeteer_1.default.defaultPage) {
37
40
  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
+ }
38
45
  if (process.env.ENVIRONMENT !== 'LOCAL') {
39
46
  const screenshotBuffer = yield (0, screenshot_helper_1.captureScreenshotPage)(page);
40
47
  if (screenshotBuffer) {
@@ -63,6 +70,10 @@ class FunctionHelper extends extend_default_page_1.ExtendDefaultPage {
63
70
  clickByText(selector, text, dotOrText = '.', options = {}, page = puppeteer_1.default.defaultPage, time = this.defaultTimeout, log_message = true) {
64
71
  return __awaiter(this, void 0, void 0, function* () {
65
72
  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
+ }
66
77
  try {
67
78
  const [linkHandlers] = yield page.$x(`//${selector}[contains(${dotOrText},"${text}")]`);
68
79
  if (linkHandlers) {
@@ -74,7 +85,6 @@ class FunctionHelper extends extend_default_page_1.ExtendDefaultPage {
74
85
  if (log_message) {
75
86
  log_service_1.default.push('And', `${message}, but it didn't appear in ${time / 1000} seconds.`, status_of_step_1.StatusOfStep.FAILED);
76
87
  }
77
- throw new Error(message);
78
88
  }
79
89
  if (log_message) {
80
90
  log_service_1.default.push('And', message, status_of_step_1.StatusOfStep.PASSED);
@@ -84,6 +94,10 @@ class FunctionHelper extends extend_default_page_1.ExtendDefaultPage {
84
94
  clickByTextWithClass(class_selector, class_name, selector, text, dotOrText = '.', page = puppeteer_1.default.defaultPage) {
85
95
  return __awaiter(this, void 0, void 0, function* () {
86
96
  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
+ }
87
101
  try {
88
102
  const [linkHandlers] = yield page.$x(`//${class_selector}[contains(@class,${this.getEscapedText(class_name)})]//${selector}[contains(${dotOrText},"${text}")]`);
89
103
  if (linkHandlers) {
@@ -95,12 +109,15 @@ class FunctionHelper extends extend_default_page_1.ExtendDefaultPage {
95
109
  catch (e) {
96
110
  }
97
111
  log_service_1.default.push('Then', message, status_of_step_1.StatusOfStep.FAILED);
98
- throw new Error(message);
99
112
  });
100
113
  }
101
114
  waitForSelectorWithText(selector, text, dotOrText = '.', page = puppeteer_1.default.defaultPage) {
102
115
  return __awaiter(this, void 0, void 0, function* () {
103
116
  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
+ }
104
121
  try {
105
122
  yield page.waitForSelector(selector, {
106
123
  timeout: this.defaultTimeout
@@ -114,17 +131,23 @@ class FunctionHelper extends extend_default_page_1.ExtendDefaultPage {
114
131
  catch (e) {
115
132
  }
116
133
  log_service_1.default.push('And', message, status_of_step_1.StatusOfStep.FAILED);
117
- throw new Error(message);
118
134
  });
119
135
  }
120
136
  timeout(timeout = this.defaultTimeout, page = puppeteer_1.default.defaultPage) {
121
137
  return __awaiter(this, void 0, void 0, function* () {
138
+ if (log_service_1.default.AuxTA_FAILED) {
139
+ return;
140
+ }
122
141
  yield new Promise(r => setTimeout(r, timeout));
123
142
  });
124
143
  }
125
144
  waitForSelector(option, selector, time = this.defaultTimeout, page = puppeteer_1.default.defaultPage, log_message = true) {
126
145
  return __awaiter(this, void 0, void 0, function* () {
127
146
  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
+ }
128
151
  try {
129
152
  yield page.waitForSelector(selector, {
130
153
  [option]: true,
@@ -135,7 +158,6 @@ class FunctionHelper extends extend_default_page_1.ExtendDefaultPage {
135
158
  if (log_message) {
136
159
  log_service_1.default.push('And', `${message}, but it didn't appear in ${time / 1000} seconds.`, status_of_step_1.StatusOfStep.FAILED);
137
160
  }
138
- throw new Error(message);
139
161
  }
140
162
  if (log_message) {
141
163
  log_service_1.default.push('And', message, status_of_step_1.StatusOfStep.PASSED);
@@ -144,11 +166,14 @@ class FunctionHelper extends extend_default_page_1.ExtendDefaultPage {
144
166
  }
145
167
  urlContains(selector, page = puppeteer_1.default.defaultPage) {
146
168
  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
+ }
147
173
  const url = page.url();
148
174
  let message = `I am on the ${selector} page`;
149
175
  if (!url.includes(selector)) {
150
176
  log_service_1.default.push('And', message, status_of_step_1.StatusOfStep.FAILED);
151
- throw new Error(message);
152
177
  }
153
178
  log_service_1.default.push('And', message, status_of_step_1.StatusOfStep.PASSED);
154
179
  });
@@ -160,6 +185,9 @@ class FunctionHelper extends extend_default_page_1.ExtendDefaultPage {
160
185
  }
161
186
  emulate(phone_name, page = puppeteer_1.default.defaultPage) {
162
187
  return __awaiter(this, void 0, void 0, function* () {
188
+ if (log_service_1.default.AuxTA_FAILED) {
189
+ return;
190
+ }
163
191
  const phone = puppeteer_2.KnownDevices[phone_name];
164
192
  yield page.emulate(phone);
165
193
  });
@@ -172,6 +200,10 @@ class FunctionHelper extends extend_default_page_1.ExtendDefaultPage {
172
200
  }
173
201
  clickAndWaitForPageToBeCreated(selector, page = puppeteer_1.default.defaultPage, newPage) {
174
202
  return __awaiter(this, void 0, void 0, function* () {
203
+ if (log_service_1.default.AuxTA_FAILED) {
204
+ yield page.click(selector);
205
+ return;
206
+ }
175
207
  if (newPage) {
176
208
  const nav = new Promise(res => page.browser().on('targetcreated', res));
177
209
  yield page.click(selector);
@@ -234,7 +266,6 @@ class FunctionHelper extends extend_default_page_1.ExtendDefaultPage {
234
266
  }
235
267
  catch (e) {
236
268
  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}`);
238
269
  }
239
270
  yield this.timeout(4000);
240
271
  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;
5
+ link: string | undefined;
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,6 +22,20 @@ 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
+ }
25
39
  log_service_1.default.push('Then', `Logging in two google or getting the token`, AuxTA_1.StepStatus.PASSED);
26
40
  yield AuxGoogleAuth_1.AuxGoogleAuth.setupHeadless();
27
41
  log_service_1.default.push('Then', `Done logging in and waiting 35 seconds`, AuxTA_1.StepStatus.PASSED);
@@ -105,6 +119,9 @@ class EmailHelper {
105
119
  }
106
120
  sendEmail(to, subject, body) {
107
121
  return __awaiter(this, void 0, void 0, function* () {
122
+ if (log_service_1.default.AuxTA_FAILED) {
123
+ return;
124
+ }
108
125
  yield AuxGoogleAuth_1.AuxGoogleAuth.setupHeadless();
109
126
  const options = {
110
127
  to: to,
@@ -117,6 +134,9 @@ class EmailHelper {
117
134
  }
118
135
  replyEmail(id, threadId, body) {
119
136
  return __awaiter(this, void 0, void 0, function* () {
137
+ if (log_service_1.default.AuxTA_FAILED) {
138
+ return;
139
+ }
120
140
  yield AuxGoogleAuth_1.AuxGoogleAuth.setupHeadless();
121
141
  const gmailResponse = yield AuxGoogleAuth_1.AuxGoogleAuth.gmailClient.users.messages.get({
122
142
  userId: "me",
@@ -141,6 +161,9 @@ class EmailHelper {
141
161
  }
142
162
  static send(options, threadId) {
143
163
  return __awaiter(this, void 0, void 0, function* () {
164
+ if (log_service_1.default.AuxTA_FAILED) {
165
+ return;
166
+ }
144
167
  const mailComposer = new MailComposer(options);
145
168
  const message = yield mailComposer.compile().build();
146
169
  const encodeMessage = Buffer.from(message).toString('base64').replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
@@ -190,6 +213,9 @@ class EmailHelper {
190
213
  }
191
214
  getUrl(body) {
192
215
  return __awaiter(this, void 0, void 0, function* () {
216
+ if (log_service_1.default.AuxTA_FAILED) {
217
+ return;
218
+ }
193
219
  const httpsStartIndex = body.indexOf('https');
194
220
  const bodyHttpsStartIndexString = body.toString().substring(httpsStartIndex);
195
221
  return bodyHttpsStartIndexString.substring(0, bodyHttpsStartIndexString.indexOf(' ')).replace('"', '');
@@ -23,14 +23,55 @@ 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, click: original_click, type: original_type, waitForNetworkIdle: original_waitForNetworkIdle } = page;
26
+ const { goto: original_goto, $: original_$, $$: original_$$, 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`, status_of_step_1.StatusOfStep.PASSED);
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
+ }
29
32
  return original_goto.apply(page, arguments);
30
33
  };
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
+ };
31
68
  page.click = function click(selector, options) {
32
69
  return __awaiter(this, arguments, void 0, function* () {
33
70
  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
+ }
34
75
  yield page.waitForSelector(selector, {
35
76
  timeout: time
36
77
  });
@@ -43,7 +84,6 @@ class ExtendDefaultPage {
43
84
  catch (e) {
44
85
  const msg = `I click on the '${selector}'`;
45
86
  log_service_1.default.push('Then', msg, status_of_step_1.StatusOfStep.FAILED);
46
- throw new Error(msg);
47
87
  }
48
88
  });
49
89
  };
@@ -51,19 +91,26 @@ class ExtendDefaultPage {
51
91
  return __awaiter(this, arguments, void 0, function* () {
52
92
  let message = 'I wait for the page to load';
53
93
  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
+ }
54
98
  try {
55
99
  result = yield original_waitForNetworkIdle.apply(page, arguments);
56
100
  log_service_1.default.push('Then', message, status_of_step_1.StatusOfStep.PASSED);
57
101
  }
58
102
  catch (e) {
59
103
  log_service_1.default.push('Then', message, status_of_step_1.StatusOfStep.FAILED);
60
- throw new Error(message);
61
104
  }
62
105
  return result;
63
106
  });
64
107
  };
65
108
  page.type = function type(field, value) {
66
109
  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
+ }
67
114
  try {
68
115
  yield page.waitForSelector(field, {
69
116
  timeout: time
@@ -77,7 +124,6 @@ class ExtendDefaultPage {
77
124
  catch (e) {
78
125
  const msg = `I type '${value}' into the '${field}' field`;
79
126
  log_service_1.default.push('Then', msg, status_of_step_1.StatusOfStep.FAILED);
80
- throw new Error(msg);
81
127
  }
82
128
  });
83
129
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@auxcode/auxta",
3
- "version": "1.3.78-beta.107",
3
+ "version": "1.3.78-beta.108",
4
4
  "description": "",
5
5
  "main": "./build/AuxTA.js",
6
6
  "types": "./build/AuxTA.d.ts",