@auxcode/auxta 0.3.3 → 0.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@auxcode/auxta",
3
- "version": "0.3.3",
3
+ "version": "0.3.7",
4
4
  "description": "",
5
5
  "main": "src/AuxTA.ts",
6
6
  "scripts": {
package/src/AuxTA.ts CHANGED
@@ -62,14 +62,14 @@ class AuxTA extends FunctionHelper {
62
62
  if (overrideConfig) {
63
63
  if (overrideConfig.digitalProduct) this.uploadModel.digitalProduct = overrideConfig.digitalProduct
64
64
  if (overrideConfig.environment) this.uploadModel.environment = overrideConfig.environment
65
- if (overrideConfig.baseUrl) this.uploadModel.baseUrl = overrideConfig.baseUrl
65
+ if (overrideConfig.baseURL) this.uploadModel.baseUrl = overrideConfig.baseURL
66
66
  this.config = setupOverrideConfig(overrideConfig)
67
67
  }
68
68
  }
69
69
 
70
70
  public async startBrowser(event: any, callback: any, feature: string, scenario: string, overrideConfig?: any, singleFeature = false) {
71
71
  this.changeModelData(overrideConfig);
72
- if (singleFeature) {
72
+ if (singleFeature && process.env.ENVIRONMENT !== 'LOCAL') {
73
73
  if (process.env.ENVIRONMENT === 'LIVE' && event.queryStringParameters.token !== this.config.token)
74
74
  return {statusCode: 401, message: 'Unauthorized'}
75
75
  this.uploadModel.reportId = await createEmptyReport(this.uploadModel);
@@ -24,6 +24,8 @@ export function setupConfig(jsonConfig: any) {
24
24
  export function setupOverrideConfig(overrideConfig: any){
25
25
  if (overrideConfig.baseURL) config.baseURL = overrideConfig.baseURL;
26
26
  if (overrideConfig.digitalProduct) config.digitalProduct = overrideConfig.digitalProduct;
27
+ if (overrideConfig.screenWidth) config.screenWidth = overrideConfig.screenWidth;
28
+ if (overrideConfig.screenHeight) config.screenHeight = overrideConfig.screenHeight;
27
29
  return config;
28
30
  }
29
31
 
@@ -18,25 +18,21 @@ export class FunctionHelper {
18
18
  const splitedQuotes = text.replace(/'/g, `', "'", '`)
19
19
  return `concat('${splitedQuotes}', '')`;
20
20
  }
21
-
21
+
22
22
  public async clickByText(selector: string, text: string, page = puppeteer.defaultPage) {
23
23
  const message = `I click on the '${text}' '${selector}'`;
24
24
  try{
25
- await page.waitForSelector(selector, {
26
- timeout: this.defaultTimeout
27
- });
28
- const [linkHandlers] = await page.$x(`//${selector}[. = ${this.getEscapedText(text)}]`);
25
+ const [linkHandlers] = await page.$x(`//${selector}[text() = ${this.getEscapedText(text)}]`);
29
26
 
30
27
  if (linkHandlers) {
31
- log.push('Then', message, StatusOfStep.PASSED);
32
28
  await linkHandlers.click();
29
+ log.push('Then', message, StatusOfStep.PASSED);
33
30
  return;
34
31
  }
35
32
  } catch (e){
36
33
  }
37
34
  log.push('Then', message, StatusOfStep.FAILED);
38
35
  throw new Error(message);
39
-
40
36
  }
41
37
 
42
38
  public async waitForSelectorWithText(selector: string, text: string, page = puppeteer.defaultPage) {
@@ -45,7 +41,7 @@ export class FunctionHelper {
45
41
  await page.waitForSelector(selector, {
46
42
  timeout: this.defaultTimeout
47
43
  });
48
- const linkHandlers = await page.$x(`//${selector}[. = ${this.getEscapedText(text)}]`);
44
+ const linkHandlers = await page.$x(`//${selector}[text() = ${this.getEscapedText(text)}]`);
49
45
  if (linkHandlers.length > 0) {
50
46
  log.push('And', message, StatusOfStep.PASSED);
51
47
  return true;
@@ -100,9 +96,10 @@ export class FunctionHelper {
100
96
  * @param selector - class to select
101
97
  * @param time
102
98
  * @param page
99
+ * @param log_message
103
100
  */
104
101
 
105
- public async waitForSelector(option: string, selector: string, time: number = this.defaultTimeout, page = puppeteer.defaultPage) {
102
+ public async waitForSelector(option: string, selector: string, time: number = this.defaultTimeout, page = puppeteer.defaultPage,log_message = true) {
106
103
  const message = `I check for the '${selector}' element to be ${option}`;
107
104
  try{
108
105
  await page.waitForSelector(selector, {
@@ -110,13 +107,17 @@ export class FunctionHelper {
110
107
  timeout: time
111
108
  });
112
109
  } catch (e){
113
- log.push('And', message, StatusOfStep.FAILED);
110
+ if (log_message) {
111
+ log.push('And', message, StatusOfStep.FAILED);
112
+ }
114
113
  throw new Error(message)
115
114
  }
116
- log.push('And', message, StatusOfStep.PASSED);
115
+ if (log_message) {
116
+ log.push('And', message, StatusOfStep.PASSED);
117
+ }
117
118
  }
118
119
 
119
- public async click(selector: string, page = puppeteer.defaultPage) {
120
+ public async click(selector: string, logMessages = true, page = puppeteer.defaultPage) {
120
121
  try{
121
122
  await page.waitForSelector(selector, {
122
123
  timeout: this.defaultTimeout
@@ -137,7 +138,7 @@ export class FunctionHelper {
137
138
  let message = `I am on the ${selector} page`
138
139
  if (!url.includes(selector)) {
139
140
  log.push('And', message, StatusOfStep.FAILED);
140
- throw new Error(`I am not at the '${selector}' page`)
141
+ throw new Error(message)
141
142
  }
142
143
  log.push('And', message, StatusOfStep.PASSED);
143
144
  }