vita-playwright 1.3.3 → 1.3.5
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/src/helpers/api-helpers.d.ts +23 -3
- package/dist/src/helpers/api-helpers.js +26 -6
- package/dist/src/helpers/api-helpers.js.map +1 -1
- package/dist/src/helpers/ui-helpers.d.ts +71 -0
- package/dist/src/helpers/ui-helpers.js +71 -0
- package/dist/src/helpers/ui-helpers.js.map +1 -1
- package/dist/src/utils/date_utilitites.d.ts +38 -0
- package/dist/src/utils/date_utilitites.js +38 -0
- package/dist/src/utils/date_utilitites.js.map +1 -1
- package/dist/src/utils/document_utility.d.ts +37 -0
- package/dist/src/utils/document_utility.js +37 -0
- package/dist/src/utils/document_utility.js.map +1 -1
- package/dist/src/utils/lighhouse_utility.d.ts +17 -0
- package/dist/src/utils/lighhouse_utility.js +17 -0
- package/dist/src/utils/lighhouse_utility.js.map +1 -1
- package/dist/src/utils/test_data.d.ts +11 -0
- package/dist/src/utils/test_data.js +11 -0
- package/dist/src/utils/test_data.js.map +1 -1
- package/package.json +2 -2
- package/src/helpers/api-helpers.ts +26 -8
- package/src/helpers/ui-helpers.ts +77 -18
- package/src/utils/date_utilitites.ts +45 -7
- package/src/utils/document_utility.ts +38 -1
- package/src/utils/lighhouse_utility.ts +18 -1
- package/src/utils/test_data.ts +19 -8
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
export declare class LightHouseUtility {
|
|
2
|
+
/**
|
|
3
|
+
* @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.
|
|
4
|
+
* @param {string} pageurl - url of the given page which needs to be calculated.
|
|
5
|
+
* @param {string} deviceType - type of device i.e desktop or mobile.
|
|
6
|
+
* @param {string} filename - to save the result the filename.
|
|
7
|
+
* @param {object} customThresholds - It is optional threshold object. example: {performance: 80,accessibility: 70,
|
|
8
|
+
'best-practices': 70,seo: 70, pwa: 70,} these are the default values.
|
|
9
|
+
* @param {object} format - This is optional. example: { html: true, csv:true, json: true}.
|
|
10
|
+
* @returns {Promise<void>} - returns void promise.
|
|
11
|
+
*/
|
|
2
12
|
static auditLightHouse(pageurl: string, deviceType: any, filename: any, customThresholds?: {
|
|
3
13
|
performance: number;
|
|
4
14
|
accessibility: number;
|
|
@@ -8,5 +18,12 @@ export declare class LightHouseUtility {
|
|
|
8
18
|
}, format?: {
|
|
9
19
|
html: boolean;
|
|
10
20
|
}): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* @description: it creates new index.html file which has links to all pages htnl files.
|
|
23
|
+
* @param {string} dirPath - Complete path of the directory which contains Lighthouse performace html files, example: C:/lighthouse.
|
|
24
|
+
* @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/
|
|
25
|
+
* @param {String} applicationName - Name of the Application
|
|
26
|
+
* @returns {Promise<void>} - returns void promise.
|
|
27
|
+
*/
|
|
11
28
|
static createLightHouseReport(dirPath: string, savefilepath: string, applicationName: any): Promise<void>;
|
|
12
29
|
}
|
|
@@ -18,6 +18,16 @@ const lr_mobile_config_1 = __importDefault(require("lighthouse/lighthouse-core/c
|
|
|
18
18
|
const playwright_lighthouse_1 = require("playwright-lighthouse");
|
|
19
19
|
const fs_1 = __importDefault(require("fs"));
|
|
20
20
|
class LightHouseUtility {
|
|
21
|
+
/**
|
|
22
|
+
* @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.
|
|
23
|
+
* @param {string} pageurl - url of the given page which needs to be calculated.
|
|
24
|
+
* @param {string} deviceType - type of device i.e desktop or mobile.
|
|
25
|
+
* @param {string} filename - to save the result the filename.
|
|
26
|
+
* @param {object} customThresholds - It is optional threshold object. example: {performance: 80,accessibility: 70,
|
|
27
|
+
'best-practices': 70,seo: 70, pwa: 70,} these are the default values.
|
|
28
|
+
* @param {object} format - This is optional. example: { html: true, csv:true, json: true}.
|
|
29
|
+
* @returns {Promise<void>} - returns void promise.
|
|
30
|
+
*/
|
|
21
31
|
static auditLightHouse(pageurl, deviceType, filename, customThresholds = {
|
|
22
32
|
performance: 80,
|
|
23
33
|
accessibility: 70,
|
|
@@ -45,6 +55,13 @@ class LightHouseUtility {
|
|
|
45
55
|
});
|
|
46
56
|
});
|
|
47
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* @description: it creates new index.html file which has links to all pages htnl files.
|
|
60
|
+
* @param {string} dirPath - Complete path of the directory which contains Lighthouse performace html files, example: C:/lighthouse.
|
|
61
|
+
* @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/
|
|
62
|
+
* @param {String} applicationName - Name of the Application
|
|
63
|
+
* @returns {Promise<void>} - returns void promise.
|
|
64
|
+
*/
|
|
48
65
|
static createLightHouseReport(dirPath, savefilepath, applicationName) {
|
|
49
66
|
return __awaiter(this, void 0, void 0, function* () {
|
|
50
67
|
var str = ``;
|
|
@@ -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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O;iBACV;gBACD,SAAS,CAAC,OAAO,CAAC,UAAU,IAAI;oBAC5B,GAAG,GAAG,GAAG,GAAG,CAAC,CAAC;oBACd,GAAG,GAAG,GAAG,GAAG,6BAA6B,GAAG,GAAG,GAAG,eAAe,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,4BAA4B,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,GAAG,GAAG,IAAI,GAAG,gFAAgF,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,GAAG,GAAG,IAAI,GAAG,qDAAqD,CAAA;gBACtY,CAAC,CAAC,CAAC;gBACH,GAAG,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBA+BM,GAAE,eAAe,GAAG;;;;;;;;sBAQtB,GAAG,GAAG,GAAG;;;;wBAIP,CAAC;gBACb,YAAE,CAAC,aAAa,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC;YACxC,CAAC,CAAC,CAAC;QACP,CAAC;KAAA;CACJ;AAvGD,8CAuGC"}
|
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
export declare class TestData {
|
|
2
|
+
/**
|
|
3
|
+
* @description: establish the connection with database.
|
|
4
|
+
* @param {string} configuration - example: {server: string, database: string, username:string, password: string, portNumber: number}.
|
|
5
|
+
* @returns {Connection} - returns connection object.
|
|
6
|
+
*/
|
|
2
7
|
static sqlDBConnection(configuration: any): Promise<any>;
|
|
8
|
+
/**
|
|
9
|
+
* @description: establish the connection with database.
|
|
10
|
+
* @param {string} connectionObj - connection object which will come from sqlDBConnection()
|
|
11
|
+
* @param {string} queryString - query to execute
|
|
12
|
+
* @returns {Connection} - returns connection object.
|
|
13
|
+
*/
|
|
3
14
|
static executeSqlQuery(connectionObj: any, queryString: any): Promise<any>;
|
|
4
15
|
static generateRandomUniqeIDNumber(): Promise<string>;
|
|
5
16
|
static getUTCTimeCustom24hrs(localTime: string): Promise<string>;
|
|
@@ -13,6 +13,11 @@ exports.TestData = void 0;
|
|
|
13
13
|
// const cosmosClient = require("@azure/cosmos").CosmosClient;
|
|
14
14
|
const sql = require('mssql');
|
|
15
15
|
class TestData {
|
|
16
|
+
/**
|
|
17
|
+
* @description: establish the connection with database.
|
|
18
|
+
* @param {string} configuration - example: {server: string, database: string, username:string, password: string, portNumber: number}.
|
|
19
|
+
* @returns {Connection} - returns connection object.
|
|
20
|
+
*/
|
|
16
21
|
static sqlDBConnection(configuration) {
|
|
17
22
|
return __awaiter(this, void 0, void 0, function* () {
|
|
18
23
|
// var server = "zwetrvl2sqd001.database.windows.net";
|
|
@@ -38,6 +43,12 @@ class TestData {
|
|
|
38
43
|
return conn;
|
|
39
44
|
});
|
|
40
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* @description: establish the connection with database.
|
|
48
|
+
* @param {string} connectionObj - connection object which will come from sqlDBConnection()
|
|
49
|
+
* @param {string} queryString - query to execute
|
|
50
|
+
* @returns {Connection} - returns connection object.
|
|
51
|
+
*/
|
|
41
52
|
static executeSqlQuery(connectionObj, queryString) {
|
|
42
53
|
return __awaiter(this, void 0, void 0, function* () {
|
|
43
54
|
var pool1Connect = yield connectionObj.connect();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test_data.js","sourceRoot":"","sources":["../../../src/utils/test_data.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8DAA8D;AAC9D,MAAM,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAE7B,MAAa,QAAQ;IAEjB,MAAM,CAAO,eAAe,CAAC,aAAkB;;YAC3C,sDAAsD;YACtD,wCAAwC;YACxC,IAAI,MAAM,GAAG;gBACT,MAAM,EAAE,aAAa,CAAC,MAAM;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,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;iBAChE;qBAAM;oBACH,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC;iBACrE;aACJ;iBAAM;gBACH,IAAI,KAAK,IAAI,EAAE,EAAE;oBACb,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;iBACzB;qBAAM;oBACH,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;iBAChE;aACJ;YACD,SAAS,CAAC,UAAU,CAAC,QAAQ,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAA;YAC9E,SAAS,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;YAC1B,OAAO,CAAC,GAAG,CAAC,sBAAsB,GAAG,SAAS,CAAC,WAAW,EAAE,CAAC,CAAC;YAC9D,OAAO,SAAS,CAAC,WAAW,EAAE,CAAA;QAElC,CAAC;KAAA;CAEJ;AAtID,4BAsIC"}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vita-playwright",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.5",
|
|
4
4
|
"email": "noreply_testautomation@vialto.com",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"build": "tsc",
|
|
9
|
-
"publish": "npm run build && npm publish --access public"
|
|
9
|
+
"publish": "npm version patch && npm run build && npm publish --access public"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@azure/storage-blob": "^12.11.0",
|
|
@@ -2,10 +2,17 @@ import { TokenGenerators } from '../utils/api_axios';
|
|
|
2
2
|
|
|
3
3
|
export class ApiHelper {
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* @description: Post call with endpoint, headers and data.
|
|
7
|
+
* @param {string} apiEndPoint - API end point.
|
|
8
|
+
* @param {string} header - header contains authentication keys, application type etc..
|
|
9
|
+
* @param {string} payload - payload data
|
|
10
|
+
* @returns {Promise<reponse>} - returns Promise of reponse
|
|
11
|
+
*/
|
|
12
|
+
static async post(apiEndPoint: any, header: any, payload: any) {
|
|
6
13
|
var config = {
|
|
7
14
|
method: 'post',
|
|
8
|
-
url:
|
|
15
|
+
url: apiEndPoint,
|
|
9
16
|
headers: header,
|
|
10
17
|
data: payload
|
|
11
18
|
};
|
|
@@ -13,22 +20,33 @@ export class ApiHelper {
|
|
|
13
20
|
var response = await TokenGenerators.request(config);
|
|
14
21
|
return response;
|
|
15
22
|
}
|
|
16
|
-
|
|
17
|
-
|
|
23
|
+
/**
|
|
24
|
+
* @description: Get call with endpoint and headers.
|
|
25
|
+
* @param {string} apiEndPoint - API end point.
|
|
26
|
+
* @param {string} header - header contains authentication keys, application type etc..
|
|
27
|
+
* @returns {Promise<reponse>} - returns Promise of reponse
|
|
28
|
+
*/
|
|
29
|
+
static async get(apiEndPoint: any, header: any) {
|
|
18
30
|
var config = {
|
|
19
31
|
method: 'GET',
|
|
20
|
-
url:
|
|
32
|
+
url: apiEndPoint,
|
|
21
33
|
headers: header
|
|
22
34
|
};
|
|
23
35
|
|
|
24
36
|
var response = await TokenGenerators.request(config);
|
|
25
37
|
return response;
|
|
26
38
|
}
|
|
27
|
-
|
|
28
|
-
|
|
39
|
+
/**
|
|
40
|
+
* @description: Put call with endpoint, headers and data and it will insert the data.
|
|
41
|
+
* @param {string} apiEndPoint - API end point.
|
|
42
|
+
* @param {string} header - headers contains authentication keys, application type etc..
|
|
43
|
+
* @param {string} payload - payload data
|
|
44
|
+
* @returns {Promise<reponse>} - returns Promise of reponse
|
|
45
|
+
*/
|
|
46
|
+
static async put(apiEndPoint: any, header: any, payload: any) {
|
|
29
47
|
var config = {
|
|
30
48
|
method: 'put',
|
|
31
|
-
url:
|
|
49
|
+
url: apiEndPoint,
|
|
32
50
|
headers: header,
|
|
33
51
|
data: payload
|
|
34
52
|
};
|
|
@@ -7,6 +7,12 @@ export class UIHelper {
|
|
|
7
7
|
this.page = page;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* @description: sets the text in inputbox.
|
|
12
|
+
* @param {string} locator - css selector/xpath of the inputbox.
|
|
13
|
+
* @param {string} data - Text to be set to inputbox
|
|
14
|
+
* @returns {Promise<void>} - returns Promise of void
|
|
15
|
+
*/
|
|
10
16
|
async filltheData(locator: any, data: any) {
|
|
11
17
|
|
|
12
18
|
if (data) {
|
|
@@ -17,34 +23,55 @@ export class UIHelper {
|
|
|
17
23
|
}
|
|
18
24
|
|
|
19
25
|
}
|
|
20
|
-
|
|
26
|
+
/**
|
|
27
|
+
* @description: click the given locator element.
|
|
28
|
+
* @param {string} locator - css selector/xpath of the element.
|
|
29
|
+
* @returns {Promise<void>} - returns Promise of void
|
|
30
|
+
*/
|
|
21
31
|
async clickonWebElement(locator: any) {
|
|
22
32
|
await this.page.locator(locator).scrollIntoViewIfNeeded();
|
|
23
33
|
await this.waitTillElementIsVisible(locator);
|
|
24
34
|
await this.page.locator(locator).click();
|
|
25
35
|
|
|
26
36
|
}
|
|
27
|
-
|
|
37
|
+
/**
|
|
38
|
+
* @description: returns inner html of locator element.
|
|
39
|
+
* @param {string} locator - css selector/xpath of the element.
|
|
40
|
+
* @returns {string} - returns inner html string
|
|
41
|
+
*/
|
|
28
42
|
async getInnerHTML(locator: any) {
|
|
29
43
|
await this.waitTillElementIsVisible(locator);
|
|
30
44
|
await this.page.locator(locator).scrollIntoViewIfNeeded();
|
|
31
45
|
return await this.page.innerHTML(locator);
|
|
32
46
|
}
|
|
33
47
|
|
|
34
|
-
|
|
48
|
+
/**
|
|
49
|
+
* @description: returns inner text of locator element.
|
|
50
|
+
* @param {string} locator - css selector/xpath of the element.
|
|
51
|
+
* @returns {string} - returns inner text string
|
|
52
|
+
*/
|
|
35
53
|
async getInnerText(locator: any) {
|
|
36
54
|
await this.waitTillElementIsVisible(locator);
|
|
37
55
|
await this.page.locator(locator).scrollIntoViewIfNeeded();
|
|
38
56
|
return await this.page.locator(locator).innerText().trim();
|
|
39
57
|
}
|
|
40
|
-
|
|
58
|
+
/**
|
|
59
|
+
* @description: returns text of locator element.
|
|
60
|
+
* @param {string} locator - css selector/xpath of the element.
|
|
61
|
+
* @returns {string} - returns text string
|
|
62
|
+
*/
|
|
41
63
|
async getText(locator: any) {
|
|
42
64
|
await this.waitTillElementIsVisible(locator);
|
|
43
65
|
await this.page.locator(locator).scrollIntoViewIfNeeded();
|
|
44
66
|
return await this.page.locator(locator).textContent();
|
|
45
67
|
|
|
46
68
|
}
|
|
47
|
-
|
|
69
|
+
/**
|
|
70
|
+
* @description: returns given attribute value of locator element.
|
|
71
|
+
* @param {string} locator - css selector/xpath of the element.
|
|
72
|
+
* @param {string} attribute - html attribute to get value
|
|
73
|
+
* @returns {string} - returns text string
|
|
74
|
+
*/
|
|
48
75
|
async getAttribute(locator: any, attribute: any) {
|
|
49
76
|
await this.waitTillElementIsVisible(locator);
|
|
50
77
|
await this.page.locator(locator).scrollIntoViewIfNeeded();
|
|
@@ -56,7 +83,11 @@ export class UIHelper {
|
|
|
56
83
|
return await this.page.evaluate(jsDOM);
|
|
57
84
|
|
|
58
85
|
}
|
|
59
|
-
|
|
86
|
+
/**
|
|
87
|
+
* @description: verifies given locator element is displayed or not.
|
|
88
|
+
* @param {string} locator - css selector/xpath of the element.
|
|
89
|
+
* @returns {boolean} - returns true/false
|
|
90
|
+
*/
|
|
60
91
|
async isElementPresent(locator: any) {
|
|
61
92
|
// console.log(typeof locator.toString());
|
|
62
93
|
let type = typeof locator;
|
|
@@ -71,46 +102,74 @@ export class UIHelper {
|
|
|
71
102
|
console.log(type.toString());
|
|
72
103
|
|
|
73
104
|
}
|
|
74
|
-
|
|
105
|
+
/**
|
|
106
|
+
* @description: verifies given locator element is enabled or not.
|
|
107
|
+
* @param {string} locator - css selector/xpath of the element.
|
|
108
|
+
* @returns {boolean} - returns true/false
|
|
109
|
+
*/
|
|
75
110
|
async isElementEnabled(locator: any) {
|
|
76
111
|
await this.page.locator(locator).scrollIntoViewIfNeeded();
|
|
77
112
|
return await this.page.locator(locator).isEnabled();
|
|
78
113
|
|
|
79
114
|
}
|
|
80
|
-
|
|
115
|
+
/**
|
|
116
|
+
* @description: waits until locator element visibles.
|
|
117
|
+
* @param {elementReference} elementSelector - element reference.
|
|
118
|
+
* @param {number} wait time
|
|
119
|
+
* @returns {Promise<void>} - returns Promise of void
|
|
120
|
+
*/
|
|
81
121
|
async waitTillElementIsVisible(elementSelector: any, waitTime = 60000) {
|
|
82
122
|
await this.page.waitForSelector(elementSelector, { waitFor: 'visible', timeout: waitTime })
|
|
83
123
|
}
|
|
84
|
-
|
|
124
|
+
/**
|
|
125
|
+
* @description: returns value of inputbox.
|
|
126
|
+
* @param {string} locator - css selector/xpath of the element.
|
|
127
|
+
* @returns {string} - returns text string
|
|
128
|
+
*/
|
|
85
129
|
async getInputBoxValue(locator: any) {
|
|
86
130
|
await this.waitTillElementIsVisible(locator);
|
|
87
131
|
await this.page.locator(locator).scrollIntoViewIfNeeded();
|
|
88
132
|
return await this.page.inputValue();
|
|
89
133
|
}
|
|
90
|
-
|
|
91
|
-
|
|
134
|
+
|
|
135
|
+
// async closeCertificationPopup() {
|
|
92
136
|
// await this.page.waitForTimeout(5000);
|
|
93
137
|
// robot.moveMouse(400, 20);
|
|
94
138
|
// robot.keyTap("enter");
|
|
95
139
|
// }
|
|
96
|
-
|
|
97
|
-
|
|
140
|
+
/**
|
|
141
|
+
* @description: wait untill download process completes and save file with custom name.
|
|
142
|
+
* @param {string} locator - css selector/xpath of the element.
|
|
143
|
+
* @param {string} filePath - Complete path of the excel file, example: C:/resources/****.xlsx.
|
|
144
|
+
* @returns {Promise<void>} - returns Promise of void
|
|
145
|
+
*/
|
|
146
|
+
async downloadAFile(downloadButton: String, filePath: string) {
|
|
98
147
|
const downloadPromise = this.page.waitForEvent('download');
|
|
99
148
|
await this.clickonWebElement(downloadButton);
|
|
100
149
|
const download = await downloadPromise;
|
|
101
150
|
// Wait for the download process to complete
|
|
102
151
|
console.log("download", await download.path());
|
|
103
|
-
await download.saveAs(filePath);
|
|
152
|
+
await download.saveAs(filePath);
|
|
104
153
|
}
|
|
105
|
-
|
|
106
|
-
|
|
154
|
+
/**
|
|
155
|
+
* @description: wait untill upload process completes and save file with custom name.
|
|
156
|
+
* @param {string} locator - css selector/xpath of the element.
|
|
157
|
+
* @param {string} filePath - Complete path of the excel file, example: C:/resources/****.xlsx.
|
|
158
|
+
* @returns {Promise<void>} - returns Promise of void
|
|
159
|
+
*/
|
|
160
|
+
async uploadAFile(uploadButton: String, uploadFilePath: String) {
|
|
107
161
|
const fileChooserPromise = this.page.waitForEvent('filechooser');
|
|
108
162
|
await this.clickonWebElement(uploadButton);
|
|
109
163
|
const fileChooser = await fileChooserPromise;
|
|
110
164
|
await fileChooser.setFiles(uploadFilePath);
|
|
111
165
|
}
|
|
112
|
-
|
|
113
|
-
|
|
166
|
+
/**
|
|
167
|
+
* @description: will perform click action.
|
|
168
|
+
* @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".
|
|
169
|
+
* @param {string} roleName - name of the element.
|
|
170
|
+
* @returns {Promise<void>} - returns Promise of void
|
|
171
|
+
*/
|
|
172
|
+
async getElementRefByRole(roleType: string, roleName: string) {
|
|
114
173
|
await this.page.getByRole(roleType, { name: roleName }).click();
|
|
115
174
|
}
|
|
116
175
|
|
|
@@ -1,28 +1,66 @@
|
|
|
1
1
|
import { map } from 'lodash';
|
|
2
2
|
import moment, { DurationInputArg1, DurationInputArg2 } from 'moment';
|
|
3
|
-
export class Dateutility{
|
|
3
|
+
export class Dateutility {
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* @description: returns date in required format.
|
|
7
|
+
* @param {string} date - date in the form of string, example: 01/01/2023.
|
|
8
|
+
* @param {string} format - format od date, example: DD/MM/YYYY.
|
|
9
|
+
* @returns {string} - returns date in given format.
|
|
10
|
+
*/
|
|
11
|
+
static getDateInCustomFormat(date: any, format: string) {
|
|
6
12
|
return moment(date).format(format);
|
|
7
13
|
}
|
|
8
14
|
|
|
9
|
-
|
|
15
|
+
/**
|
|
16
|
+
* @description: adds no of days|months|years|hours|minutes|seconds from given date.
|
|
17
|
+
* @param {string} date - date in the form of string, example: 01/01/2023.
|
|
18
|
+
* @param {string} format - format od date, example: DD/MM/YYYY.
|
|
19
|
+
* @param {string} durationType - example days, months, years, hours, minutes, seconds.
|
|
20
|
+
* @param {string} duration - no of days|months|years|hours|minutes|seconds.
|
|
21
|
+
* @returns {string} - returns date in given format.
|
|
22
|
+
*/
|
|
23
|
+
static getFutureDateInCustomFormat(date: any, format: string, durationType: DurationInputArg2, duration: DurationInputArg1) {
|
|
10
24
|
return moment(date).add(duration, durationType).format(format);
|
|
11
25
|
}
|
|
12
26
|
|
|
13
|
-
|
|
27
|
+
/**
|
|
28
|
+
* @description: subtracts no of days|months|years|hours|minutes|seconds from given date.
|
|
29
|
+
* @param {string} date - date in the form of string, example: 01/01/2023.
|
|
30
|
+
* @param {string} format - format od date, example: DD/MM/YYYY.
|
|
31
|
+
* @param {string} durationType - example days, months, years, hours, minutes, seconds.
|
|
32
|
+
* @param {string} duration - no of days|months|years|hours|minutes|seconds.
|
|
33
|
+
* @returns {string} - returns date in given format.
|
|
34
|
+
*/
|
|
35
|
+
static getPastDateInCustomFormat(date: any, format: string, durationType: DurationInputArg2, duration: DurationInputArg1) {
|
|
14
36
|
return moment(date).subtract(duration, durationType).format(format);
|
|
15
37
|
}
|
|
16
38
|
|
|
17
|
-
|
|
39
|
+
/**
|
|
40
|
+
* @description: return min date from given dates.
|
|
41
|
+
* @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"}].
|
|
42
|
+
* @returns {string} - return min date amount given dates example: 10/01/2023.
|
|
43
|
+
*/
|
|
44
|
+
static getMinDateFromMultipleDates(datesArrayObject: any) {
|
|
18
45
|
return moment.min(map(datesArrayObject, (obj) => moment(obj.date, obj.format)));
|
|
19
46
|
}
|
|
20
47
|
|
|
21
|
-
|
|
48
|
+
/**
|
|
49
|
+
* @description: return max date from given dates.
|
|
50
|
+
* @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"}].
|
|
51
|
+
* @returns {string} - return max date amount given dates example: 20/01/2023.
|
|
52
|
+
*/
|
|
53
|
+
static getMaxDateFromMultipleDates(date1: any, date2: any) {
|
|
22
54
|
return moment.max(date1, date2);
|
|
23
55
|
}
|
|
24
56
|
|
|
25
|
-
|
|
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
|
+
static calculateRelativeDate(fromDate: any, format: string) {
|
|
26
64
|
return moment(fromDate, format).fromNow();
|
|
27
65
|
}
|
|
28
66
|
}
|
|
@@ -6,15 +6,27 @@ import { PdfReader } from "pdfreader";
|
|
|
6
6
|
|
|
7
7
|
export class DocumentUtility {
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* @description: it will take excel file path as input and will return excel Workbook object.
|
|
11
|
+
* @param {string} filePath - Complete path of the excel file, example: C:/resources/****.xlsx.
|
|
12
|
+
* @returns {Promise<Workbook>} - returns Promise, if we resolves and will get Workbook object
|
|
13
|
+
*/
|
|
9
14
|
static async readData(filePath: string) {
|
|
10
15
|
return XLSX.readFile(filePath, { cellDates: true, bookVBA: true, sheetStubs: true, cellNF: true });
|
|
11
16
|
}
|
|
12
17
|
|
|
18
|
+
/**
|
|
19
|
+
* @description: it will take excel file path and sheetname as input and will return array of objects.
|
|
20
|
+
* @param {string} filePath - Complete path of the excel file, example: C:/resources/****.xlsx.
|
|
21
|
+
* @param {string} sheetname - name of the sheet name and it is optional. For CSV files no need pass this parameter.
|
|
22
|
+
* @returns {Promise<Array<Object>>} - returns Promise, if we resolves and will get Array of Json objects.
|
|
23
|
+
* [{startDate: '****',endDate: '****', employeeId: '****',CompanyToken: '******'}]
|
|
24
|
+
*/
|
|
13
25
|
static async readDataFromExcelorCSV(filePath: string, sheetname: string) {
|
|
14
26
|
const jsonOpts = {
|
|
15
27
|
raw: false,
|
|
16
28
|
dateNF: `yyyy/mm/dd` // <--- need dateNF in sheet_to_json options (note the escape chars)
|
|
17
|
-
|
|
29
|
+
}
|
|
18
30
|
const workbook = await DocumentUtility.readData(filePath);
|
|
19
31
|
const sheet_name_list = workbook.SheetNames;
|
|
20
32
|
sheetname = (sheetname === undefined ? sheet_name_list[0] : sheetname);
|
|
@@ -33,23 +45,48 @@ export class DocumentUtility {
|
|
|
33
45
|
// })[0];
|
|
34
46
|
}
|
|
35
47
|
|
|
48
|
+
/**
|
|
49
|
+
* @description: it will filter excel data and will return filtered array of objects.
|
|
50
|
+
* @param {string} filePath - Complete path of the excel file, example: C:/resources/****.xlsx.
|
|
51
|
+
* @param {string} sheetname - name of the sheet name and it is optional. For CSV files no need pass this parameter.
|
|
52
|
+
* @param {Object} filterObject - {column Name:Row value} key:value pair. example: {startDate: '****'}
|
|
53
|
+
* @returns {Promise<Array<Object>>} - returns Promise, if we resolves and will get filtered Array of Json objects.
|
|
54
|
+
* [{startDate: '****',endDate: '****', employeeId: '****',CompanyToken: '******'}]
|
|
55
|
+
*/
|
|
36
56
|
static async filterData(filePath: string, sheetName: string, filterObject: object) {
|
|
37
57
|
let fileData = await DocumentUtility.readData(filePath);
|
|
38
58
|
return _.filter(XLSX.utils.sheet_to_json(fileData.Sheets[sheetName]), filterObject)
|
|
39
59
|
}
|
|
40
60
|
|
|
61
|
+
/**
|
|
62
|
+
* @description: it will modify/update excel file based on input data.
|
|
63
|
+
* @param {string} filePath - Complete path of the excel file, example: C:/resources/****.xlsx.
|
|
64
|
+
* @param {string} sheetname - name of the sheet name and it is optional. For CSV files no need pass this parameter.
|
|
65
|
+
* @param {Array<Object>} exportData - excel modify data. example: [{startDate: '****',endDate: '****', employeeId: '****',CompanyToken: '******'}]
|
|
66
|
+
* @returns {Promise<void>} - returns void promise.
|
|
67
|
+
*/
|
|
41
68
|
static async updateExcelData(filePath: string, sheetName: string, exportData: Array<object>) {
|
|
42
69
|
const workbook = await DocumentUtility.readData(filePath);
|
|
43
70
|
workbook.Sheets[sheetName] = XLSX.utils.json_to_sheet(exportData);
|
|
44
71
|
XLSX.writeFile(workbook, filePath);
|
|
45
72
|
}
|
|
46
73
|
|
|
74
|
+
/**
|
|
75
|
+
* @description: it will delete all files under given directory.
|
|
76
|
+
* @param {string} dirPath - Complete path of the directory which contain file, example: C:/resources.
|
|
77
|
+
* @returns {Promise<void>} - returns void promise.
|
|
78
|
+
*/
|
|
47
79
|
static async deleteAllFilesUnderDir(dirPath: string) {
|
|
48
80
|
for (const file of await fs.readdir(dirPath)) {
|
|
49
81
|
await fs.unlink(path.join(dirPath, file));
|
|
50
82
|
}
|
|
51
83
|
}
|
|
52
84
|
|
|
85
|
+
/**
|
|
86
|
+
* @description: it will take pdf file path as input and will return array of strings(each each line in pdf is each item in result array).
|
|
87
|
+
* @param {string} filePath - Complete path of the excel file, example: C:/resources/****.pdf.
|
|
88
|
+
* @returns { Array<string>} - returns array os string, each string represents each line in pdf
|
|
89
|
+
*/
|
|
53
90
|
static async readPdfFile(filePath: string) {
|
|
54
91
|
const items = [];
|
|
55
92
|
return new Promise((resolve, reject) => {
|
|
@@ -5,6 +5,16 @@ import fs from 'fs';
|
|
|
5
5
|
|
|
6
6
|
export class LightHouseUtility {
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* @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.
|
|
10
|
+
* @param {string} pageurl - url of the given page which needs to be calculated.
|
|
11
|
+
* @param {string} deviceType - type of device i.e desktop or mobile.
|
|
12
|
+
* @param {string} filename - to save the result the filename.
|
|
13
|
+
* @param {object} customThresholds - It is optional threshold object. example: {performance: 80,accessibility: 70,
|
|
14
|
+
'best-practices': 70,seo: 70, pwa: 70,} these are the default values.
|
|
15
|
+
* @param {object} format - This is optional. example: { html: true, csv:true, json: true}.
|
|
16
|
+
* @returns {Promise<void>} - returns void promise.
|
|
17
|
+
*/
|
|
8
18
|
static async auditLightHouse(pageurl: string, deviceType, filename, customThresholds = {
|
|
9
19
|
performance: 80,
|
|
10
20
|
accessibility: 70,
|
|
@@ -31,6 +41,13 @@ export class LightHouseUtility {
|
|
|
31
41
|
});
|
|
32
42
|
}
|
|
33
43
|
|
|
44
|
+
/**
|
|
45
|
+
* @description: it creates new index.html file which has links to all pages htnl files.
|
|
46
|
+
* @param {string} dirPath - Complete path of the directory which contains Lighthouse performace html files, example: C:/lighthouse.
|
|
47
|
+
* @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/
|
|
48
|
+
* @param {String} applicationName - Name of the Application
|
|
49
|
+
* @returns {Promise<void>} - returns void promise.
|
|
50
|
+
*/
|
|
34
51
|
static async createLightHouseReport(dirPath: string, savefilepath: string, applicationName) {
|
|
35
52
|
var str = ``;
|
|
36
53
|
var sno = 0;
|
|
@@ -73,7 +90,7 @@ export class LightHouseUtility {
|
|
|
73
90
|
</head>
|
|
74
91
|
<body>
|
|
75
92
|
|
|
76
|
-
<h1><u>`+applicationName
|
|
93
|
+
<h1><u>`+ applicationName + ` Performance Testing Status</u></h1>
|
|
77
94
|
<div>
|
|
78
95
|
<table class='center'>
|
|
79
96
|
<tr class='center'>
|
package/src/utils/test_data.ts
CHANGED
|
@@ -3,6 +3,11 @@ const sql = require('mssql');
|
|
|
3
3
|
|
|
4
4
|
export class TestData {
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* @description: establish the connection with database.
|
|
8
|
+
* @param {string} configuration - example: {server: string, database: string, username:string, password: string, portNumber: number}.
|
|
9
|
+
* @returns {Connection} - returns connection object.
|
|
10
|
+
*/
|
|
6
11
|
static async sqlDBConnection(configuration: any) {
|
|
7
12
|
// var server = "zwetrvl2sqd001.database.windows.net";
|
|
8
13
|
// var database ="zwetrvl2sqd001-DB002";
|
|
@@ -21,13 +26,19 @@ export class TestData {
|
|
|
21
26
|
authentication: {
|
|
22
27
|
// type: "azure-active-directory-service-principal-secret",
|
|
23
28
|
type: "default"
|
|
24
|
-
|
|
29
|
+
|
|
25
30
|
}
|
|
26
31
|
};
|
|
27
32
|
var conn = new sql.ConnectionPool(config);
|
|
28
33
|
return conn;
|
|
29
34
|
|
|
30
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* @description: establish the connection with database.
|
|
38
|
+
* @param {string} connectionObj - connection object which will come from sqlDBConnection()
|
|
39
|
+
* @param {string} queryString - query to execute
|
|
40
|
+
* @returns {Connection} - returns connection object.
|
|
41
|
+
*/
|
|
31
42
|
static async executeSqlQuery(connectionObj: any, queryString: any) {
|
|
32
43
|
var pool1Connect = await connectionObj.connect();
|
|
33
44
|
connectionObj.on('error', err => {
|
|
@@ -47,7 +58,7 @@ export class TestData {
|
|
|
47
58
|
|
|
48
59
|
}
|
|
49
60
|
|
|
50
|
-
|
|
61
|
+
|
|
51
62
|
|
|
52
63
|
static async generateRandomUniqeIDNumber() {
|
|
53
64
|
const d = new Date();
|
|
@@ -55,7 +66,7 @@ export class TestData {
|
|
|
55
66
|
let seconds = d.getSeconds();
|
|
56
67
|
let hour = d.getHours();
|
|
57
68
|
const result = Math.random().toString(36).substring(2, 5).toUpperCase();
|
|
58
|
-
let localUid = "SNO"+result + hour + minutes.toString() + seconds;
|
|
69
|
+
let localUid = "SNO" + result + hour + minutes.toString() + seconds;
|
|
59
70
|
return localUid;
|
|
60
71
|
|
|
61
72
|
}
|
|
@@ -73,12 +84,12 @@ export class TestData {
|
|
|
73
84
|
return localDate.toISOString()
|
|
74
85
|
|
|
75
86
|
}
|
|
76
|
-
|
|
77
|
-
static async waitFortimeOut(waitTime
|
|
78
|
-
const sleep = (waitTimeInMs
|
|
87
|
+
|
|
88
|
+
static async waitFortimeOut(waitTime: any) {
|
|
89
|
+
const sleep = (waitTimeInMs: any) => new Promise(resolve => setTimeout(resolve, waitTimeInMs));
|
|
79
90
|
await sleep(waitTime);
|
|
80
91
|
}
|
|
81
|
-
static async executeCosmosQuery(queryString
|
|
92
|
+
static async executeCosmosQuery(queryString: any) {
|
|
82
93
|
/*var endpoint = process.env.cosmosConfig.endpoint;
|
|
83
94
|
var key = process.env.cosmosConfig.key;
|
|
84
95
|
var databaseId = process.env.cosmosConfig.databaseId;
|
|
@@ -99,7 +110,7 @@ export class TestData {
|
|
|
99
110
|
return items;*/
|
|
100
111
|
}
|
|
101
112
|
|
|
102
|
-
static async getUTCTimeCustom(localTime
|
|
113
|
+
static async getUTCTimeCustom(localTime: any) {
|
|
103
114
|
|
|
104
115
|
console.log(localTime);
|
|
105
116
|
var localDate = new Date();
|