vita-playwright 1.1.0 → 1.2.0
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 +266 -55
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/src/helpers/ui-helpers.d.ts +1 -1
- package/dist/src/helpers/ui-helpers.js +1 -1
- package/dist/src/helpers/ui-helpers.js.map +1 -1
- package/dist/src/utils/excel_utility.d.ts +8 -0
- package/dist/src/utils/excel_utility.js +71 -0
- package/dist/src/utils/excel_utility.js.map +1 -0
- package/dist/src/utils/lighhouse_utility.d.ts +1 -1
- package/dist/src/utils/lighhouse_utility.js +3 -3
- package/dist/src/utils/lighhouse_utility.js.map +1 -1
- package/dist/src/utils/pdf_utility.d.ts +2 -0
- package/dist/src/utils/pdf_utility.js +7 -0
- package/dist/src/utils/pdf_utility.js.map +1 -0
- package/index.ts +2 -2
- package/package.json +21 -17
- package/src/helpers/ui-helpers.ts +1 -1
- package/src/utils/{document_utility.ts → excel_utility.ts} +5 -5
- package/src/utils/lighhouse_utility.ts +3 -3
- package/src/utils/pdf_utility.ts +13 -0
package/README.md
CHANGED
|
@@ -1,81 +1,292 @@
|
|
|
1
|
-
# VITA
|
|
1
|
+
# VITA Playwright Helpers
|
|
2
|
+
VITA Playwright helpers are written in Typescript with playwright support and a focus on using common playwright helpers, Excel utilities and Pdf utilities.
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
4
|
+
## Table of Contents
|
|
5
|
+
- [VITA Playwright Helpers](#vita-playwright-helpers)
|
|
6
|
+
- [Table of Contents](#table-of-contents)
|
|
7
|
+
- [Installation](#installation)
|
|
8
|
+
- [Node.js](#nodejs)
|
|
9
|
+
- [Helpers](#helpers)
|
|
10
|
+
- [Api Helpers](#api-helpers)
|
|
11
|
+
- [ApiHelpers.post](#apihelperspost)
|
|
12
|
+
- [ApiHelpers.get](#apihelpersget)
|
|
13
|
+
- [ApiHelpers.put](#apihelpersput)
|
|
14
|
+
- [UI Helpers](#ui-helpers)
|
|
15
|
+
- [filltheData](#fillthedata)
|
|
16
|
+
- [clickonWebElement](#clickonwebelement)
|
|
17
|
+
- [getInnerHTML](#getinnerhtml)
|
|
18
|
+
- [getInnerText](#getinnertext)
|
|
19
|
+
- [getText](#gettext)
|
|
20
|
+
- [getAttribute](#getattribute)
|
|
21
|
+
- [evaluateJS](#evaluatejs)
|
|
22
|
+
- [isElementPresent](#iselementpresent)
|
|
23
|
+
- [isElementEnabled](#iselementenabled)
|
|
24
|
+
- [waitTillElementIsVisible](#waittillelementisvisible)
|
|
25
|
+
- [getInputBoxValue](#getinputboxvalue)
|
|
26
|
+
- [downloadAFile](#downloadafile)
|
|
27
|
+
- [uploadAFile](#uploadafile)
|
|
28
|
+
- [getElementRefByRole](#getelementrefbyrole)
|
|
29
|
+
- [Utilities](#utilities)
|
|
30
|
+
- [Excel Utilities](#excel-utilities)
|
|
31
|
+
- [readData](#readdata)
|
|
32
|
+
- [readDataFromExcelorCSV](#readdatafromexcelorcsv)
|
|
33
|
+
- [filterData](#filterdata)
|
|
34
|
+
- [updateExcelData](#updateexceldata)
|
|
35
|
+
- [deleteAllFilesUnderDir](#deleteallfilesunderdir)
|
|
36
|
+
- [PDF Utilities](#pdf-utilities)
|
|
37
|
+
- [Lighthouse Utilities](#lighthouse-utilities)
|
|
38
|
+
- [auditLightHouse](#auditlighthouse)
|
|
39
|
+
- [createLightHouseReport](#createlighthousereport)
|
|
40
|
+
- [Date Utilities](#date-utilities)
|
|
41
|
+
- [Database Utilities](#database-utilities)
|
|
42
|
+
- [sqlDBConnection](#sqldbconnection)
|
|
43
|
+
- [executeSqlQuery](#executesqlquery)
|
|
44
|
+
- [Data Comparisions](#data-comparisions)
|
|
45
|
+
- [Missing Features](#missing-features)
|
|
5
46
|
|
|
6
|
-
##
|
|
7
|
-
|
|
8
|
-
VITA playwright helpers is a helper library for dealing with utilities.
|
|
9
|
-
|
|
10
|
-
<details>
|
|
11
|
-
<summary>excel utilities</summary><br/>
|
|
12
|
-
|
|
13
|
-
### Installation
|
|
14
|
-
|
|
15
|
-
Use the package manager [npm](https://www.npmjs.com/) to install xlsx.
|
|
47
|
+
## Installation
|
|
16
48
|
|
|
49
|
+
### Node.js
|
|
17
50
|
```bash
|
|
18
|
-
npm install
|
|
51
|
+
npm install vita-playwright
|
|
19
52
|
```
|
|
53
|
+
Note that vita-playwright uses ES6 features so only Node.js v4+ is supported.
|
|
20
54
|
|
|
21
|
-
|
|
55
|
+
## Helpers
|
|
22
56
|
|
|
23
|
-
|
|
24
|
-
import path from 'node:path';
|
|
25
|
-
import { DocsReaderHelper } from '../../../helpers/docs-reader-helper';
|
|
57
|
+
vita-playwright has an [extensive methods](#api-reference) for working with playwright, excel and pdf. This section reviews the most common functions and use cases. Examples can also be found in the examples directory of the source code.
|
|
26
58
|
|
|
27
|
-
|
|
28
|
-
const pathtoExcel =path.resolve(__dirname,"../../../../resources/**/**.xlsx");
|
|
29
|
-
const excelData = await DocsReaderHelper.readDataFromExcelorCSV(pathtoExcel);
|
|
30
|
-
console.log(excelData);
|
|
59
|
+
### Api Helpers
|
|
31
60
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
})
|
|
61
|
+
To use most common API methods, you first require ApiHelper class. Then you can access methods within the ApiHelper class to use API calls.
|
|
62
|
+
```ts
|
|
63
|
+
import {ApiHelper} from 'vita-playwright';
|
|
36
64
|
|
|
65
|
+
// call static methods using classname
|
|
66
|
+
const getResponse = await ApiHelper.get(url, header);
|
|
67
|
+
const putResponse = await ApiHelper.put(url, header, payload);
|
|
68
|
+
const postResponse = await ApiHelper.post(url, header, payload);
|
|
69
|
+
```
|
|
70
|
+
#### ApiHelpers.post
|
|
71
|
+
```ts
|
|
72
|
+
// will be added in next versions.
|
|
73
|
+
```
|
|
74
|
+
#### ApiHelpers.get
|
|
75
|
+
```ts
|
|
76
|
+
// will be added in next versions.
|
|
77
|
+
```
|
|
78
|
+
#### ApiHelpers.put
|
|
79
|
+
```ts
|
|
80
|
+
// will be added in next versions.
|
|
37
81
|
```
|
|
38
|
-
<br />
|
|
39
82
|
|
|
40
|
-
|
|
83
|
+
### UI Helpers
|
|
41
84
|
|
|
42
|
-
|
|
43
|
-
|
|
85
|
+
Either you can create object or extends UIHelper to use common ui helpers by passing locators
|
|
86
|
+
```ts
|
|
87
|
+
import {UIHelper} from 'vita-playwright';
|
|
44
88
|
|
|
45
|
-
|
|
46
|
-
|
|
89
|
+
const uihelper = new UIHelpers();
|
|
90
|
+
// call static methods using classname
|
|
91
|
+
await uihelper.filltheData(locator, data);
|
|
92
|
+
await uihelper.clickonWebElement(locator);
|
|
93
|
+
await uihelper.getInnerHTML(locator);
|
|
94
|
+
await uihelper.getInnerText(locator);
|
|
95
|
+
await uihelper.getText(locator);
|
|
96
|
+
await uihelper.getAttribute(locator, attribute);
|
|
97
|
+
await uihelper.evaluateJS(jsDOM);
|
|
98
|
+
const isElementPresent = await uihelper.isElementPresent(locator);
|
|
99
|
+
const isElementEnabled = await uihelper.isElementEnabled(locator);
|
|
100
|
+
await waitTillElementIsVisible(elementSelector, waitTime);
|
|
101
|
+
const inputBoxValue = await uihelper.getIputBoxValue(locator);
|
|
102
|
+
await downloadAFile(downloadButton, downloadFilePath);
|
|
103
|
+
await uploadAFile(uploadButton, uploadFilePath);
|
|
104
|
+
const elementReference = await getElementRefByRole(roleType, roleName);
|
|
105
|
+
```
|
|
106
|
+
__Note__: getElementRefByRole() method will work for all types of roles, example: button, combobox, main, checkbox and radiobutton.
|
|
47
107
|
|
|
48
|
-
|
|
49
|
-
|
|
108
|
+
#### filltheData
|
|
109
|
+
```ts
|
|
110
|
+
// will be added in next versions.
|
|
111
|
+
```
|
|
112
|
+
#### clickonWebElement
|
|
113
|
+
```ts
|
|
114
|
+
// will be added in next versions.
|
|
115
|
+
```
|
|
116
|
+
#### getInnerHTML
|
|
117
|
+
```ts
|
|
118
|
+
// will be added in next versions.
|
|
119
|
+
```
|
|
120
|
+
#### getInnerText
|
|
121
|
+
```ts
|
|
122
|
+
// will be added in next versions.
|
|
123
|
+
```
|
|
124
|
+
#### getText
|
|
125
|
+
```ts
|
|
126
|
+
// will be added in next versions.
|
|
127
|
+
```
|
|
128
|
+
#### getAttribute
|
|
129
|
+
```ts
|
|
130
|
+
// will be added in next versions.
|
|
131
|
+
```
|
|
132
|
+
#### evaluateJS
|
|
133
|
+
```ts
|
|
134
|
+
// will be added in next versions.
|
|
135
|
+
```
|
|
136
|
+
#### isElementPresent
|
|
137
|
+
```ts
|
|
138
|
+
// will be added in next versions.
|
|
139
|
+
```
|
|
140
|
+
#### isElementEnabled
|
|
141
|
+
```ts
|
|
142
|
+
// will be added in next versions.
|
|
143
|
+
```
|
|
144
|
+
#### waitTillElementIsVisible
|
|
145
|
+
```ts
|
|
146
|
+
// will be added in next versions.
|
|
147
|
+
```
|
|
148
|
+
#### getInputBoxValue
|
|
149
|
+
```ts
|
|
150
|
+
// will be added in next versions.
|
|
151
|
+
```
|
|
152
|
+
#### downloadAFile
|
|
153
|
+
```ts
|
|
154
|
+
// will be added in next versions.
|
|
155
|
+
```
|
|
156
|
+
#### uploadAFile
|
|
157
|
+
```ts
|
|
158
|
+
// will be added in next versions.
|
|
159
|
+
```
|
|
160
|
+
#### getElementRefByRole
|
|
161
|
+
```ts
|
|
162
|
+
// will be added in next versions.
|
|
163
|
+
```
|
|
50
164
|
|
|
51
|
-
|
|
165
|
+
## Utilities
|
|
166
|
+
vita-playwright also provides utilities for Excel, Pdf, Date, Email and Lighthosue for perfomace.
|
|
52
167
|
|
|
53
|
-
|
|
168
|
+
### Excel Utilities
|
|
54
169
|
|
|
55
|
-
|
|
56
|
-
npm install xlsx
|
|
57
|
-
```
|
|
170
|
+
You can access rows and columns in order to change size, hide/show, or access cells within:
|
|
58
171
|
|
|
59
|
-
|
|
172
|
+
#### readData
|
|
173
|
+
```ts
|
|
174
|
+
/**
|
|
175
|
+
* @description: it will take excel file path as input and will return excel Workbook object.
|
|
176
|
+
* @param {string} filePath - Complete path of the excel file, example: C:/resources/****.xlsx.
|
|
177
|
+
* @returns {Promise<Workbook>} - returns Promise, if we resolves and will get Workbook object
|
|
178
|
+
*/
|
|
179
|
+
static async readData(filePath: string)
|
|
180
|
+
```
|
|
181
|
+
#### readDataFromExcelorCSV
|
|
182
|
+
```ts
|
|
183
|
+
/**
|
|
184
|
+
* @description: it will take excel file path and sheetname as input and will return array of objects.
|
|
185
|
+
* @param {string} filePath - Complete path of the excel file, example: C:/resources/****.xlsx.
|
|
186
|
+
* @param {string} sheetname - name of the sheet name and it is optional. For CSV files no need pass this parameter.
|
|
187
|
+
* @returns {Promise<Array<Object>>} - returns Promise, if we resolves and will get Array of Json objects.
|
|
188
|
+
* [{startDate: '****',endDate: '****', employeeId: '****',CompanyToken: '******'}]
|
|
189
|
+
*/
|
|
190
|
+
static async readDataFromExcelorCSV(filePath: string, sheetname: string)
|
|
191
|
+
```
|
|
192
|
+
#### filterData
|
|
193
|
+
```ts
|
|
194
|
+
/**
|
|
195
|
+
* @description: it will filter excel data and will return filtered array of objects.
|
|
196
|
+
* @param {string} filePath - Complete path of the excel file, example: C:/resources/****.xlsx.
|
|
197
|
+
* @param {string} sheetname - name of the sheet name and it is optional. For CSV files no need pass this parameter.
|
|
198
|
+
* @param {Object} filterObject - {column Name:Row value} key:value pair. example: {startDate: '****'}
|
|
199
|
+
* @returns {Promise<Array<Object>>} - returns Promise, if we resolves and will get filtered Array of Json objects.
|
|
200
|
+
* [{startDate: '****',endDate: '****', employeeId: '****',CompanyToken: '******'}]
|
|
201
|
+
*/
|
|
202
|
+
static async filterData(filePath: string, sheetname: string)
|
|
203
|
+
```
|
|
204
|
+
#### updateExcelData
|
|
205
|
+
```ts
|
|
206
|
+
/**
|
|
207
|
+
* @description: it will modify/update excel file based on input data.
|
|
208
|
+
* @param {string} filePath - Complete path of the excel file, example: C:/resources/****.xlsx.
|
|
209
|
+
* @param {string} sheetname - name of the sheet name and it is optional. For CSV files no need pass this parameter.
|
|
210
|
+
* @param {Array<Object>} exportData - excel modify data. example: [{startDate: '****',endDate: '****', employeeId: '****',CompanyToken: '******'}]
|
|
211
|
+
* @returns {Promise<void>} - returns void promise.
|
|
212
|
+
*/
|
|
213
|
+
static async updateExcelData(filePath: string, sheetname: string)
|
|
214
|
+
```
|
|
215
|
+
#### deleteAllFilesUnderDir
|
|
216
|
+
```ts
|
|
217
|
+
/**
|
|
218
|
+
* @description: it will delete all files under given directory.
|
|
219
|
+
* @param {string} dirPath - Complete path of the directory which contain file, example: C:/resources.
|
|
220
|
+
* @returns {Promise<void>} - returns void promise.
|
|
221
|
+
*/
|
|
222
|
+
static async deleteAllFilesUnderDir(filePath: string, sheetname: string)
|
|
223
|
+
```
|
|
224
|
+
### PDF Utilities
|
|
225
|
+
TODO: need to add PDF Utilities
|
|
60
226
|
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
|
|
227
|
+
```ts
|
|
228
|
+
// will be added in next versions.
|
|
229
|
+
```
|
|
230
|
+
### Lighthouse Utilities
|
|
231
|
+
Lighthouse utilities are used to perform Lighthouse performace testing provided by Google.
|
|
64
232
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
233
|
+
#### auditLightHouse
|
|
234
|
+
```ts
|
|
235
|
+
/**
|
|
236
|
+
* @description: it will take url of the web page and will calculates the performance of that web page and compare with given customThresholds. If any threashold doesn't meet the minimum value, then it test will be fail.
|
|
237
|
+
* @param {string} pageurl - url of the given page which needs to be calculated.
|
|
238
|
+
* @param {string} deviceType - type of device i.e desktop or mobile.
|
|
239
|
+
* @param {string} filename - to save the result the filename.
|
|
240
|
+
* @param {object} customThresholds - It is optional threshold object. example: {performance: 80,accessibility: 70,
|
|
241
|
+
'best-practices': 70,seo: 70, pwa: 70,} these are the default values.
|
|
242
|
+
* @param {object} format - This is optional. example: { html: true, csv:true, json: true}.
|
|
243
|
+
* @returns {Promise<void>} - returns void promise.
|
|
244
|
+
*/
|
|
245
|
+
static async auditLightHouse(pageurl: string, deviceType, filename, customThresholds = {
|
|
246
|
+
performance: 80,
|
|
247
|
+
accessibility: 70,
|
|
248
|
+
'best-practices': 70,
|
|
249
|
+
seo: 70,
|
|
250
|
+
pwa: 70,
|
|
251
|
+
}, format = { html: true })
|
|
252
|
+
```
|
|
253
|
+
#### createLightHouseReport
|
|
254
|
+
```ts
|
|
255
|
+
/**
|
|
256
|
+
* @description: it creates new index.html file which has links to all pages htnl files.
|
|
257
|
+
* @param {string} dirPath - Complete path of the directory which contains Lighthouse performace html files, example: C:/lighthouse.
|
|
258
|
+
* @param {String} savefilepath - Based on files in directory, new index.html file will be created. To save that index.html file in given filepath. example: C:/lighthouse/complateReport/
|
|
259
|
+
* @param {String} applicationName - Name of the Application
|
|
260
|
+
* @returns {Promise<void>} - returns void promise.
|
|
261
|
+
*/
|
|
262
|
+
static async createLightHouseReport(filePath: string, sheetname: string)
|
|
263
|
+
```
|
|
69
264
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
console.log(csvData);
|
|
73
|
-
})
|
|
265
|
+
### Date Utilities
|
|
266
|
+
TODO: need to add Date Utilities
|
|
74
267
|
|
|
268
|
+
```ts
|
|
269
|
+
// will be added in next versions.
|
|
75
270
|
```
|
|
76
|
-
<br />
|
|
77
|
-
</details>
|
|
78
|
-
|
|
79
|
-
</details>
|
|
80
271
|
|
|
272
|
+
### Database Utilities
|
|
273
|
+
TODO: need to add Database Utilities
|
|
274
|
+
```ts
|
|
275
|
+
// will be added in next versions
|
|
276
|
+
```
|
|
277
|
+
#### sqlDBConnection
|
|
278
|
+
```ts
|
|
279
|
+
// will be added in next versions
|
|
280
|
+
```
|
|
281
|
+
#### executeSqlQuery
|
|
282
|
+
```ts
|
|
283
|
+
// will be added in next versions
|
|
284
|
+
```
|
|
81
285
|
|
|
286
|
+
### Data Comparisions
|
|
287
|
+
TODO: need to add Data Comparisions Utilities
|
|
288
|
+
```ts
|
|
289
|
+
// will be added in next versions
|
|
290
|
+
```
|
|
291
|
+
## Missing Features
|
|
292
|
+
There are many features of playwright and other node modules needs to be added.
|
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 {
|
|
6
|
+
import { ExcelUtility } from "./src/utils/excel_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,
|
|
11
|
+
export { UIHelper, ApiHelper, TokenGenerators, AzureStorageMethods, Comparisions, ExcelUtility, 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.
|
|
3
|
+
exports.LightHouseUtility = exports.XmlToJson = exports.TestData = exports.KeyVaultMethods = exports.ExcelUtility = 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
|
|
15
|
-
Object.defineProperty(exports, "
|
|
14
|
+
const excel_utility_1 = require("./src/utils/excel_utility");
|
|
15
|
+
Object.defineProperty(exports, "ExcelUtility", { enumerable: true, get: function () { return excel_utility_1.ExcelUtility; } });
|
|
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,
|
|
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"}
|
|
@@ -11,7 +11,7 @@ export declare class UIHelper {
|
|
|
11
11
|
isElementPresent(locator: any): Promise<any>;
|
|
12
12
|
isElementEnabled(locator: any): Promise<any>;
|
|
13
13
|
waitTillElementIsVisible(elementSelector: any, waitTime?: number): Promise<void>;
|
|
14
|
-
|
|
14
|
+
getInputBoxValue(locator: any): Promise<any>;
|
|
15
15
|
downloadAFile(downloadButton: String, filePath: string): Promise<void>;
|
|
16
16
|
uploadAFile(uploadButton: String, uploadFilePath: String): Promise<void>;
|
|
17
17
|
getElementRefByRole(roleType: string, roleName: string): Promise<void>;
|
|
@@ -90,7 +90,7 @@ class UIHelper {
|
|
|
90
90
|
yield this.page.waitForSelector(elementSelector, { waitFor: 'visible', timeout: waitTime });
|
|
91
91
|
});
|
|
92
92
|
}
|
|
93
|
-
|
|
93
|
+
getInputBoxValue(locator) {
|
|
94
94
|
return __awaiter(this, void 0, void 0, function* () {
|
|
95
95
|
yield this.waitTillElementIsVisible(locator);
|
|
96
96
|
yield this.page.locator(locator).scrollIntoViewIfNeeded();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui-helpers.js","sourceRoot":"","sources":["../../../src/helpers/ui-helpers.ts"],"names":[],"mappings":";AAAA,8BAA8B;;;;;;;;;;;;AAE9B,MAAa,QAAQ;IAGjB,YAAY,IAAS;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACrB,CAAC;IAEK,WAAW,CAAC,OAAY,EAAE,IAAS;;YAErC,IAAI,IAAI,EAAE;gBACN,MAAM,IAAI,CAAC,wBAAwB,CAAC,OAAO,CAAC,CAAC;gBAC7C,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,sBAAsB,EAAE,CAAC;gBAC1D,MAAM,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cAAc,CAAC,CAAC;YAC7C,MAAM,QAAQ,GAAG,MAAM,eAAe,CAAC;YACvC,4CAA4C;YAC5C,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;YAC/C,MAAM,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QACpC,CAAC;KAAA;IAEK,WAAW,CAAC,YAAoB,EAAE,cAAsB;;YAC1D,MAAM,kBAAkB,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC;YACjE,MAAM,IAAI,CAAC,iBAAiB,CAAC,YAAY,CAAC,CAAC;YAC3C,MAAM,WAAW,GAAG,MAAM,kBAAkB,CAAC;YAC7C,MAAM,WAAW,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;QAC/C,CAAC;KAAA;IAEK,mBAAmB,CAAC,QAAgB,EAAE,QAAgB;;YACxD,MAAM,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC;QACpE,CAAC;KAAA;CAEJ;AAlHD,4BAkHC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import XLSX from 'xlsx';
|
|
2
|
+
export declare class ExcelUtility {
|
|
3
|
+
static readData(filePath: string): Promise<XLSX.WorkBook>;
|
|
4
|
+
static readDataFromExcelorCSV(filePath: string, sheetname: string): Promise<unknown[]>;
|
|
5
|
+
static filterData(filePath: string, sheetName: string, filterObject: object): Promise<unknown[]>;
|
|
6
|
+
static updateExcelData(filePath: string, sheetName: string, exportData: Array<object>): Promise<void>;
|
|
7
|
+
static deleteAllFilesUnderDir(dirPath: string): Promise<void>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.ExcelUtility = void 0;
|
|
16
|
+
const xlsx_1 = __importDefault(require("xlsx"));
|
|
17
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
18
|
+
const promises_1 = __importDefault(require("node:fs/promises"));
|
|
19
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
20
|
+
class ExcelUtility {
|
|
21
|
+
static readData(filePath) {
|
|
22
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
return xlsx_1.default.readFile(filePath, { cellDates: true, bookVBA: true, sheetStubs: true, cellNF: true });
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
static readDataFromExcelorCSV(filePath, sheetname) {
|
|
27
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
const jsonOpts = {
|
|
29
|
+
raw: false,
|
|
30
|
+
dateNF: `yyyy/mm/dd` // <--- need dateNF in sheet_to_json options (note the escape chars)
|
|
31
|
+
};
|
|
32
|
+
const workbook = yield ExcelUtility.readData(filePath);
|
|
33
|
+
const sheet_name_list = workbook.SheetNames;
|
|
34
|
+
sheetname = (sheetname === undefined ? sheet_name_list[0] : sheetname);
|
|
35
|
+
return xlsx_1.default.utils.sheet_to_json(workbook.Sheets[sheet_name_list[0]], jsonOpts);
|
|
36
|
+
// const tempTwoDimentionalArr = new Array(_.keys(excelData[0]).length);
|
|
37
|
+
// for (var i = 0; i < tempTwoDimentionalArr.length; i++) {
|
|
38
|
+
// tempTwoDimentionalArr[i] = new Array();
|
|
39
|
+
// }
|
|
40
|
+
// return _.map(excelData, function (obj) {
|
|
41
|
+
// return _.reduce(_.keys(excelData[0]), function (result, columnName, index) {
|
|
42
|
+
// tempTwoDimentionalArr[index].push(obj[columnName])
|
|
43
|
+
// result[columnName] = tempTwoDimentionalArr[index];
|
|
44
|
+
// return result;
|
|
45
|
+
// }, {})
|
|
46
|
+
// })[0];
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
static filterData(filePath, sheetName, filterObject) {
|
|
50
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
let fileData = yield ExcelUtility.readData(filePath);
|
|
52
|
+
return lodash_1.default.filter(xlsx_1.default.utils.sheet_to_json(fileData.Sheets[sheetName]), filterObject);
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
static updateExcelData(filePath, sheetName, exportData) {
|
|
56
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
+
const workbook = yield ExcelUtility.readData(filePath);
|
|
58
|
+
workbook.Sheets[sheetName] = xlsx_1.default.utils.json_to_sheet(exportData);
|
|
59
|
+
xlsx_1.default.writeFile(workbook, filePath);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
static deleteAllFilesUnderDir(dirPath) {
|
|
63
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
64
|
+
for (const file of yield promises_1.default.readdir(dirPath)) {
|
|
65
|
+
yield promises_1.default.unlink(node_path_1.default.join(dirPath, file));
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.ExcelUtility = ExcelUtility;
|
|
71
|
+
//# sourceMappingURL=excel_utility.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
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AAC;YACrD,OAAO,gBAAC,CAAC,MAAM,CAAC,cAAI,CAAC,KAAK,CAAC,aAAa,CAAC,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,EAAE,YAAY,CAAC,CAAA;QACvF,CAAC;KAAA;IAED,MAAM,CAAO,eAAe,CAAC,QAAgB,EAAE,SAAiB,EAAE,UAAyB;;YACvF,MAAM,QAAQ,GAAG,MAAM,YAAY,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;YACvD,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;CAGJ;AA/CD,oCA+CC"}
|
|
@@ -8,5 +8,5 @@ export declare class LightHouseUtility {
|
|
|
8
8
|
}, format?: {
|
|
9
9
|
html: boolean;
|
|
10
10
|
}): Promise<void>;
|
|
11
|
-
static createLightHouseReport(
|
|
11
|
+
static createLightHouseReport(dirPath: string, savefilepath: string, applicationName: any): Promise<void>;
|
|
12
12
|
}
|
|
@@ -45,17 +45,17 @@ class LightHouseUtility {
|
|
|
45
45
|
});
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
|
-
static createLightHouseReport(
|
|
48
|
+
static createLightHouseReport(dirPath, savefilepath, applicationName) {
|
|
49
49
|
return __awaiter(this, void 0, void 0, function* () {
|
|
50
50
|
var str = ``;
|
|
51
51
|
var sno = 0;
|
|
52
|
-
fs_1.default.readdir(
|
|
52
|
+
fs_1.default.readdir(dirPath, function (err, filenames) {
|
|
53
53
|
if (err) {
|
|
54
54
|
return;
|
|
55
55
|
}
|
|
56
56
|
filenames.forEach(function (file) {
|
|
57
57
|
sno = sno + 1;
|
|
58
|
-
str = str + '<tr class="center"><td> ' + sno + ' </td><td>' + file.split('.')[0] + '</td><td>\n<iframe src="./' +
|
|
58
|
+
str = str + '<tr class="center"><td> ' + sno + ' </td><td>' + file.split('.')[0] + '</td><td>\n<iframe src="./' + dirPath.split('/')[dirPath.split('/').length - 1] + '/' + file + '" width="100%" height="300" scrolling="no"></iframe></td><td>\n<p> <a href="./' + dirPath.split('/')[dirPath.split('/').length - 1] + '/' + file + '" target="_blank">open in new tab</a></p></td></tr>';
|
|
59
59
|
});
|
|
60
60
|
str = `<html>
|
|
61
61
|
<head>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lighhouse_utility.js","sourceRoot":"","sources":["../../../src/utils/lighhouse_utility.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,4GAA0F;AAC1F,0GAAwF;AACxF,iEAAkD;AAClD,4CAAoB;AAEpB,MAAa,iBAAiB;IAE1B,MAAM,CAAO,eAAe,CAAC,OAAe,EAAE,UAAU,EAAE,QAAQ,EAAE,gBAAgB,GAAG;QACnF,WAAW,EAAE,EAAE;QACf,aAAa,EAAE,EAAE;QACjB,gBAAgB,EAAE,EAAE;QACpB,GAAG,EAAE,EAAE;QACP,GAAG,EAAE,EAAE;KACV,EAAE,MAAM,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE;;YACtB,UAAU,GAAG,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,0BAAsB,CAAC,CAAC,CAAC,2BAAuB,CAAC;YACxF,MAAM,OAAO,GAAG;gBACZ,UAAU,EAAE,MAAM;aACrB,CAAC;YACF,MAAM,IAAA,iCAAS,EAAC;gBACZ,GAAG,EAAE,OAAO;gBACZ,IAAI,EAAE,OAAO;gBACb,MAAM,EAAE,UA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B;AAVD,gCAUC"}
|
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 {
|
|
6
|
+
import { ExcelUtility } from "./src/utils/excel_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
|
-
|
|
18
|
+
ExcelUtility,
|
|
19
19
|
KeyVaultMethods,
|
|
20
20
|
TestData,
|
|
21
21
|
XmlToJson,
|
package/package.json
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vita-playwright",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"url": "https://github.com/Vialto/fbt-test-automation",
|
|
3
|
+
"version": "1.2.0",
|
|
5
4
|
"email": "noreply_testautomation@vialto.com",
|
|
6
5
|
"main": "dist/index.js",
|
|
7
6
|
"types": "dist/index.d.ts",
|
|
@@ -10,6 +9,10 @@
|
|
|
10
9
|
"publish": "npm run build && npm publish --access public"
|
|
11
10
|
},
|
|
12
11
|
"dependencies": {
|
|
12
|
+
"@azure/storage-blob": "^12.11.0",
|
|
13
|
+
"@cucumber/cucumber": "7.3.1",
|
|
14
|
+
"@cucumber/html-formatter": "11.0.4",
|
|
15
|
+
"@cucumber/pretty-formatter": "1.0.0-alpha.0",
|
|
13
16
|
"@playwright/test": "^1.29.1",
|
|
14
17
|
"@types/lodash": "4.14.189",
|
|
15
18
|
"@types/node": "18.11.9",
|
|
@@ -20,32 +23,33 @@
|
|
|
20
23
|
"allure-playwright": "^2.0.0-beta.20",
|
|
21
24
|
"axios": "^0.27.2",
|
|
22
25
|
"crypto-js": "^4.1.1",
|
|
26
|
+
"cucumber-console-formatter": "1.0.0",
|
|
27
|
+
"dotenv": "^16.0.3",
|
|
23
28
|
"eslint": "8.28.0",
|
|
24
29
|
"eslint-config-prettier": "8.5.0",
|
|
25
30
|
"eslint-plugin-import": "2.26.0",
|
|
26
31
|
"eslint-plugin-prettier": "4.2.1",
|
|
32
|
+
"is-ci": "2.0.0",
|
|
33
|
+
"lighthouse": "^9.6.8",
|
|
34
|
+
"lodash": "^4.17.21",
|
|
27
35
|
"mssql": "9.0.0",
|
|
28
36
|
"open": "8.4.0",
|
|
37
|
+
"pdf-lib": "^1.17.1",
|
|
38
|
+
"playwright": "^1.25.0",
|
|
39
|
+
"playwright-lighthouse": "^2.2.2",
|
|
29
40
|
"prettier": "2.7.1",
|
|
30
41
|
"rimraf": "3.0.2",
|
|
42
|
+
"robotjs": "^0.6.0",
|
|
31
43
|
"ts-node": "10.9.1",
|
|
32
44
|
"typescript": "4.9.3",
|
|
33
|
-
"xmldom": "0.6.0",
|
|
34
|
-
"@azure/storage-blob": "^12.11.0",
|
|
35
|
-
"@cucumber/cucumber": "7.3.1",
|
|
36
|
-
"@cucumber/html-formatter": "11.0.4",
|
|
37
|
-
"@cucumber/pretty-formatter": "1.0.0-alpha.0",
|
|
38
|
-
"cucumber-console-formatter": "1.0.0",
|
|
39
|
-
"dotenv": "^16.0.3",
|
|
40
|
-
"is-ci": "2.0.0",
|
|
41
|
-
"lodash": "^4.17.21",
|
|
42
|
-
"playwright": "^1.25.0",
|
|
43
|
-
"robotjs": "^0.6.0",
|
|
44
45
|
"xlsx": "^0.18.5",
|
|
45
|
-
"
|
|
46
|
-
"lighthouse": "^9.6.8"
|
|
46
|
+
"xmldom": "0.6.0"
|
|
47
47
|
},
|
|
48
48
|
"author": "Vialto QE",
|
|
49
49
|
"license": "ISC",
|
|
50
|
-
"description": "common functions for VITA framework"
|
|
51
|
-
|
|
50
|
+
"description": "common functions for VITA framework",
|
|
51
|
+
"repository": {
|
|
52
|
+
"type": "git",
|
|
53
|
+
"url": "https://github.com/Vialto/fbt-test-automation"
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -82,7 +82,7 @@ export class UIHelper {
|
|
|
82
82
|
await this.page.waitForSelector(elementSelector, { waitFor: 'visible', timeout: waitTime })
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
async
|
|
85
|
+
async getInputBoxValue(locator: any) {
|
|
86
86
|
await this.waitTillElementIsVisible(locator);
|
|
87
87
|
await this.page.locator(locator).scrollIntoViewIfNeeded();
|
|
88
88
|
return await this.page.inputValue();
|
|
@@ -2,7 +2,7 @@ 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
|
|
5
|
+
export class ExcelUtility {
|
|
6
6
|
|
|
7
7
|
static async readData(filePath: string) {
|
|
8
8
|
return XLSX.readFile(filePath, { cellDates: true, bookVBA: true, sheetStubs: true, cellNF: true });
|
|
@@ -13,7 +13,7 @@ export class DocumentUtility {
|
|
|
13
13
|
raw: false,
|
|
14
14
|
dateNF: `yyyy/mm/dd` // <--- need dateNF in sheet_to_json options (note the escape chars)
|
|
15
15
|
}
|
|
16
|
-
const workbook = await
|
|
16
|
+
const workbook = await ExcelUtility.readData(filePath);
|
|
17
17
|
const sheet_name_list = workbook.SheetNames;
|
|
18
18
|
sheetname = (sheetname === undefined ? sheet_name_list[0] : sheetname);
|
|
19
19
|
return XLSX.utils.sheet_to_json(workbook.Sheets[sheet_name_list[0]], jsonOpts);
|
|
@@ -32,17 +32,17 @@ export class DocumentUtility {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
static async filterData(filePath: string, sheetName: string, filterObject: object) {
|
|
35
|
-
let fileData = await
|
|
35
|
+
let fileData = await ExcelUtility.readData(filePath);
|
|
36
36
|
return _.filter(XLSX.utils.sheet_to_json(fileData.Sheets[sheetName]), filterObject)
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
static async updateExcelData(filePath: string, sheetName: string, exportData: Array<object>) {
|
|
40
|
-
const workbook = await
|
|
40
|
+
const workbook = await ExcelUtility.readData(filePath);
|
|
41
41
|
workbook.Sheets[sheetName] = XLSX.utils.json_to_sheet(exportData);
|
|
42
42
|
XLSX.writeFile(workbook, filePath);
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
static async
|
|
45
|
+
static async deleteAllFilesUnderDir(dirPath: string) {
|
|
46
46
|
for (const file of await fs.readdir(dirPath)) {
|
|
47
47
|
await fs.unlink(path.join(dirPath, file));
|
|
48
48
|
}
|
|
@@ -31,16 +31,16 @@ export class LightHouseUtility {
|
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
static async createLightHouseReport(
|
|
34
|
+
static async createLightHouseReport(dirPath: string, savefilepath: string, applicationName) {
|
|
35
35
|
var str = ``;
|
|
36
36
|
var sno = 0;
|
|
37
|
-
fs.readdir(
|
|
37
|
+
fs.readdir(dirPath, function (err, filenames) {
|
|
38
38
|
if (err) {
|
|
39
39
|
return;
|
|
40
40
|
}
|
|
41
41
|
filenames.forEach(function (file) {
|
|
42
42
|
sno = sno + 1;
|
|
43
|
-
str = str + '<tr class="center"><td> ' + sno + ' </td><td>' + file.split('.')[0] + '</td><td>\n<iframe src="./' +
|
|
43
|
+
str = str + '<tr class="center"><td> ' + sno + ' </td><td>' + file.split('.')[0] + '</td><td>\n<iframe src="./' + dirPath.split('/')[dirPath.split('/').length - 1] + '/' + file + '" width="100%" height="300" scrolling="no"></iframe></td><td>\n<p> <a href="./' + dirPath.split('/')[dirPath.split('/').length - 1] + '/' + file + '" target="_blank">open in new tab</a></p></td></tr>'
|
|
44
44
|
});
|
|
45
45
|
str = `<html>
|
|
46
46
|
<head>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { degrees, PDFDocument, rgb, StandardFonts } from 'pdf-lib';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
export class PDFUtility {
|
|
4
|
+
|
|
5
|
+
// static async readData() {
|
|
6
|
+
// const existingPdfBytes = fs.readFile("C:/Users/vtpr271/Downloads/SS - Global Decision Tree - Apr 2021 update (new manual outcome) (1).pdf");
|
|
7
|
+
// // Load a PDFDocument from the existing PDF bytes
|
|
8
|
+
// const pdfDoc = await PDFDocument.load(existingPdfBytes);
|
|
9
|
+
// // Load a PDFDocument from the existing PDF bytes
|
|
10
|
+
// const pdfDoc2 = await PDFDocument.load(existingPdfBytes);
|
|
11
|
+
// console.log(pdfDoc2);
|
|
12
|
+
// }
|
|
13
|
+
}
|