@auxcode/auxta 0.3.2 → 0.3.6

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.2",
3
+ "version": "0.3.6",
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
 
@@ -22,21 +22,17 @@ export class FunctionHelper {
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;
@@ -116,12 +112,12 @@ export class FunctionHelper {
116
112
  log.push('And', message, StatusOfStep.PASSED);
117
113
  }
118
114
 
119
- public async click(selector: string, page = puppeteer.defaultPage) {
115
+ public async click(selector: string, logMessages = true, page = puppeteer.defaultPage) {
120
116
  try{
121
117
  await page.waitForSelector(selector, {
122
118
  timeout: this.defaultTimeout
123
119
  });
124
- let elementName = await puppeteer.defaultPage.$eval(selector, (e) => e.textContent);
120
+ let elementName = await page.$eval(selector, (e) => e.textContent);
125
121
  if (!elementName || elementName === ' ') elementName = selector;
126
122
  await page.click(selector);
127
123
  log.push('Then', `I click on the '${elementName}'`, StatusOfStep.PASSED);
@@ -132,12 +128,12 @@ export class FunctionHelper {
132
128
  }
133
129
  }
134
130
 
135
- public async urlContains(selector: string) {
136
- const url = puppeteer.defaultPage.url();
131
+ public async urlContains(selector: string, page = puppeteer.defaultPage) {
132
+ const url = page.url();
137
133
  let message = `I am on the ${selector} page`
138
134
  if (!url.includes(selector)) {
139
135
  log.push('And', message, StatusOfStep.FAILED);
140
- throw new Error(`I am not at the '${selector}' page`)
136
+ throw new Error(message)
141
137
  }
142
138
  log.push('And', message, StatusOfStep.PASSED);
143
139
  }