vita-playwright 1.2.3 → 1.2.4

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/README.md CHANGED
@@ -27,13 +27,12 @@ VITA Playwright helpers are written in Typescript with playwright support and a
27
27
  - [uploadAFile](#uploadafile)
28
28
  - [getElementRefByRole](#getelementrefbyrole)
29
29
  - [Utilities](#utilities)
30
- - [Excel Utilities](#excel-utilities)
30
+ - [Document Utilities](#document-utilities)
31
31
  - [readData](#readdata)
32
32
  - [readDataFromExcelorCSV](#readdatafromexcelorcsv)
33
33
  - [filterData](#filterdata)
34
34
  - [updateExcelData](#updateexceldata)
35
35
  - [deleteAllFilesUnderDir](#deleteallfilesunderdir)
36
- - [PDF Utilities](#pdf-utilities)
37
36
  - [readPdfFile](#readpdffile)
38
37
  - [Lighthouse Utilities](#lighthouse-utilities)
39
38
  - [auditLightHouse](#auditlighthouse)
@@ -76,15 +75,73 @@ const postResponse = await ApiHelper.post(url, header, payload);
76
75
  ```
77
76
  #### ApiHelpers.post
78
77
  ```ts
79
- // will be added in next versions.
78
+ /**
79
+ * @description: Post call with endpoint, headers and data.
80
+ * @param {string} apiEndPoint - API end point.
81
+ * @param {string} headers - headers contains authentication keys, application type etc..
82
+ * @param {string} payload - payload data
83
+ * @returns {Promise<reponse>} - returns Promise of reponse
84
+ */
85
+ import { ApiHelper } from "vita-playwright";
86
+ const headers= {
87
+ "content-type": "application/json; charset=utf-8",
88
+ "Accept": "*/*"
89
+ };
90
+ const payload = {
91
+ "key":"value"
92
+ };
93
+ const apiEndPoint = "https://admin.googleapis.com/discovery/rest?version=datatransfer_v1";
94
+
95
+ await ApiHelper.post(
96
+ apiEndPoint,
97
+ headers,
98
+ payload
99
+ );
80
100
  ```
81
101
  #### ApiHelpers.get
82
102
  ```ts
83
- // will be added in next versions.
103
+ /**
104
+ * @description: Get call with endpoint and headers.
105
+ * @param {string} apiEndPoint - API end point.
106
+ * @param {string} headers - headers contains authentication keys, application type etc..
107
+ * @returns {Promise<reponse>} - returns Promise of reponse
108
+ */
109
+ import { ApiHelper } from "vita-playwright";
110
+ const headers= {
111
+ "content-type": "application/json; charset=utf-8",
112
+ "Accept": "*/*"
113
+ };
114
+ const apiEndPoint = "https://admin.googleapis.com/discovery/rest?version=datatransfer_v1";
115
+
116
+ await ApiHelper.get(
117
+ apiEndPoint,
118
+ headers,
119
+ );
84
120
  ```
85
121
  #### ApiHelpers.put
86
122
  ```ts
87
- // will be added in next versions.
123
+ /**
124
+ * @description: Put call with endpoint, headers and data and it will insert the data.
125
+ * @param {string} apiEndPoint - API end point.
126
+ * @param {string} headers - headers contains authentication keys, application type etc..
127
+ * @param {string} payload - payload data
128
+ * @returns {Promise<reponse>} - returns Promise of reponse
129
+ */
130
+ import { ApiHelper } from "vita-playwright";
131
+ const headers= {
132
+ "content-type": "application/json; charset=utf-8",
133
+ "Accept": "*/*"
134
+ };
135
+ const data = {
136
+ "key":"value"
137
+ };
138
+ const apiEndPoint = "https://admin.googleapis.com/discovery/rest?version=datatransfer_v1";
139
+
140
+ await ApiHelper.put(
141
+ apiEndPoint,
142
+ headers,
143
+ data
144
+ );
88
145
  ```
89
146
 
90
147
  ### UI Helpers
@@ -120,7 +177,13 @@ __Note__: getElementRefByRole() method will work for all types of roles, example
120
177
  * @param {string} data - Text to be set to inputbox
121
178
  * @returns {Promise<void>} - returns Promise of void
122
179
  */
123
- async filltheData(locator: any, data: any)
180
+ async filltheData(locator: any, data: any);
181
+
182
+ Usage:
183
+ import { UIHelper } from 'vita-playwright'
184
+ class UserClass extends UIHelper{
185
+ await this.filltheData("locator/xpath/css selector", "data to set into inputbox");
186
+ }
124
187
  ```
125
188
  #### clickonWebElement
126
189
  ```ts
@@ -130,6 +193,12 @@ async filltheData(locator: any, data: any)
130
193
  * @returns {Promise<void>} - returns Promise of void
131
194
  */
132
195
  async clickonWebElement(locator: any)
196
+
197
+ Usage:
198
+ import { UIHelper } from 'vita-playwright'
199
+ class UserClass extends UIHelper{
200
+ await this.clickonWebElement("locator/xpath/css selector");
201
+ }
133
202
  ```
134
203
  #### getInnerHTML
135
204
  ```ts
@@ -139,6 +208,13 @@ async clickonWebElement(locator: any)
139
208
  * @returns {string} - returns inner html string
140
209
  */
141
210
  async getInnerHTML(locator: any)
211
+
212
+ Usage:
213
+ import { UIHelper } from 'vita-playwright'
214
+ class UserClass extends UIHelper{
215
+ console.log(await this.getInnerHTML("locator/xpath/css selector"));
216
+ //output: inner HTML of given selector
217
+ }
142
218
  ```
143
219
  #### getInnerText
144
220
  ```ts
@@ -148,6 +224,13 @@ async getInnerHTML(locator: any)
148
224
  * @returns {string} - returns inner text string
149
225
  */
150
226
  async getInnerText(locator: any)
227
+
228
+ Usage:
229
+ import { UIHelper } from 'vita-playwright'
230
+ class UserClass extends UIHelper{
231
+ console.log(await this.getInnerText("locator/xpath/css selector"));
232
+ //output: inner Text of given selector
233
+ }
151
234
  ```
152
235
  #### getText
153
236
  ```ts
@@ -157,6 +240,13 @@ async getInnerText(locator: any)
157
240
  * @returns {string} - returns text string
158
241
  */
159
242
  async getText(locator: any)
243
+
244
+ Usage:
245
+ import { UIHelper } from 'vita-playwright'
246
+ class UserClass extends UIHelper{
247
+ console.log(await this.getText("locator/xpath/css selector"));
248
+ //output: Text of given selector
249
+ }
160
250
  ```
161
251
  #### getAttribute
162
252
  ```ts
@@ -166,7 +256,14 @@ async getText(locator: any)
166
256
  * @param {string} attribute - html attribute to get value
167
257
  * @returns {string} - returns text string
168
258
  */
169
- async getAttribute(locator: any, attribute: any))
259
+ async getAttribute(locator: any, attribute: any)
260
+
261
+ Usage:
262
+ import { UIHelper } from 'vita-playwright'
263
+ class UserClass extends UIHelper{
264
+ console.log(await this.getAttribute("locator/xpath/css selector", "class"));
265
+ //output: returns locator class value
266
+ }
170
267
  ```
171
268
  #### evaluateJS
172
269
  ```ts
@@ -180,6 +277,13 @@ async getAttribute(locator: any, attribute: any))
180
277
  * @returns {boolean} - returns true/false
181
278
  */
182
279
  async isElementPresent(locator: any)
280
+
281
+ Usage:
282
+ import { UIHelper } from 'vita-playwright'
283
+ class UserClass extends UIHelper{
284
+ console.log(await this.isElementPresent("locator/xpath/css selector"));
285
+ //output: returns true if given locator is present in the dom
286
+ }
183
287
  ```
184
288
  #### isElementEnabled
185
289
  ```ts
@@ -189,6 +293,13 @@ async isElementPresent(locator: any)
189
293
  * @returns {boolean} - returns true/false
190
294
  */
191
295
  async isElementEnabled(locator: any)
296
+
297
+ Usage:
298
+ import { UIHelper } from 'vita-playwright'
299
+ class UserClass extends UIHelper{
300
+ console.log(await this.isElementEnabled("locator/xpath/css selector"));
301
+ //output: returns true if given locator is enabled in the dom
302
+ }
192
303
  ```
193
304
  #### waitTillElementIsVisible
194
305
  ```ts
@@ -199,6 +310,13 @@ async isElementEnabled(locator: any)
199
310
  * @returns {Promise<void>} - returns Promise of void
200
311
  */
201
312
  async waitTillElementIsVisible(elementSelector: any, waitTime = 60000)
313
+
314
+ Usage:
315
+ import { UIHelper } from 'vita-playwright'
316
+ class UserClass extends UIHelper{
317
+ await this.waitTillElementIsVisible("locator/xpath/css selector", 100000);
318
+ //output: wait for given locator to be available in the dom
319
+ }
202
320
  ```
203
321
  #### getInputBoxValue
204
322
  ```ts
@@ -208,6 +326,13 @@ async waitTillElementIsVisible(elementSelector: any, waitTime = 60000)
208
326
  * @returns {string} - returns text string
209
327
  */
210
328
  async getInputBoxValue(locator: any)
329
+
330
+ Usage:
331
+ import { UIHelper } from 'vita-playwright'
332
+ class UserClass extends UIHelper{
333
+ console.log(await this.getInputBoxValue("locator/xpath/css selector"));
334
+ //output: returns inputbox value
335
+ }
211
336
  ```
212
337
  #### downloadAFile
213
338
  ```ts
@@ -218,6 +343,14 @@ async getInputBoxValue(locator: any)
218
343
  * @returns {Promise<void>} - returns Promise of void
219
344
  */
220
345
  async downloadAFile(downloadButton: String, filePath: string)
346
+
347
+ Usage:
348
+ import { UIHelper } from 'vita-playwright'
349
+ class UserClass extends UIHelper{
350
+ const filePath = path.resolve(config.use.downloadsPath, downloadFileName);
351
+ await this.downloadAFile(downloadButtonRef, filePath);
352
+ //will wait for download completes and saves in to given filepath with custom name
353
+ }
221
354
  ```
222
355
  #### uploadAFile
223
356
  ```ts
@@ -228,6 +361,14 @@ async downloadAFile(downloadButton: String, filePath: string)
228
361
  * @returns {Promise<void>} - returns Promise of void
229
362
  */
230
363
  async uploadAFile(uploadButton: String, uploadFilePath: String)
364
+
365
+ Usage:
366
+ import { UIHelper } from 'vita-playwright'
367
+ class UserClass extends UIHelper{
368
+ const filePath = path.resolve(config.use.downloadsPath, UploadFileName);
369
+ await this.uploadAFile(UploadButtonRef, filePath);
370
+ //will wait for upload completes
371
+ }
231
372
  ```
232
373
  #### getElementRefByRole
233
374
  ```ts
@@ -238,12 +379,20 @@ async uploadAFile(uploadButton: String, uploadFilePath: String)
238
379
  * @returns {Promise<void>} - returns Promise of void
239
380
  */
240
381
  async getElementRefByRole(roleType: string, roleName: string)
382
+
383
+ Usage:
384
+ import { UIHelper } from 'vita-playwright'
385
+ class UserClass extends UIHelper{
386
+ await this.getElementRefByRole("link", "Dashboard");
387
+ await this.getElementRefByRole("button", "Jobs");
388
+ await this.getElementRefByRole("checkbox", "jobName");
389
+ }
241
390
  ```
242
391
 
243
392
  ## Utilities
244
393
  vita-playwright also provides utilities for Excel, Pdf, Date, Email and Lighthosue for perfomace.
245
394
 
246
- ### Excel Utilities
395
+ ### Document Utilities
247
396
 
248
397
  You can access rows and columns in order to change size, hide/show, or access cells within:
249
398
 
@@ -299,9 +448,6 @@ static async updateExcelData(filePath: string, sheetname: string)
299
448
  */
300
449
  static async deleteAllFilesUnderDir(filePath: string, sheetname: string)
301
450
  ```
302
- ### PDF Utilities
303
- PDF reading related utilities
304
-
305
451
  #### readPdfFile
306
452
  ```ts
307
453
  /**
@@ -311,6 +457,7 @@ PDF reading related utilities
311
457
  */
312
458
  static async readPdfFile(filePath: string)
313
459
  ```
460
+
314
461
  ### Lighthouse Utilities
315
462
  Lighthouse utilities are used to perform Lighthouse performace testing provided by Google.
316
463
 
package/dist/index.d.ts CHANGED
@@ -3,9 +3,9 @@ import { ApiHelper } from "./src/helpers/api-helpers";
3
3
  import { TokenGenerators } from "./src/utils/api_axios";
4
4
  import { AzureStorageMethods } from "./src/utils/azure_storage_methods";
5
5
  import { Comparisions } from "./src/utils/comparisions";
6
- import { ExcelUtility } from "./src/utils/excel_utility";
6
+ import { DocumentUtility } from "./src/utils/document_utility";
7
7
  import { KeyVaultMethods } from "./src/utils/keyvault_methods";
8
8
  import { TestData } from "./src/utils/test_data";
9
9
  import { XmlToJson } from "./src/utils/xmlToJson";
10
10
  import { LightHouseUtility } from "./src/utils/lighhouse_utility";
11
- export { UIHelper, ApiHelper, TokenGenerators, AzureStorageMethods, Comparisions, ExcelUtility, KeyVaultMethods, TestData, XmlToJson, LightHouseUtility };
11
+ export { UIHelper, ApiHelper, TokenGenerators, AzureStorageMethods, Comparisions, DocumentUtility, KeyVaultMethods, TestData, XmlToJson, LightHouseUtility };
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LightHouseUtility = exports.XmlToJson = exports.TestData = exports.KeyVaultMethods = exports.ExcelUtility = exports.Comparisions = exports.AzureStorageMethods = exports.TokenGenerators = exports.ApiHelper = exports.UIHelper = void 0;
3
+ exports.LightHouseUtility = exports.XmlToJson = exports.TestData = exports.KeyVaultMethods = exports.DocumentUtility = exports.Comparisions = exports.AzureStorageMethods = exports.TokenGenerators = exports.ApiHelper = exports.UIHelper = void 0;
4
4
  const ui_helpers_1 = require("./src/helpers/ui-helpers");
5
5
  Object.defineProperty(exports, "UIHelper", { enumerable: true, get: function () { return ui_helpers_1.UIHelper; } });
6
6
  const api_helpers_1 = require("./src/helpers/api-helpers");
@@ -11,8 +11,8 @@ const azure_storage_methods_1 = require("./src/utils/azure_storage_methods");
11
11
  Object.defineProperty(exports, "AzureStorageMethods", { enumerable: true, get: function () { return azure_storage_methods_1.AzureStorageMethods; } });
12
12
  const comparisions_1 = require("./src/utils/comparisions");
13
13
  Object.defineProperty(exports, "Comparisions", { enumerable: true, get: function () { return comparisions_1.Comparisions; } });
14
- const excel_utility_1 = require("./src/utils/excel_utility");
15
- Object.defineProperty(exports, "ExcelUtility", { enumerable: true, get: function () { return excel_utility_1.ExcelUtility; } });
14
+ const document_utility_1 = require("./src/utils/document_utility");
15
+ Object.defineProperty(exports, "DocumentUtility", { enumerable: true, get: function () { return document_utility_1.DocumentUtility; } });
16
16
  const keyvault_methods_1 = require("./src/utils/keyvault_methods");
17
17
  Object.defineProperty(exports, "KeyVaultMethods", { enumerable: true, get: function () { return keyvault_methods_1.KeyVaultMethods; } });
18
18
  const test_data_1 = require("./src/utils/test_data");
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;AAAA,yDAAoD;AAYhD,yFAZK,qBAAQ,OAYL;AAXZ,2DAAsD;AAYlD,0FAZK,uBAAS,OAYL;AAXb,qDAAwD;AAYpD,gGAZK,2BAAe,OAYL;AAXnB,6EAAwE;AAYpE,oGAZK,2CAAmB,OAYL;AAXvB,2DAAwD;AAYpD,6FAZK,2BAAY,OAYL;AAXhB,6DAAyD;AAYrD,6FAZK,4BAAY,OAYL;AAXhB,mEAA+D;AAY3D,gGAZK,kCAAe,OAYL;AAXnB,qDAAiD;AAY7C,yFAZK,oBAAQ,OAYL;AAXZ,qDAAkD;AAY9C,0FAZK,qBAAS,OAYL;AAXb,qEAAkE;AAY9D,kGAZK,qCAAiB,OAYL"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;AAAA,yDAAoD;AAYhD,yFAZK,qBAAQ,OAYL;AAXZ,2DAAsD;AAYlD,0FAZK,uBAAS,OAYL;AAXb,qDAAwD;AAYpD,gGAZK,2BAAe,OAYL;AAXnB,6EAAwE;AAYpE,oGAZK,2CAAmB,OAYL;AAXvB,2DAAwD;AAYpD,6FAZK,2BAAY,OAYL;AAXhB,mEAA+D;AAY3D,gGAZK,kCAAe,OAYL;AAXnB,mEAA+D;AAY3D,gGAZK,kCAAe,OAYL;AAXnB,qDAAiD;AAY7C,yFAZK,oBAAQ,OAYL;AAXZ,qDAAkD;AAY9C,0FAZK,qBAAS,OAYL;AAXb,qEAAkE;AAY9D,kGAZK,qCAAiB,OAYL"}
@@ -4,5 +4,6 @@ export declare class DocumentUtility {
4
4
  static readDataFromExcelorCSV(filePath: string, sheetname: string): Promise<unknown[]>;
5
5
  static filterData(filePath: string, sheetName: string, filterObject: object): Promise<unknown[]>;
6
6
  static updateExcelData(filePath: string, sheetName: string, exportData: Array<object>): Promise<void>;
7
- static deleteAllFilesUnderDIr(dirPath: string): Promise<void>;
7
+ static deleteAllFilesUnderDir(dirPath: string): Promise<void>;
8
+ static readPdfFile(filePath: string): Promise<unknown>;
8
9
  }
@@ -17,6 +17,7 @@ const xlsx_1 = __importDefault(require("xlsx"));
17
17
  const lodash_1 = __importDefault(require("lodash"));
18
18
  const promises_1 = __importDefault(require("node:fs/promises"));
19
19
  const node_path_1 = __importDefault(require("node:path"));
20
+ const pdfreader_1 = require("pdfreader");
20
21
  class DocumentUtility {
21
22
  static readData(filePath) {
22
23
  return __awaiter(this, void 0, void 0, function* () {
@@ -59,13 +60,28 @@ class DocumentUtility {
59
60
  xlsx_1.default.writeFile(workbook, filePath);
60
61
  });
61
62
  }
62
- static deleteAllFilesUnderDIr(dirPath) {
63
+ static deleteAllFilesUnderDir(dirPath) {
63
64
  return __awaiter(this, void 0, void 0, function* () {
64
65
  for (const file of yield promises_1.default.readdir(dirPath)) {
65
66
  yield promises_1.default.unlink(node_path_1.default.join(dirPath, file));
66
67
  }
67
68
  });
68
69
  }
70
+ static readPdfFile(filePath) {
71
+ return __awaiter(this, void 0, void 0, function* () {
72
+ const items = [];
73
+ return new Promise((resolve, reject) => {
74
+ new pdfreader_1.PdfReader().parseFileItems(filePath, (err, item) => {
75
+ if (err)
76
+ reject(err);
77
+ else if (!item)
78
+ resolve(items);
79
+ else if (item.text)
80
+ items.push(item.text);
81
+ });
82
+ });
83
+ });
84
+ }
69
85
  }
70
86
  exports.DocumentUtility = DocumentUtility;
71
87
  //# sourceMappingURL=document_utility.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"document_utility.js","sourceRoot":"","sources":["../../../src/utils/document_utility.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,gDAAwB;AACxB,oDAAuB;AACvB,gEAAkC;AAClC,0DAA6B;AAC7B,MAAa,eAAe;IAExB,MAAM,CAAO,QAAQ,CAAC,QAAgB;;YAClC,OAAO,cAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;QACvG,CAAC;KAAA;IAED,MAAM,CAAO,sBAAsB,CAAC,QAAgB,EAAE,SAAiB;;YACnE,MAAM,QAAQ,GAAG;gBACb,GAAG,EAAE,KAAK;gBACV,MAAM,EAAE,YAAY,CAAC,oEAAoE;aAC1F,CAAA;YACH,MAAM,QAAQ,GAAG,MAAM,eAAe,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;YAC1D,MAAM,eAAe,GAAG,QAAQ,CAAC,UAAU,CAAC;YAC5C,SAAS,GAAG,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;YACvE,OAAO,cAAI,CAAC,KAAK,CAAC,aAAa,CAAC,QAAQ,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;YAE/E,wEAAwE;YACxE,2DAA2D;YAC3D,8CAA8C;YAC9C,IAAI;YACJ,2CAA2C;YAC3C,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vF,MAAM,QAAQ,GAAG,MAAM,eAAe,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;YAC1D,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,cAAI,CAAC,KAAK,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;YAClE,cAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QACvC,CAAC;KAAA;IAED,MAAM,CAAO,sBAAsB,CAAC,OAAe;;YAC/C,KAAK,MAAM,IAAI,IAAI,MAAM,kBAAE,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;gBAC1C,MAAM,kBAAE,CAAC,MAAM,CAAC,mBAAI,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC;aAC7C;QACL,CAAC;KAAA;IAED,MAAM,CAAO,WAAW,CAAC,QAAgB;;YACrC,MAAM,KAAK,GAAG,EAAE,CAAC;YACjB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;gBACnC,IAAI,qBAAS,EAAE,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;oBACnD,IAAI,GAAG;wBAAE,MAAM,CAAC,GAAG,CAAC,CAAC;yBAChB,IAAI,CAAC,IAAI;wBAAE,OAAO,CAAC,KAAK,CAAC,CAAC;yBAC1B,IAAI,IAAI,CAAC,IAAI;wBAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBAC9C,CAAC,CAAC,CAAC;YACP,CAAC,CAAC,CAAC;QACP,CAAC;KAAA;CAGJ;AA1DD,0CA0DC"}
package/index.ts CHANGED
@@ -3,7 +3,7 @@ import { ApiHelper } from "./src/helpers/api-helpers";
3
3
  import { TokenGenerators } from "./src/utils/api_axios";
4
4
  import { AzureStorageMethods } from "./src/utils/azure_storage_methods";
5
5
  import { Comparisions } from "./src/utils/comparisions";
6
- import { ExcelUtility } from "./src/utils/excel_utility";
6
+ import { DocumentUtility } from "./src/utils/document_utility";
7
7
  import { KeyVaultMethods } from "./src/utils/keyvault_methods";
8
8
  import { TestData } from "./src/utils/test_data";
9
9
  import { XmlToJson } from "./src/utils/xmlToJson";
@@ -15,7 +15,7 @@ export {
15
15
  TokenGenerators,
16
16
  AzureStorageMethods,
17
17
  Comparisions,
18
- ExcelUtility,
18
+ DocumentUtility,
19
19
  KeyVaultMethods,
20
20
  TestData,
21
21
  XmlToJson,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vita-playwright",
3
- "version": "1.2.3",
3
+ "version": "1.2.4",
4
4
  "email": "noreply_testautomation@vialto.com",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -2,7 +2,9 @@ import XLSX from 'xlsx';
2
2
  import _ from 'lodash';
3
3
  import fs from "node:fs/promises";
4
4
  import path from "node:path";
5
- export class ExcelUtility {
5
+ import { PdfReader } from "pdfreader";
6
+
7
+ export class DocumentUtility {
6
8
 
7
9
  static async readData(filePath: string) {
8
10
  return XLSX.readFile(filePath, { cellDates: true, bookVBA: true, sheetStubs: true, cellNF: true });
@@ -13,7 +15,7 @@ export class ExcelUtility {
13
15
  raw: false,
14
16
  dateNF: `yyyy/mm/dd` // <--- need dateNF in sheet_to_json options (note the escape chars)
15
17
  }
16
- const workbook = await ExcelUtility.readData(filePath);
18
+ const workbook = await DocumentUtility.readData(filePath);
17
19
  const sheet_name_list = workbook.SheetNames;
18
20
  sheetname = (sheetname === undefined ? sheet_name_list[0] : sheetname);
19
21
  return XLSX.utils.sheet_to_json(workbook.Sheets[sheet_name_list[0]], jsonOpts);
@@ -32,12 +34,12 @@ export class ExcelUtility {
32
34
  }
33
35
 
34
36
  static async filterData(filePath: string, sheetName: string, filterObject: object) {
35
- let fileData = await ExcelUtility.readData(filePath);
37
+ let fileData = await DocumentUtility.readData(filePath);
36
38
  return _.filter(XLSX.utils.sheet_to_json(fileData.Sheets[sheetName]), filterObject)
37
39
  }
38
40
 
39
41
  static async updateExcelData(filePath: string, sheetName: string, exportData: Array<object>) {
40
- const workbook = await ExcelUtility.readData(filePath);
42
+ const workbook = await DocumentUtility.readData(filePath);
41
43
  workbook.Sheets[sheetName] = XLSX.utils.json_to_sheet(exportData);
42
44
  XLSX.writeFile(workbook, filePath);
43
45
  }
@@ -48,5 +50,16 @@ export class ExcelUtility {
48
50
  }
49
51
  }
50
52
 
53
+ static async readPdfFile(filePath: string) {
54
+ const items = [];
55
+ return new Promise((resolve, reject) => {
56
+ new PdfReader().parseFileItems(filePath, (err, item) => {
57
+ if (err) reject(err);
58
+ else if (!item) resolve(items);
59
+ else if (item.text) items.push(item.text);
60
+ });
61
+ });
62
+ }
63
+
51
64
 
52
65
  }