vita-playwright 1.3.25 → 1.4.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/dist/index.d.ts +2 -3
- package/dist/index.js +3 -5
- package/dist/index.js.map +1 -1
- package/dist/src/helpers/api-helpers.d.ts +3 -23
- package/dist/src/helpers/api-helpers.js +6 -26
- package/dist/src/helpers/api-helpers.js.map +1 -1
- package/dist/src/helpers/ui-helpers.d.ts +7 -73
- package/dist/src/helpers/ui-helpers.js +33 -75
- package/dist/src/helpers/ui-helpers.js.map +1 -1
- package/dist/src/utils/date_utilitites.d.ts +0 -38
- package/dist/src/utils/date_utilitites.js +0 -38
- package/dist/src/utils/date_utilitites.js.map +1 -1
- package/dist/src/utils/document_utility.d.ts +1 -32
- package/dist/src/utils/document_utility.js +17 -33
- package/dist/src/utils/document_utility.js.map +1 -1
- package/dist/src/utils/lighhouse_utility.d.ts +0 -17
- package/dist/src/utils/lighhouse_utility.js +0 -17
- package/dist/src/utils/lighhouse_utility.js.map +1 -1
- package/dist/src/utils/test_data.d.ts +0 -11
- package/dist/src/utils/test_data.js +0 -11
- package/dist/src/utils/test_data.js.map +1 -1
- package/index.ts +3 -4
- package/package.json +1 -1
- package/src/helpers/api-helpers.ts +8 -26
- package/src/helpers/ui-helpers.ts +55 -88
- package/src/utils/date_utilitites.ts +7 -45
- package/src/utils/document_utility.ts +4 -42
- package/src/utils/lighhouse_utility.ts +1 -18
- package/src/utils/test_data.ts +8 -19
- package/tsconfig.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -3,10 +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 { DocumentUtility } from "./src/utils/document_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
|
-
|
|
12
|
-
export { UIHelper, ApiHelper, TokenGenerators, AzureStorageMethods, Comparisions, DocumentUtility, KeyVaultMethods, TestData, XmlToJson, LightHouseUtility, Dateutility };
|
|
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.
|
|
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
|
|
15
|
-
Object.defineProperty(exports, "DocumentUtility", { enumerable: true, get: function () { return
|
|
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");
|
|
@@ -21,6 +21,4 @@ const xmlToJson_1 = require("./src/utils/xmlToJson");
|
|
|
21
21
|
Object.defineProperty(exports, "XmlToJson", { enumerable: true, get: function () { return xmlToJson_1.XmlToJson; } });
|
|
22
22
|
const lighhouse_utility_1 = require("./src/utils/lighhouse_utility");
|
|
23
23
|
Object.defineProperty(exports, "LightHouseUtility", { enumerable: true, get: function () { return lighhouse_utility_1.LightHouseUtility; } });
|
|
24
|
-
const date_utilitites_1 = require("./src/utils/date_utilitites");
|
|
25
|
-
Object.defineProperty(exports, "Dateutility", { enumerable: true, get: function () { return date_utilitites_1.Dateutility; } });
|
|
26
24
|
//# sourceMappingURL=index.js.map
|
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,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"}
|
|
@@ -1,25 +1,5 @@
|
|
|
1
1
|
export declare class ApiHelper {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
* @param {string} header - header contains authentication keys, application type etc..
|
|
6
|
-
* @param {string} payload - payload data
|
|
7
|
-
* @returns {Promise<reponse>} - returns Promise of reponse
|
|
8
|
-
*/
|
|
9
|
-
static post(apiEndPoint: any, header: any, payload: any): Promise<any>;
|
|
10
|
-
/**
|
|
11
|
-
* @description: Get call with endpoint and headers.
|
|
12
|
-
* @param {string} apiEndPoint - API end point.
|
|
13
|
-
* @param {string} header - header contains authentication keys, application type etc..
|
|
14
|
-
* @returns {Promise<reponse>} - returns Promise of reponse
|
|
15
|
-
*/
|
|
16
|
-
static get(apiEndPoint: any, header: any): Promise<any>;
|
|
17
|
-
/**
|
|
18
|
-
* @description: Put call with endpoint, headers and data and it will insert the data.
|
|
19
|
-
* @param {string} apiEndPoint - API end point.
|
|
20
|
-
* @param {string} header - headers contains authentication keys, application type etc..
|
|
21
|
-
* @param {string} payload - payload data
|
|
22
|
-
* @returns {Promise<reponse>} - returns Promise of reponse
|
|
23
|
-
*/
|
|
24
|
-
static put(apiEndPoint: any, header: any, payload: any): Promise<any>;
|
|
2
|
+
static post(url: any, header: any, payload: any): Promise<any>;
|
|
3
|
+
static get(url: any, header: any): Promise<any>;
|
|
4
|
+
static put(url: any, header: any, payload: any): Promise<any>;
|
|
25
5
|
}
|
|
@@ -12,18 +12,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.ApiHelper = void 0;
|
|
13
13
|
const api_axios_1 = require("../utils/api_axios");
|
|
14
14
|
class ApiHelper {
|
|
15
|
-
|
|
16
|
-
* @description: Post call with endpoint, headers and data.
|
|
17
|
-
* @param {string} apiEndPoint - API end point.
|
|
18
|
-
* @param {string} header - header contains authentication keys, application type etc..
|
|
19
|
-
* @param {string} payload - payload data
|
|
20
|
-
* @returns {Promise<reponse>} - returns Promise of reponse
|
|
21
|
-
*/
|
|
22
|
-
static post(apiEndPoint, header, payload) {
|
|
15
|
+
static post(url, header, payload) {
|
|
23
16
|
return __awaiter(this, void 0, void 0, function* () {
|
|
24
17
|
var config = {
|
|
25
18
|
method: 'post',
|
|
26
|
-
url:
|
|
19
|
+
url: url,
|
|
27
20
|
headers: header,
|
|
28
21
|
data: payload
|
|
29
22
|
};
|
|
@@ -31,35 +24,22 @@ class ApiHelper {
|
|
|
31
24
|
return response;
|
|
32
25
|
});
|
|
33
26
|
}
|
|
34
|
-
|
|
35
|
-
* @description: Get call with endpoint and headers.
|
|
36
|
-
* @param {string} apiEndPoint - API end point.
|
|
37
|
-
* @param {string} header - header contains authentication keys, application type etc..
|
|
38
|
-
* @returns {Promise<reponse>} - returns Promise of reponse
|
|
39
|
-
*/
|
|
40
|
-
static get(apiEndPoint, header) {
|
|
27
|
+
static get(url, header) {
|
|
41
28
|
return __awaiter(this, void 0, void 0, function* () {
|
|
42
29
|
var config = {
|
|
43
30
|
method: 'GET',
|
|
44
|
-
url:
|
|
31
|
+
url: url,
|
|
45
32
|
headers: header
|
|
46
33
|
};
|
|
47
34
|
var response = yield api_axios_1.TokenGenerators.request(config);
|
|
48
35
|
return response;
|
|
49
36
|
});
|
|
50
37
|
}
|
|
51
|
-
|
|
52
|
-
* @description: Put call with endpoint, headers and data and it will insert the data.
|
|
53
|
-
* @param {string} apiEndPoint - API end point.
|
|
54
|
-
* @param {string} header - headers contains authentication keys, application type etc..
|
|
55
|
-
* @param {string} payload - payload data
|
|
56
|
-
* @returns {Promise<reponse>} - returns Promise of reponse
|
|
57
|
-
*/
|
|
58
|
-
static put(apiEndPoint, header, payload) {
|
|
38
|
+
static put(url, header, payload) {
|
|
59
39
|
return __awaiter(this, void 0, void 0, function* () {
|
|
60
40
|
var config = {
|
|
61
41
|
method: 'put',
|
|
62
|
-
url:
|
|
42
|
+
url: url,
|
|
63
43
|
headers: header,
|
|
64
44
|
data: payload
|
|
65
45
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-helpers.js","sourceRoot":"","sources":["../../../src/helpers/api-helpers.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kDAAqD;AAErD,MAAa,SAAS;IAElB
|
|
1
|
+
{"version":3,"file":"api-helpers.js","sourceRoot":"","sources":["../../../src/helpers/api-helpers.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kDAAqD;AAErD,MAAa,SAAS;IAElB,MAAM,CAAO,IAAI,CAAC,GAAQ,EAAE,MAAW,EAAE,OAAY;;YACjD,IAAI,MAAM,GAAG;gBACT,MAAM,EAAE,MAAM;gBACd,GAAG,EAAE,GAAG;gBACR,OAAO,EAAE,MAAM;gBACf,IAAI,EAAE,OAAO;aAChB,CAAC;YAEF,IAAI,QAAQ,GAAG,MAAM,2BAAe,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YACrD,OAAO,QAAQ,CAAC;QACpB,CAAC;KAAA;IAED,MAAM,CAAO,GAAG,CAAC,GAAQ,EAAE,MAAW;;YAClC,IAAI,MAAM,GAAG;gBACT,MAAM,EAAE,KAAK;gBACb,GAAG,EAAE,GAAG;gBACR,OAAO,EAAE,MAAM;aAClB,CAAC;YAEF,IAAI,QAAQ,GAAG,MAAM,2BAAe,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YACrD,OAAO,QAAQ,CAAC;QACpB,CAAC;KAAA;IAED,MAAM,CAAO,GAAG,CAAC,GAAQ,EAAE,MAAW,EAAE,OAAY;;YAChD,IAAI,MAAM,GAAG;gBACT,MAAM,EAAE,KAAK;gBACb,GAAG,EAAE,GAAG;gBACR,OAAO,EAAE,MAAM;gBACf,IAAI,EAAE,OAAO;aAChB,CAAC;YAEF,IAAI,QAAQ,GAAG,MAAM,2BAAe,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YACrD,OAAO,QAAQ,CAAC;QACpB,CAAC;KAAA;CAEJ;AArCD,8BAqCC"}
|
|
@@ -1,89 +1,23 @@
|
|
|
1
|
+
import { BrowserContext, Page } from "playwright";
|
|
1
2
|
export declare class UIHelper {
|
|
2
3
|
page: any;
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
* @returns {Promise<void>} - returns Promise of void
|
|
9
|
-
*/
|
|
4
|
+
browser: BrowserContext;
|
|
5
|
+
constructor(page: Page);
|
|
6
|
+
launchNonIncognito(chromePath: string): Promise<void>;
|
|
7
|
+
closeNonIncognito(): Promise<void>;
|
|
8
|
+
combineAllCookies(cookieJson: any): string;
|
|
10
9
|
filltheData(locator: any, data: any): Promise<void>;
|
|
11
|
-
/**
|
|
12
|
-
* @description: click the given locator element.
|
|
13
|
-
* @param {string} locator - css selector/xpath of the element.
|
|
14
|
-
* @returns {Promise<void>} - returns Promise of void
|
|
15
|
-
*/
|
|
16
10
|
clickonWebElement(locator: any): Promise<void>;
|
|
17
|
-
/**
|
|
18
|
-
* @description: returns inner html of locator element.
|
|
19
|
-
* @param {string} locator - css selector/xpath of the element.
|
|
20
|
-
* @returns {string} - returns inner html string
|
|
21
|
-
*/
|
|
22
11
|
getInnerHTML(locator: any): Promise<any>;
|
|
23
|
-
/**
|
|
24
|
-
* @description: returns inner text of locator element.
|
|
25
|
-
* @param {string} locator - css selector/xpath of the element.
|
|
26
|
-
* @returns {string} - returns inner text string
|
|
27
|
-
*/
|
|
28
12
|
getInnerText(locator: any): Promise<any>;
|
|
29
|
-
/**
|
|
30
|
-
* @description: returns text of locator element.
|
|
31
|
-
* @param {string} locator - css selector/xpath of the element.
|
|
32
|
-
* @returns {string} - returns text string
|
|
33
|
-
*/
|
|
34
13
|
getText(locator: any): Promise<any>;
|
|
35
|
-
/**
|
|
36
|
-
* @description: returns given attribute value of locator element.
|
|
37
|
-
* @param {string} locator - css selector/xpath of the element.
|
|
38
|
-
* @param {string} attribute - html attribute to get value
|
|
39
|
-
* @returns {string} - returns text string
|
|
40
|
-
*/
|
|
41
14
|
getAttribute(locator: any, attribute: any): Promise<any>;
|
|
42
15
|
evaluateJS(jsDOM: any): Promise<any>;
|
|
43
|
-
/**
|
|
44
|
-
* @description: verifies given locator element is displayed or not.
|
|
45
|
-
* @param {string} locator - css selector/xpath of the element.
|
|
46
|
-
* @returns {boolean} - returns true/false
|
|
47
|
-
*/
|
|
48
16
|
isElementPresent(locator: any): Promise<any>;
|
|
49
|
-
/**
|
|
50
|
-
* @description: verifies given locator element is enabled or not.
|
|
51
|
-
* @param {string} locator - css selector/xpath of the element.
|
|
52
|
-
* @returns {boolean} - returns true/false
|
|
53
|
-
*/
|
|
54
17
|
isElementEnabled(locator: any): Promise<any>;
|
|
55
|
-
/**
|
|
56
|
-
* @description: waits until locator element visibles.
|
|
57
|
-
* @param {elementReference} elementSelector - element reference.
|
|
58
|
-
* @param {number} wait time
|
|
59
|
-
* @returns {Promise<void>} - returns Promise of void
|
|
60
|
-
*/
|
|
61
18
|
waitTillElementIsVisible(elementSelector: any, waitTime?: number): Promise<void>;
|
|
62
|
-
/**
|
|
63
|
-
* @description: returns value of inputbox.
|
|
64
|
-
* @param {string} locator - css selector/xpath of the element.
|
|
65
|
-
* @returns {string} - returns text string
|
|
66
|
-
*/
|
|
67
19
|
getInputBoxValue(locator: any): Promise<any>;
|
|
68
|
-
/**
|
|
69
|
-
* @description: wait untill download process completes and save file with custom name.
|
|
70
|
-
* @param {string} locator - css selector/xpath of the element.
|
|
71
|
-
* @param {string} filePath - Complete path of the excel file, example: C:/resources/****.xlsx.
|
|
72
|
-
* @returns {Promise<void>} - returns Promise of void
|
|
73
|
-
*/
|
|
74
20
|
downloadAFile(downloadButton: String, filePath: string): Promise<void>;
|
|
75
|
-
/**
|
|
76
|
-
* @description: wait untill upload process completes and save file with custom name.
|
|
77
|
-
* @param {string} locator - css selector/xpath of the element.
|
|
78
|
-
* @param {string} filePath - Complete path of the excel file, example: C:/resources/****.xlsx.
|
|
79
|
-
* @returns {Promise<void>} - returns Promise of void
|
|
80
|
-
*/
|
|
81
21
|
uploadAFile(uploadButton: String, uploadFilePath: String): Promise<void>;
|
|
82
|
-
|
|
83
|
-
* @description: will perform click action.
|
|
84
|
-
* @param {string} roleType - example: "alert"|"alertdialog"|"application"|"article"|"banner"|"blockquote"|"button"|"caption"|"cell"|"checkbox"|"code"|"columnheader"|"combobox"|"complementary"|"contentinfo"|"definition"|"deletion"|"dialog"|"directory"|"document"|"emphasis"|"feed"|"figure"|"form"|"generic"|"grid"|"gridcell"|"group"|"heading"|"img"|"insertion"|"link"|"list"|"listbox"|"listitem"|"log"|"main"|"marquee"|"math"|"meter"|"menu"|"menubar"|"menuitem"|"menuitemcheckbox"|"menuitemradio"|"navigation"|"none"|"note"|"option"|"paragraph"|"presentation"|"progressbar"|"radio"|"radiogroup"|"region"|"row"|"rowgroup"|"rowheader"|"scrollbar"|"search"|"searchbox"|"separator"|"slider"|"spinbutton"|"status"|"strong"|"subscript"|"superscript"|"switch"|"tab"|"table"|"tablist"|"tabpanel"|"term"|"textbox"|"time"|"timer"|"toolbar"|"tooltip"|"tree"|"treegrid"|"treeitem".
|
|
85
|
-
* @param {string} roleName - name of the element.
|
|
86
|
-
* @returns {Promise<locator>} - returns Promise of void
|
|
87
|
-
*/
|
|
88
|
-
getElementRefByRole(roleType: string, roleName: string): Promise<any>;
|
|
22
|
+
getElementRefByRole(roleType: string, roleName: string): Promise<void>;
|
|
89
23
|
}
|
|
@@ -10,20 +10,43 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.UIHelper = void 0;
|
|
13
|
+
//import robot from "robotjs";
|
|
14
|
+
const playwright_1 = require("playwright");
|
|
13
15
|
class UIHelper {
|
|
14
16
|
constructor(page) {
|
|
15
17
|
this.page = page;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
}
|
|
19
|
+
/* chromePath should be something like below
|
|
20
|
+
<UserDirectory>/AppData/Local/Google/Chrome/User Data
|
|
21
|
+
*/
|
|
22
|
+
launchNonIncognito(chromePath) {
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
// Launch non-incognito session using provided chromePath
|
|
25
|
+
this.browser = yield playwright_1.chromium.launchPersistentContext(chromePath, { headless: false });
|
|
26
|
+
this.page = yield this.browser.newPage();
|
|
27
|
+
this.browser.clearCookies();
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
// Close All the windows opened for non-incognito session
|
|
31
|
+
closeNonIncognito() {
|
|
32
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
this.browser.clearCookies();
|
|
34
|
+
const allPages = this.browser.pages();
|
|
35
|
+
allPages.forEach(element => {
|
|
36
|
+
element.close();
|
|
37
|
+
});
|
|
19
38
|
});
|
|
20
39
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
40
|
+
//Combines given list of cookies and generates a single cookie for passing in API as header
|
|
41
|
+
combineAllCookies(cookieJson) {
|
|
42
|
+
let Finalcookie = '';
|
|
43
|
+
for (let val of cookieJson) {
|
|
44
|
+
Finalcookie += val.name + "=" + val.value + ";";
|
|
45
|
+
}
|
|
46
|
+
console.log("\n----------------> Final Cookie Generated ---------------->\n");
|
|
47
|
+
Finalcookie = Finalcookie.toString().slice(0, -1);
|
|
48
|
+
return Finalcookie.toString();
|
|
49
|
+
}
|
|
27
50
|
filltheData(locator, data) {
|
|
28
51
|
return __awaiter(this, void 0, void 0, function* () {
|
|
29
52
|
if (data) {
|
|
@@ -33,11 +56,6 @@ class UIHelper {
|
|
|
33
56
|
}
|
|
34
57
|
});
|
|
35
58
|
}
|
|
36
|
-
/**
|
|
37
|
-
* @description: click the given locator element.
|
|
38
|
-
* @param {string} locator - css selector/xpath of the element.
|
|
39
|
-
* @returns {Promise<void>} - returns Promise of void
|
|
40
|
-
*/
|
|
41
59
|
clickonWebElement(locator) {
|
|
42
60
|
return __awaiter(this, void 0, void 0, function* () {
|
|
43
61
|
yield this.page.locator(locator).scrollIntoViewIfNeeded();
|
|
@@ -45,11 +63,6 @@ class UIHelper {
|
|
|
45
63
|
yield this.page.locator(locator).click();
|
|
46
64
|
});
|
|
47
65
|
}
|
|
48
|
-
/**
|
|
49
|
-
* @description: returns inner html of locator element.
|
|
50
|
-
* @param {string} locator - css selector/xpath of the element.
|
|
51
|
-
* @returns {string} - returns inner html string
|
|
52
|
-
*/
|
|
53
66
|
getInnerHTML(locator) {
|
|
54
67
|
return __awaiter(this, void 0, void 0, function* () {
|
|
55
68
|
yield this.waitTillElementIsVisible(locator);
|
|
@@ -57,11 +70,6 @@ class UIHelper {
|
|
|
57
70
|
return yield this.page.innerHTML(locator);
|
|
58
71
|
});
|
|
59
72
|
}
|
|
60
|
-
/**
|
|
61
|
-
* @description: returns inner text of locator element.
|
|
62
|
-
* @param {string} locator - css selector/xpath of the element.
|
|
63
|
-
* @returns {string} - returns inner text string
|
|
64
|
-
*/
|
|
65
73
|
getInnerText(locator) {
|
|
66
74
|
return __awaiter(this, void 0, void 0, function* () {
|
|
67
75
|
yield this.waitTillElementIsVisible(locator);
|
|
@@ -69,11 +77,6 @@ class UIHelper {
|
|
|
69
77
|
return yield this.page.locator(locator).innerText().trim();
|
|
70
78
|
});
|
|
71
79
|
}
|
|
72
|
-
/**
|
|
73
|
-
* @description: returns text of locator element.
|
|
74
|
-
* @param {string} locator - css selector/xpath of the element.
|
|
75
|
-
* @returns {string} - returns text string
|
|
76
|
-
*/
|
|
77
80
|
getText(locator) {
|
|
78
81
|
return __awaiter(this, void 0, void 0, function* () {
|
|
79
82
|
yield this.waitTillElementIsVisible(locator);
|
|
@@ -81,12 +84,6 @@ class UIHelper {
|
|
|
81
84
|
return yield this.page.locator(locator).textContent();
|
|
82
85
|
});
|
|
83
86
|
}
|
|
84
|
-
/**
|
|
85
|
-
* @description: returns given attribute value of locator element.
|
|
86
|
-
* @param {string} locator - css selector/xpath of the element.
|
|
87
|
-
* @param {string} attribute - html attribute to get value
|
|
88
|
-
* @returns {string} - returns text string
|
|
89
|
-
*/
|
|
90
87
|
getAttribute(locator, attribute) {
|
|
91
88
|
return __awaiter(this, void 0, void 0, function* () {
|
|
92
89
|
yield this.waitTillElementIsVisible(locator);
|
|
@@ -99,11 +96,6 @@ class UIHelper {
|
|
|
99
96
|
return yield this.page.evaluate(jsDOM);
|
|
100
97
|
});
|
|
101
98
|
}
|
|
102
|
-
/**
|
|
103
|
-
* @description: verifies given locator element is displayed or not.
|
|
104
|
-
* @param {string} locator - css selector/xpath of the element.
|
|
105
|
-
* @returns {boolean} - returns true/false
|
|
106
|
-
*/
|
|
107
99
|
isElementPresent(locator) {
|
|
108
100
|
return __awaiter(this, void 0, void 0, function* () {
|
|
109
101
|
// console.log(typeof locator.toString());
|
|
@@ -119,33 +111,17 @@ class UIHelper {
|
|
|
119
111
|
console.log(type.toString());
|
|
120
112
|
});
|
|
121
113
|
}
|
|
122
|
-
/**
|
|
123
|
-
* @description: verifies given locator element is enabled or not.
|
|
124
|
-
* @param {string} locator - css selector/xpath of the element.
|
|
125
|
-
* @returns {boolean} - returns true/false
|
|
126
|
-
*/
|
|
127
114
|
isElementEnabled(locator) {
|
|
128
115
|
return __awaiter(this, void 0, void 0, function* () {
|
|
129
116
|
yield this.page.locator(locator).scrollIntoViewIfNeeded();
|
|
130
117
|
return yield this.page.locator(locator).isEnabled();
|
|
131
118
|
});
|
|
132
119
|
}
|
|
133
|
-
/**
|
|
134
|
-
* @description: waits until locator element visibles.
|
|
135
|
-
* @param {elementReference} elementSelector - element reference.
|
|
136
|
-
* @param {number} wait time
|
|
137
|
-
* @returns {Promise<void>} - returns Promise of void
|
|
138
|
-
*/
|
|
139
120
|
waitTillElementIsVisible(elementSelector, waitTime = 60000) {
|
|
140
121
|
return __awaiter(this, void 0, void 0, function* () {
|
|
141
122
|
yield this.page.waitForSelector(elementSelector, { waitFor: 'visible', timeout: waitTime });
|
|
142
123
|
});
|
|
143
124
|
}
|
|
144
|
-
/**
|
|
145
|
-
* @description: returns value of inputbox.
|
|
146
|
-
* @param {string} locator - css selector/xpath of the element.
|
|
147
|
-
* @returns {string} - returns text string
|
|
148
|
-
*/
|
|
149
125
|
getInputBoxValue(locator) {
|
|
150
126
|
return __awaiter(this, void 0, void 0, function* () {
|
|
151
127
|
yield this.waitTillElementIsVisible(locator);
|
|
@@ -158,12 +134,6 @@ class UIHelper {
|
|
|
158
134
|
// robot.moveMouse(400, 20);
|
|
159
135
|
// robot.keyTap("enter");
|
|
160
136
|
// }
|
|
161
|
-
/**
|
|
162
|
-
* @description: wait untill download process completes and save file with custom name.
|
|
163
|
-
* @param {string} locator - css selector/xpath of the element.
|
|
164
|
-
* @param {string} filePath - Complete path of the excel file, example: C:/resources/****.xlsx.
|
|
165
|
-
* @returns {Promise<void>} - returns Promise of void
|
|
166
|
-
*/
|
|
167
137
|
downloadAFile(downloadButton, filePath) {
|
|
168
138
|
return __awaiter(this, void 0, void 0, function* () {
|
|
169
139
|
const downloadPromise = this.page.waitForEvent('download');
|
|
@@ -174,12 +144,6 @@ class UIHelper {
|
|
|
174
144
|
yield download.saveAs(filePath);
|
|
175
145
|
});
|
|
176
146
|
}
|
|
177
|
-
/**
|
|
178
|
-
* @description: wait untill upload process completes and save file with custom name.
|
|
179
|
-
* @param {string} locator - css selector/xpath of the element.
|
|
180
|
-
* @param {string} filePath - Complete path of the excel file, example: C:/resources/****.xlsx.
|
|
181
|
-
* @returns {Promise<void>} - returns Promise of void
|
|
182
|
-
*/
|
|
183
147
|
uploadAFile(uploadButton, uploadFilePath) {
|
|
184
148
|
return __awaiter(this, void 0, void 0, function* () {
|
|
185
149
|
const fileChooserPromise = this.page.waitForEvent('filechooser');
|
|
@@ -188,15 +152,9 @@ class UIHelper {
|
|
|
188
152
|
yield fileChooser.setFiles(uploadFilePath);
|
|
189
153
|
});
|
|
190
154
|
}
|
|
191
|
-
/**
|
|
192
|
-
* @description: will perform click action.
|
|
193
|
-
* @param {string} roleType - example: "alert"|"alertdialog"|"application"|"article"|"banner"|"blockquote"|"button"|"caption"|"cell"|"checkbox"|"code"|"columnheader"|"combobox"|"complementary"|"contentinfo"|"definition"|"deletion"|"dialog"|"directory"|"document"|"emphasis"|"feed"|"figure"|"form"|"generic"|"grid"|"gridcell"|"group"|"heading"|"img"|"insertion"|"link"|"list"|"listbox"|"listitem"|"log"|"main"|"marquee"|"math"|"meter"|"menu"|"menubar"|"menuitem"|"menuitemcheckbox"|"menuitemradio"|"navigation"|"none"|"note"|"option"|"paragraph"|"presentation"|"progressbar"|"radio"|"radiogroup"|"region"|"row"|"rowgroup"|"rowheader"|"scrollbar"|"search"|"searchbox"|"separator"|"slider"|"spinbutton"|"status"|"strong"|"subscript"|"superscript"|"switch"|"tab"|"table"|"tablist"|"tabpanel"|"term"|"textbox"|"time"|"timer"|"toolbar"|"tooltip"|"tree"|"treegrid"|"treeitem".
|
|
194
|
-
* @param {string} roleName - name of the element.
|
|
195
|
-
* @returns {Promise<locator>} - returns Promise of void
|
|
196
|
-
*/
|
|
197
155
|
getElementRefByRole(roleType, roleName) {
|
|
198
156
|
return __awaiter(this, void 0, void 0, function* () {
|
|
199
|
-
|
|
157
|
+
yield this.page.getByRole(roleType, { name: roleName }).click();
|
|
200
158
|
});
|
|
201
159
|
}
|
|
202
160
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui-helpers.js","sourceRoot":"","sources":["../../../src/helpers/ui-helpers.ts"],"names":[],"mappings":";;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"ui-helpers.js","source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AY,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;AAjJD,4BAiJC"}
|
|
@@ -1,47 +1,9 @@
|
|
|
1
1
|
import moment, { DurationInputArg1, DurationInputArg2 } from 'moment';
|
|
2
2
|
export declare class Dateutility {
|
|
3
|
-
/**
|
|
4
|
-
* @description: returns date in required format.
|
|
5
|
-
* @param {string} date - date in the form of string, example: 01/01/2023.
|
|
6
|
-
* @param {string} format - format od date, example: DD/MM/YYYY.
|
|
7
|
-
* @returns {string} - returns date in given format.
|
|
8
|
-
*/
|
|
9
3
|
static getDateInCustomFormat(date: any, format: string): string;
|
|
10
|
-
/**
|
|
11
|
-
* @description: adds no of days|months|years|hours|minutes|seconds from given date.
|
|
12
|
-
* @param {string} date - date in the form of string, example: 01/01/2023.
|
|
13
|
-
* @param {string} format - format od date, example: DD/MM/YYYY.
|
|
14
|
-
* @param {string} durationType - example days, months, years, hours, minutes, seconds.
|
|
15
|
-
* @param {string} duration - no of days|months|years|hours|minutes|seconds.
|
|
16
|
-
* @returns {string} - returns date in given format.
|
|
17
|
-
*/
|
|
18
4
|
static getFutureDateInCustomFormat(date: any, format: string, durationType: DurationInputArg2, duration: DurationInputArg1): string;
|
|
19
|
-
/**
|
|
20
|
-
* @description: subtracts no of days|months|years|hours|minutes|seconds from given date.
|
|
21
|
-
* @param {string} date - date in the form of string, example: 01/01/2023.
|
|
22
|
-
* @param {string} format - format od date, example: DD/MM/YYYY.
|
|
23
|
-
* @param {string} durationType - example days, months, years, hours, minutes, seconds.
|
|
24
|
-
* @param {string} duration - no of days|months|years|hours|minutes|seconds.
|
|
25
|
-
* @returns {string} - returns date in given format.
|
|
26
|
-
*/
|
|
27
5
|
static getPastDateInCustomFormat(date: any, format: string, durationType: DurationInputArg2, duration: DurationInputArg1): string;
|
|
28
|
-
/**
|
|
29
|
-
* @description: return min date from given dates.
|
|
30
|
-
* @param {Array<object<date,format>>} datesArrayObject - array of dates in form of object example: [{date:10/01/2023, format: "DD/MM/YYYY"}, {date:20/01/2023, format: "DD/MM/YYYY"}].
|
|
31
|
-
* @returns {string} - return min date amount given dates example: 10/01/2023.
|
|
32
|
-
*/
|
|
33
6
|
static getMinDateFromMultipleDates(datesArrayObject: any): moment.Moment;
|
|
34
|
-
/**
|
|
35
|
-
* @description: return max date from given dates.
|
|
36
|
-
* @param {Array<object<date,format>>} datesArrayObject - array of dates in form of object example: [{date:10/01/2023, format: "DD/MM/YYYY"}, {date:20/01/2023, format: "DD/MM/YYYY"}].
|
|
37
|
-
* @returns {string} - return max date amount given dates example: 20/01/2023.
|
|
38
|
-
*/
|
|
39
7
|
static getMaxDateFromMultipleDates(date1: any, date2: any): moment.Moment;
|
|
40
|
-
/**
|
|
41
|
-
* @description: returns no of days "lessthan|Greaterthan" from given date.
|
|
42
|
-
* @param {string} fromDate - date in the form of string, example: 01/01/2023.
|
|
43
|
-
* @param {string} format - format od date, example: DD/MM/YYYY.
|
|
44
|
-
* @returns {string} - returns string which is no of days "lessthan|Greaterthan" from given date.
|
|
45
|
-
*/
|
|
46
8
|
static calculateRelativeDate(fromDate: any, format: string): string;
|
|
47
9
|
}
|
|
@@ -7,59 +7,21 @@ exports.Dateutility = void 0;
|
|
|
7
7
|
const lodash_1 = require("lodash");
|
|
8
8
|
const moment_1 = __importDefault(require("moment"));
|
|
9
9
|
class Dateutility {
|
|
10
|
-
/**
|
|
11
|
-
* @description: returns date in required format.
|
|
12
|
-
* @param {string} date - date in the form of string, example: 01/01/2023.
|
|
13
|
-
* @param {string} format - format od date, example: DD/MM/YYYY.
|
|
14
|
-
* @returns {string} - returns date in given format.
|
|
15
|
-
*/
|
|
16
10
|
static getDateInCustomFormat(date, format) {
|
|
17
11
|
return (0, moment_1.default)(date).format(format);
|
|
18
12
|
}
|
|
19
|
-
/**
|
|
20
|
-
* @description: adds no of days|months|years|hours|minutes|seconds from given date.
|
|
21
|
-
* @param {string} date - date in the form of string, example: 01/01/2023.
|
|
22
|
-
* @param {string} format - format od date, example: DD/MM/YYYY.
|
|
23
|
-
* @param {string} durationType - example days, months, years, hours, minutes, seconds.
|
|
24
|
-
* @param {string} duration - no of days|months|years|hours|minutes|seconds.
|
|
25
|
-
* @returns {string} - returns date in given format.
|
|
26
|
-
*/
|
|
27
13
|
static getFutureDateInCustomFormat(date, format, durationType, duration) {
|
|
28
14
|
return (0, moment_1.default)(date).add(duration, durationType).format(format);
|
|
29
15
|
}
|
|
30
|
-
/**
|
|
31
|
-
* @description: subtracts no of days|months|years|hours|minutes|seconds from given date.
|
|
32
|
-
* @param {string} date - date in the form of string, example: 01/01/2023.
|
|
33
|
-
* @param {string} format - format od date, example: DD/MM/YYYY.
|
|
34
|
-
* @param {string} durationType - example days, months, years, hours, minutes, seconds.
|
|
35
|
-
* @param {string} duration - no of days|months|years|hours|minutes|seconds.
|
|
36
|
-
* @returns {string} - returns date in given format.
|
|
37
|
-
*/
|
|
38
16
|
static getPastDateInCustomFormat(date, format, durationType, duration) {
|
|
39
17
|
return (0, moment_1.default)(date).subtract(duration, durationType).format(format);
|
|
40
18
|
}
|
|
41
|
-
/**
|
|
42
|
-
* @description: return min date from given dates.
|
|
43
|
-
* @param {Array<object<date,format>>} datesArrayObject - array of dates in form of object example: [{date:10/01/2023, format: "DD/MM/YYYY"}, {date:20/01/2023, format: "DD/MM/YYYY"}].
|
|
44
|
-
* @returns {string} - return min date amount given dates example: 10/01/2023.
|
|
45
|
-
*/
|
|
46
19
|
static getMinDateFromMultipleDates(datesArrayObject) {
|
|
47
20
|
return moment_1.default.min((0, lodash_1.map)(datesArrayObject, (obj) => (0, moment_1.default)(obj.date, obj.format)));
|
|
48
21
|
}
|
|
49
|
-
/**
|
|
50
|
-
* @description: return max date from given dates.
|
|
51
|
-
* @param {Array<object<date,format>>} datesArrayObject - array of dates in form of object example: [{date:10/01/2023, format: "DD/MM/YYYY"}, {date:20/01/2023, format: "DD/MM/YYYY"}].
|
|
52
|
-
* @returns {string} - return max date amount given dates example: 20/01/2023.
|
|
53
|
-
*/
|
|
54
22
|
static getMaxDateFromMultipleDates(date1, date2) {
|
|
55
23
|
return moment_1.default.max(date1, date2);
|
|
56
24
|
}
|
|
57
|
-
/**
|
|
58
|
-
* @description: returns no of days "lessthan|Greaterthan" from given date.
|
|
59
|
-
* @param {string} fromDate - date in the form of string, example: 01/01/2023.
|
|
60
|
-
* @param {string} format - format od date, example: DD/MM/YYYY.
|
|
61
|
-
* @returns {string} - returns string which is no of days "lessthan|Greaterthan" from given date.
|
|
62
|
-
*/
|
|
63
25
|
static calculateRelativeDate(fromDate, format) {
|
|
64
26
|
return (0, moment_1.default)(fromDate, format).fromNow();
|
|
65
27
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date_utilitites.js","sourceRoot":"","sources":["../../../src/utils/date_utilitites.ts"],"names":[],"mappings":";;;;;;AAAA,mCAA6B;AAC7B,oDAAsE;AACtE,MAAa,WAAW;IAEpB
|
|
1
|
+
{"version":3,"file":"date_utilitites.js","sourceRoot":"","sources":["../../../src/utils/date_utilitites.ts"],"names":[],"mappings":";;;;;;AAAA,mCAA6B;AAC7B,oDAAsE;AACtE,MAAa,WAAW;IAEpB,MAAM,CAAC,qBAAqB,CAAC,IAAQ,EAAE,MAAc;QACjD,OAAO,IAAA,gBAAM,EAAC,IAAI,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACvC,CAAC;IAED,MAAM,CAAC,2BAA2B,CAAC,IAAS,EAAE,MAAc,EAAE,YAA8B,EAAE,QAA2B;QACrH,OAAO,IAAA,gBAAM,EAAC,IAAI,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACnE,CAAC;IAED,MAAM,CAAC,yBAAyB,CAAC,IAAS,EAAE,MAAc,EAAE,YAA8B,EAAE,QAA2B;QACnH,OAAO,IAAA,gBAAM,EAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACxE,CAAC;IAED,MAAM,CAAC,2BAA2B,CAAC,gBAAqB;QACpD,OAAO,gBAAM,CAAC,GAAG,CAAC,IAAA,YAAG,EAAC,gBAAgB,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,IAAA,gBAAM,EAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IACpF,CAAC;IAED,MAAM,CAAC,2BAA2B,CAAC,KAAU,EAAE,KAAU;QACrD,OAAO,gBAAM,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACpC,CAAC;IAED,MAAM,CAAC,qBAAqB,CAAC,QAAa,EAAE,MAAc;QACtD,OAAO,IAAA,gBAAM,EAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,OAAO,EAAE,CAAC;IAC9C,CAAC;CACJ;AAzBD,kCAyBC"}
|
|
@@ -1,40 +1,9 @@
|
|
|
1
1
|
import XLSX from 'xlsx';
|
|
2
2
|
export declare class DocumentUtility {
|
|
3
|
-
/**
|
|
4
|
-
* @description: it will take excel file path as input and will return excel Workbook object.
|
|
5
|
-
* @param {string} filePath - Complete path of the excel file, example: C:/resources/****.xlsx.
|
|
6
|
-
* @returns {Promise<Workbook>} - returns Promise, if we resolves and will get Workbook object
|
|
7
|
-
*/
|
|
8
3
|
static readData(filePath: string): Promise<XLSX.WorkBook>;
|
|
9
|
-
/**
|
|
10
|
-
* @description: it will take excel file path and sheetname as input and will return array of objects.
|
|
11
|
-
* @param {string} filePath - Complete path of the excel file, example: C:/resources/****.xlsx.
|
|
12
|
-
* @param {string} sheetname - name of the sheet name and it is optional. For CSV files no need pass this parameter.
|
|
13
|
-
* @returns {Promise<Array<Object>>} - returns Promise, if we resolves and will get Array of Json objects.
|
|
14
|
-
* [{startDate: '****',endDate: '****', employeeId: '****',CompanyToken: '******'}]
|
|
15
|
-
*/
|
|
16
4
|
static readDataFromExcelorCSV(filePath: string, sheetname: string): Promise<unknown[]>;
|
|
17
|
-
/**
|
|
18
|
-
* @description: it will filter excel data and will return filtered array of objects.
|
|
19
|
-
* @param {string} filePath - Complete path of the excel file, example: C:/resources/****.xlsx.
|
|
20
|
-
* @param {string} sheetname - name of the sheet name and it is optional. For CSV files no need pass this parameter.
|
|
21
|
-
* @param {Object} filterObject - {column Name:Row value} key:value pair. example: {startDate: '****'}
|
|
22
|
-
* @returns {Promise<Array<Object>>} - returns Promise, if we resolves and will get filtered Array of Json objects.
|
|
23
|
-
* [{startDate: '****',endDate: '****', employeeId: '****',CompanyToken: '******'}]
|
|
24
|
-
*/
|
|
25
5
|
static filterData(filePath: string, sheetName: string, filterObject: object): Promise<unknown[]>;
|
|
26
|
-
/**
|
|
27
|
-
* @description: it will modify/update excel file based on input data.
|
|
28
|
-
* @param {string} filePath - Complete path of the excel file, example: C:/resources/****.xlsx.
|
|
29
|
-
* @param {string} sheetname - name of the sheet name and it is optional. For CSV files no need pass this parameter.
|
|
30
|
-
* @param {Array<Object>} exportData - excel modify data. example: [{startDate: '****',endDate: '****', employeeId: '****',CompanyToken: '******'}]
|
|
31
|
-
* @returns {Promise<void>} - returns void promise.
|
|
32
|
-
*/
|
|
33
6
|
static updateExcelData(filePath: string, sheetName: string, exportData: Array<object>): Promise<void>;
|
|
34
|
-
/**
|
|
35
|
-
* @description: it will delete all files under given directory.
|
|
36
|
-
* @param {string} dirPath - Complete path of the directory which contain file, example: C:/resources.
|
|
37
|
-
* @returns {Promise<void>} - returns void promise.
|
|
38
|
-
*/
|
|
39
7
|
static deleteAllFilesUnderDir(dirPath: string): Promise<void>;
|
|
8
|
+
static readPdfFile(filePath: string): Promise<unknown>;
|
|
40
9
|
}
|