@auxcode/auxta 0.3.5 → 0.3.9

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.5",
3
+ "version": "0.3.9",
4
4
  "description": "",
5
5
  "main": "src/AuxTA.ts",
6
6
  "scripts": {
@@ -18,11 +18,11 @@ export class FunctionHelper {
18
18
  const splitedQuotes = text.replace(/'/g, `', "'", '`)
19
19
  return `concat('${splitedQuotes}', '')`;
20
20
  }
21
-
22
- public async clickByText(selector: string, text: string, page = puppeteer.defaultPage) {
21
+
22
+ public async clickByText(selector: string, text: string, page = puppeteer.defaultPage, dotOrText = '.') {
23
23
  const message = `I click on the '${text}' '${selector}'`;
24
24
  try{
25
- const [linkHandlers] = await page.$x(`//${selector}[. = ${this.getEscapedText(text)}]`);
25
+ const [linkHandlers] = await page.$x(`//${selector}[${dotOrText} = ${this.getEscapedText(text)}]`);
26
26
 
27
27
  if (linkHandlers) {
28
28
  await linkHandlers.click();
@@ -35,13 +35,13 @@ export class FunctionHelper {
35
35
  throw new Error(message);
36
36
  }
37
37
 
38
- public async waitForSelectorWithText(selector: string, text: string, page = puppeteer.defaultPage) {
38
+ public async waitForSelectorWithText(selector: string, text: string, page = puppeteer.defaultPage, dotOrText = '.') {
39
39
  const message = `I check for '${text}' on the current page`;
40
40
  try{
41
41
  await page.waitForSelector(selector, {
42
42
  timeout: this.defaultTimeout
43
43
  });
44
- const linkHandlers = await page.$x(`//${selector}[. = ${this.getEscapedText(text)}]`);
44
+ const linkHandlers = await page.$x(`//${selector}[${dotOrText} = ${this.getEscapedText(text)}]`);
45
45
  if (linkHandlers.length > 0) {
46
46
  log.push('And', message, StatusOfStep.PASSED);
47
47
  return true;
@@ -96,9 +96,10 @@ export class FunctionHelper {
96
96
  * @param selector - class to select
97
97
  * @param time
98
98
  * @param page
99
+ * @param log_message
99
100
  */
100
101
 
101
- 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) {
102
103
  const message = `I check for the '${selector}' element to be ${option}`;
103
104
  try{
104
105
  await page.waitForSelector(selector, {
@@ -106,10 +107,14 @@ export class FunctionHelper {
106
107
  timeout: time
107
108
  });
108
109
  } catch (e){
109
- log.push('And', message, StatusOfStep.FAILED);
110
+ if (log_message) {
111
+ log.push('And', message, StatusOfStep.FAILED);
112
+ }
110
113
  throw new Error(message)
111
114
  }
112
- log.push('And', message, StatusOfStep.PASSED);
115
+ if (log_message) {
116
+ log.push('And', message, StatusOfStep.PASSED);
117
+ }
113
118
  }
114
119
 
115
120
  public async click(selector: string, logMessages = true, page = puppeteer.defaultPage) {
@@ -64,7 +64,7 @@ export class Puppeteer {
64
64
  .on('response', response =>
65
65
  consoleStack.push(`${response.status()} ${response.url()}`))
66
66
  .on('requestfailed', request =>
67
- consoleStack.push(`${request.failure().errorText} ${request.url()}`))
67
+ consoleStack.push(`${request.failure() !== null ? request.failure()?.errorText : ""} ${request.url()}`))
68
68
  await callback(event)
69
69
  log.push('When', `Finished puppeteer process`, StatusOfStep.PASSED);
70
70
  } catch (err) {