froth-webdriverio-framework 7.0.43 → 7.0.44
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/froth_api_calls/getexecutionDetails.js +9 -9
- package/froth_api_calls/getsuiteDetails.js +9 -9
- package/package.json +1 -1
- package/froth_common_actions_back/Utils.js +0 -167
- package/froth_common_actions_back/alert.js +0 -49
- package/froth_common_actions_back/apicall.js +0 -179
- package/froth_common_actions_back/assert.js +0 -85
- package/froth_common_actions_back/captureNavigationTime.js +0 -53
- package/froth_common_actions_back/click.js +0 -57
- package/froth_common_actions_back/dropDown.js +0 -34
- package/froth_common_actions_back/emailParsing.js +0 -161
- package/froth_common_actions_back/jwt.js +0 -64
- package/froth_common_actions_back/logData.js +0 -73
- package/froth_common_actions_back/random.js +0 -230
- package/froth_common_actions_back/scroll.js +0 -104
- package/froth_common_actions_back/storeToBuffer.js +0 -45
- package/froth_common_actions_back/swicthWindowTab.js +0 -36
- package/froth_common_actions_back/swipe.js +0 -219
- package/froth_configs_back/commonconfig.js +0 -409
- package/froth_configs_back/setallDatailinBuffer.js +0 -100
- package/froth_configs_back/wdio.common.conf.js +0 -53
- package/froth_configs_back/wdio.common.conf_back.js +0 -138
|
@@ -47,18 +47,18 @@ async function getExecuitonDetails(frothUrl, token, id) {
|
|
|
47
47
|
headers: DEFAULT_HEADERS(token)
|
|
48
48
|
});
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
const data = await handleResponse(response, 'getExecuitonDetails');
|
|
51
|
+
if (!data) return null;
|
|
52
52
|
|
|
53
|
-
let data = await handleResponse(response, 'getExecuitonDetails');
|
|
54
|
-
// let responseData = await response.json()
|
|
53
|
+
// let data = await handleResponse(response, 'getExecuitonDetails');
|
|
54
|
+
// // let responseData = await response.json()
|
|
55
55
|
|
|
56
|
-
data = await aes.decrpytData(data.data)
|
|
57
|
-
// console.log("after decrypting",data)
|
|
56
|
+
// data = await aes.decrpytData(data.data)
|
|
57
|
+
// // console.log("after decrypting",data)
|
|
58
58
|
|
|
59
|
-
data = JSON.parse(data)
|
|
60
|
-
// console.log("json parsing",data)
|
|
61
|
-
if (!data) return null;
|
|
59
|
+
// data = JSON.parse(data)
|
|
60
|
+
// // console.log("json parsing",data)
|
|
61
|
+
// if (!data) return null;
|
|
62
62
|
|
|
63
63
|
const jsondata = {
|
|
64
64
|
automation_suite_id: data?.automation_suite_details?.id ?? null,
|
|
@@ -29,18 +29,18 @@ async function getSuiteDetails(frothUrl, token, suiteId) {
|
|
|
29
29
|
}
|
|
30
30
|
});
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
const data = await handleResponse(response, 'getExecuitonDetails');
|
|
33
|
+
if (!data) return null;
|
|
34
34
|
|
|
35
|
-
let resData = await handleResponse(response, 'getSuiteDetails');
|
|
36
|
-
if (!resData || !resData.data) return jsonData;
|
|
35
|
+
// let resData = await handleResponse(response, 'getSuiteDetails');
|
|
36
|
+
// if (!resData || !resData.data) return jsonData;
|
|
37
37
|
|
|
38
|
-
// Decrypt the data
|
|
39
|
-
let decryptedData = await aes.decrpytData(resData.data);
|
|
40
|
-
if (!decryptedData) return jsonData;
|
|
38
|
+
// // Decrypt the data
|
|
39
|
+
// let decryptedData = await aes.decrpytData(resData.data);
|
|
40
|
+
// if (!decryptedData) return jsonData;
|
|
41
41
|
|
|
42
|
-
// Parse JSON
|
|
43
|
-
let data;
|
|
42
|
+
// // Parse JSON
|
|
43
|
+
// let data;
|
|
44
44
|
try {
|
|
45
45
|
data = JSON.parse(decryptedData);
|
|
46
46
|
} catch (parseError) {
|
package/package.json
CHANGED
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
const assert = require("assert");
|
|
2
|
-
|
|
3
|
-
// This file contains the common methods that are used in the test scripts
|
|
4
|
-
let scrollToEnd = null;
|
|
5
|
-
let scrollToBeginning = null;
|
|
6
|
-
let scrollToLeft = null;
|
|
7
|
-
let scrollToRight = null;
|
|
8
|
-
let scrollDownToView = null;
|
|
9
|
-
let scrollRightToView = null;
|
|
10
|
-
let scrollUpUntilVisible = null;
|
|
11
|
-
|
|
12
|
-
let swipeRight = null;
|
|
13
|
-
let swipeLeft = null;
|
|
14
|
-
let swipeUp = null;
|
|
15
|
-
let swipeDown = null;
|
|
16
|
-
let swipetoFit = null;
|
|
17
|
-
let swipeWithCoordinates = null;
|
|
18
|
-
|
|
19
|
-
let clickIfVisible = null;
|
|
20
|
-
let doubleClick = null;
|
|
21
|
-
|
|
22
|
-
let assertText = null;
|
|
23
|
-
|
|
24
|
-
let random = null;
|
|
25
|
-
let randomtext = null;
|
|
26
|
-
let randomnumber = null;
|
|
27
|
-
let randomfloat = null;
|
|
28
|
-
let randomint = null;
|
|
29
|
-
let randomalphanum = null;
|
|
30
|
-
let randomdecimal = null;
|
|
31
|
-
let randomregex = null;
|
|
32
|
-
let randomdate = null;
|
|
33
|
-
|
|
34
|
-
let storetext = null;
|
|
35
|
-
let storevalue = null;
|
|
36
|
-
let storeattributevalue = null;
|
|
37
|
-
let assertAttributeValue = null;
|
|
38
|
-
let basepath = null;
|
|
39
|
-
let scrollIntoView = null;
|
|
40
|
-
|
|
41
|
-
let api = null;
|
|
42
|
-
|
|
43
|
-
let selectDropDownValue = null;
|
|
44
|
-
let selectDropDownText = null;
|
|
45
|
-
|
|
46
|
-
let acceptAlert = null;
|
|
47
|
-
let dismissAlert = null;
|
|
48
|
-
|
|
49
|
-
let generateJWT = null;
|
|
50
|
-
|
|
51
|
-
let switchToWindowByTitle = null;
|
|
52
|
-
let switchToWindowByIndex = null;
|
|
53
|
-
|
|
54
|
-
let captureLoadNavigation = null;
|
|
55
|
-
let amendBrowserStackLog = null;
|
|
56
|
-
let logJsonDataToTable = null;
|
|
57
|
-
|
|
58
|
-
let extractEmailLinks = null;
|
|
59
|
-
|
|
60
|
-
if (process.env.LOCATION == null || process.env.LOCATION == 'local') {
|
|
61
|
-
basepath = ".";
|
|
62
|
-
} else {
|
|
63
|
-
basepath = "froth-webdriverio-framework/froth_common_actions";
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
scrollToEnd = require(basepath + "/scroll").scrollToEnd;
|
|
67
|
-
scrollToBeginning = require(basepath + '/scroll').scrollToBeginning;
|
|
68
|
-
scrollToLeft = require(basepath + '/scroll').scrollToLeft;
|
|
69
|
-
scrollToRight = require(basepath + '/scroll').scrollToRight;
|
|
70
|
-
scrollDownToView = require(basepath + '/scroll').scrollDownToView;
|
|
71
|
-
scrollRightToView = require(basepath + '/scroll').scrollRightToView;
|
|
72
|
-
scrollIntoView = require(basepath + '/scroll').scrollIntoView;
|
|
73
|
-
scrollUpUntilVisible = require(basepath + '/scroll').scrollupUntilVisible;
|
|
74
|
-
switchToWindowByTitle = require(basepath + '/swicthWindowTab').switch2WindowByTitle;
|
|
75
|
-
switchToWindowByIndex = require(basepath + '/swicthWindowTab').switch2WindowByIndex;
|
|
76
|
-
|
|
77
|
-
swipeDown = require(basepath + '/swipe').swipedown;
|
|
78
|
-
swipeLeft = require(basepath + '/swipe').swipeleft;
|
|
79
|
-
swipeRight = require(basepath + '/swipe').swiperight;
|
|
80
|
-
swipeUp = require(basepath + '/swipe').swipeup;
|
|
81
|
-
swipetoFit = require(basepath + '/swipe').swipetofit;
|
|
82
|
-
swipeWithCoordinates = require(basepath + '/swipe').swipewithcoordinates;
|
|
83
|
-
|
|
84
|
-
clickIfVisible = require(basepath + "/click").clickIfVisible;
|
|
85
|
-
clickByIdWithExecute = require(basepath + "/click").clickByIdWithExecute;
|
|
86
|
-
doubleClick = require(basepath + "/click").doubleclick;
|
|
87
|
-
|
|
88
|
-
assertText = require(basepath + '/assert').assertText;
|
|
89
|
-
assertAttributeValue = require(basepath + '/assert').assertAttributeValue;
|
|
90
|
-
|
|
91
|
-
randomtext = require(basepath + '/random').RANDOMTEXT;
|
|
92
|
-
randomnumber = require(basepath + '/random').RNDNUMBER;
|
|
93
|
-
randomfloat = require(basepath + '/random').RNDFLOAT;
|
|
94
|
-
randomint = require(basepath + '/random').RNDINT;
|
|
95
|
-
randomalphanum = require(basepath + '/random').RNDALPHANUM;
|
|
96
|
-
randomdecimal = require(basepath + '/random').RNDDECIMAL;
|
|
97
|
-
randomregex = require(basepath + '/random').RNDREGEX;
|
|
98
|
-
random = require(basepath + '/random').RANDOM;
|
|
99
|
-
randomdate = require(basepath + '/random').RNDDATE;
|
|
100
|
-
|
|
101
|
-
storetext = require(basepath + '/storeToBuffer').STORETEXT;
|
|
102
|
-
storevalue = require(basepath + '/storeToBuffer').STOREVALUE;
|
|
103
|
-
storeattributevalue = require(basepath + '/storeToBuffer').STOREATTRIBUTEVALUE;
|
|
104
|
-
|
|
105
|
-
api = require(basepath + '/apicall').callapi;
|
|
106
|
-
validate = require(basepath + '/apicall').validate;
|
|
107
|
-
|
|
108
|
-
selectDropDownValue = require(basepath + '/dropDown').select4mDropDownValue;
|
|
109
|
-
selectDropDownText= require(basepath + '/dropDown').select4mDropDownText;
|
|
110
|
-
|
|
111
|
-
acceptAlert = require(basepath + '/alert.js').acceptalert;
|
|
112
|
-
dismissAlert = require(basepath + '/alert.js').dismissalert;
|
|
113
|
-
|
|
114
|
-
generateJWT = require(basepath + '/jwt').generateJWTToken;
|
|
115
|
-
captureLoadNavigation= require(basepath + '/captureNavigationTime').captureLoadNavigationTime;
|
|
116
|
-
|
|
117
|
-
amendBrowserStackLog= require(basepath + '/../froth_api_calls/browsersatckSessionInfo').amend2Browserstack;
|
|
118
|
-
logJsonDataToTable= require(basepath + '/logData').logJsonData2Table;
|
|
119
|
-
|
|
120
|
-
extractEmailLinks = require(basepath + '/emailParsing');
|
|
121
|
-
//export the variabels
|
|
122
|
-
module.exports = {
|
|
123
|
-
scrollToEnd,
|
|
124
|
-
scrollToBeginning,
|
|
125
|
-
scrollToLeft,
|
|
126
|
-
scrollToRight,
|
|
127
|
-
scrollDownToView,
|
|
128
|
-
scrollRightToView,
|
|
129
|
-
clickIfVisible,
|
|
130
|
-
clickByIdWithExecute,
|
|
131
|
-
doubleClick,
|
|
132
|
-
assertText,
|
|
133
|
-
assertAttributeValue,
|
|
134
|
-
random,
|
|
135
|
-
randomtext,
|
|
136
|
-
randomnumber,
|
|
137
|
-
randomfloat,
|
|
138
|
-
randomint,
|
|
139
|
-
randomalphanum,
|
|
140
|
-
randomdecimal,
|
|
141
|
-
randomregex,
|
|
142
|
-
randomdate,
|
|
143
|
-
storetext,
|
|
144
|
-
storevalue,
|
|
145
|
-
storeattributevalue,
|
|
146
|
-
scrollIntoView,
|
|
147
|
-
scrollUpUntilVisible,
|
|
148
|
-
api,
|
|
149
|
-
validate,
|
|
150
|
-
selectDropDownValue,
|
|
151
|
-
selectDropDownText,
|
|
152
|
-
acceptAlert,
|
|
153
|
-
dismissAlert,
|
|
154
|
-
swipeLeft,
|
|
155
|
-
swipeRight,
|
|
156
|
-
swipeDown,
|
|
157
|
-
swipeUp,
|
|
158
|
-
swipetoFit,
|
|
159
|
-
swipeWithCoordinates,
|
|
160
|
-
generateJWT,
|
|
161
|
-
switchToWindowByTitle,
|
|
162
|
-
switchToWindowByIndex,
|
|
163
|
-
captureLoadNavigation,
|
|
164
|
-
amendBrowserStackLog,
|
|
165
|
-
logJsonDataToTable,
|
|
166
|
-
extractEmailLinks
|
|
167
|
-
};
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
async function acceptalert() {
|
|
2
|
-
|
|
3
|
-
try {
|
|
4
|
-
let alertFound = false;
|
|
5
|
-
for (let i = 0; i < 6; i++) {
|
|
6
|
-
if (await browser.isAlertOpen()) {
|
|
7
|
-
alertFound = true;
|
|
8
|
-
break;
|
|
9
|
-
}
|
|
10
|
-
await browser.pause(10000); // wait for 10 seconds
|
|
11
|
-
}
|
|
12
|
-
if (!alertFound) {
|
|
13
|
-
console.log('Expected alert to appear but it did not');
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
// await browser.waitUntil(async () => {
|
|
17
|
-
// return await browser.isAlertOpen();
|
|
18
|
-
// }, {
|
|
19
|
-
// timeout: 5000,
|
|
20
|
-
// timeoutMsg: 'Expected alert to appear but it did not'
|
|
21
|
-
// });
|
|
22
|
-
await browser.acceptAlert();
|
|
23
|
-
|
|
24
|
-
} catch (e) {
|
|
25
|
-
console.log("error occured while accepting alert", e)
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
async function dismissalert() {
|
|
31
|
-
try {
|
|
32
|
-
await browser.waitUntil(async () => {
|
|
33
|
-
return await browser.isAlertOpen();
|
|
34
|
-
}, {
|
|
35
|
-
timeout: 5000,
|
|
36
|
-
timeoutMsg: 'Expected alert to appear but it did not'
|
|
37
|
-
});
|
|
38
|
-
await browser.dismissAlert();
|
|
39
|
-
|
|
40
|
-
} catch (e) {
|
|
41
|
-
console.log("error occured while dismissing alert", e)
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
module.exports = { acceptalert, dismissalert };
|
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
const axios = require('axios');
|
|
2
|
-
|
|
3
|
-
const amendToBrowserstack = require("../froth_api_calls/browsersatckSessionInfo").amend2Browserstack;
|
|
4
|
-
|
|
5
|
-
async function callapi(methodtype, api_url, queryParams, payloaddetails, body_type, authentication, headersdetails, attachments) {
|
|
6
|
-
let response;
|
|
7
|
-
// if (queryParams && Object.keys(queryParams).length > 0) {
|
|
8
|
-
// const queryString = new URLSearchParams(queryParams).toString();
|
|
9
|
-
// api_url += `?${queryString}`;
|
|
10
|
-
// }
|
|
11
|
-
console.log("Final API URL:", api_url);
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
try {
|
|
15
|
-
|
|
16
|
-
let method = methodtype.toUpperCase();
|
|
17
|
-
let headers = await formheaders(authentication, headersdetails, body_type);
|
|
18
|
-
let body = null;
|
|
19
|
-
console.log("Body Type:", body_type);
|
|
20
|
-
console.log("method:", method);
|
|
21
|
-
console.log("headers:", headers);
|
|
22
|
-
|
|
23
|
-
if (body_type === "raw" && payloaddetails && Object.keys(payloaddetails).length > 0) {
|
|
24
|
-
console.log("Payload (JSON):", JSON.stringify(payloaddetails));
|
|
25
|
-
body = JSON.stringify(payloaddetails);
|
|
26
|
-
console.log("Payload (raw):", body);
|
|
27
|
-
} else if (body_type === "form-data" && payloaddetails) {
|
|
28
|
-
body = await jsonToFormData(payloaddetails);
|
|
29
|
-
console.log("Payload (FormData):", body);
|
|
30
|
-
for (let [key, value] of body.entries()) {
|
|
31
|
-
console.log(`FormData Key: ${key}, Value: ${value}`);
|
|
32
|
-
}
|
|
33
|
-
} else {
|
|
34
|
-
console.log("No body sent (body_type not provided or empty payload).");
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
console.warn("Warning: GET request with a body is non-standard and may not work with all APIs.");
|
|
39
|
-
const config = {
|
|
40
|
-
method: method,
|
|
41
|
-
url: api_url,
|
|
42
|
-
headers: headers
|
|
43
|
-
};
|
|
44
|
-
const isBodyEmpty =
|
|
45
|
-
body === null ||
|
|
46
|
-
body === undefined ||
|
|
47
|
-
body === ''
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
if (!isBodyEmpty) {
|
|
51
|
-
config.data = body;
|
|
52
|
-
}
|
|
53
|
-
console.log("body:", body);
|
|
54
|
-
console.log("Config for API call:", config);
|
|
55
|
-
response = await axios(config);
|
|
56
|
-
|
|
57
|
-
// response = await axios({
|
|
58
|
-
// method: method,
|
|
59
|
-
// url: api_url,
|
|
60
|
-
// headers: headers,
|
|
61
|
-
// data: body === null ? undefined : body // Axios allows body with GET in some cases
|
|
62
|
-
// });
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
console.log("Response Data:", response.data);
|
|
66
|
-
|
|
67
|
-
} catch (error) {
|
|
68
|
-
console.error('Error during API call in call api menthod:', error);
|
|
69
|
-
let annotationMessage = 'Error during API call:' + error.response ? error.response.data : error.message;
|
|
70
|
-
await amendToBrowserstack(annotationMessage, "error");
|
|
71
|
-
throw error;
|
|
72
|
-
}
|
|
73
|
-
return response;
|
|
74
|
-
}
|
|
75
|
-
async function jsonToFormData(json) {
|
|
76
|
-
const formData = new FormData();
|
|
77
|
-
|
|
78
|
-
function appendFormData(data, parentKey = '') {
|
|
79
|
-
if (data && typeof data === 'object' && !Array.isArray(data)) {
|
|
80
|
-
for (const key in data) {
|
|
81
|
-
if (data.hasOwnProperty(key)) {
|
|
82
|
-
appendFormData(data[key], parentKey ? `${parentKey}[${key}]` : key);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
} else {
|
|
86
|
-
formData.append(parentKey, data);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
appendFormData(json);
|
|
91
|
-
console.log("FormData in json to formdata:", formData);
|
|
92
|
-
return formData;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// Function to form headers
|
|
96
|
-
async function formheaders(authentication, headers, body_type) {
|
|
97
|
-
try {
|
|
98
|
-
if (!headers || typeof headers !== "object") {
|
|
99
|
-
headers = {};
|
|
100
|
-
}
|
|
101
|
-
if (body_type === "raw") {
|
|
102
|
-
headers['Content-Type'] = 'application/json';
|
|
103
|
-
}
|
|
104
|
-
// Add authentication headers based on the type
|
|
105
|
-
if (authentication && authentication.auth_type) {
|
|
106
|
-
if (authentication.auth_type?.toLowerCase() === 'bearer') {
|
|
107
|
-
console.log('Bearer token:', authentication.token);
|
|
108
|
-
headers.Authorization = `Bearer ` + authentication.token;
|
|
109
|
-
} else if (authentication.auth_type?.toLowerCase() === 'basic') {
|
|
110
|
-
headers.Authorization = `Basic ` + btoa(authentication.username + `:` + authentication.password);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
console.log('Headers:', headers);
|
|
114
|
-
} catch (e) {
|
|
115
|
-
|
|
116
|
-
console.error('Error in formheaders:', e);
|
|
117
|
-
let annotationMessage = `Error during API call: ${error.response?.data || error.message}`;
|
|
118
|
-
await amendToBrowserstack(annotationMessage, "error");
|
|
119
|
-
}
|
|
120
|
-
return headers;
|
|
121
|
-
|
|
122
|
-
}
|
|
123
|
-
async function validate(attribute_name, attribute, actionname, buffer, buffername_value, datatype) {
|
|
124
|
-
|
|
125
|
-
if (actionname.toLowerCase() == "verify") {
|
|
126
|
-
await validateAttributeData(attribute_name, attribute, buffer, buffername_value, datatype);
|
|
127
|
-
} else if (actionname.toLowerCase() == "setbuffer") {
|
|
128
|
-
BUFFER.setItem(buffername_value, attribute);
|
|
129
|
-
let annotationMessage = `The vlaue has been stored in the buffer : ${buffername_value}.`;
|
|
130
|
-
await amendToBrowserstack(annotationMessage, "info");
|
|
131
|
-
|
|
132
|
-
} else if (actionname.toLowerCase() == "getbuffer") {
|
|
133
|
-
let annotationMessage = `The vlaue has been retrived from the buffer : ${buffername_value}.`;
|
|
134
|
-
await amendToBrowserstack(annotationMessage, "info");
|
|
135
|
-
return await BUFFER.getItem(buffername_value);
|
|
136
|
-
|
|
137
|
-
}
|
|
138
|
-
// } catch (e) {
|
|
139
|
-
// console.error('Error in validate method:', e);
|
|
140
|
-
// throw e;
|
|
141
|
-
// }
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
async function validateAttributeData(attribute_name, attribute, buffer, buffername_value, datatype) {
|
|
145
|
-
let assertionStatus = false; // Initialize status
|
|
146
|
-
let valueToVerify;
|
|
147
|
-
|
|
148
|
-
try {
|
|
149
|
-
//if buffer is true, get the value from buffer
|
|
150
|
-
buffer ? valueToVerify = BUFFER.getItem(buffername_value) : valueToVerify = buffername_value;
|
|
151
|
-
|
|
152
|
-
if (datatype.toLowerCase() == "integer") {
|
|
153
|
-
valueToVerify = Number(valueToVerify);
|
|
154
|
-
} else if (datatype.toLowerCase() == "boolean") {
|
|
155
|
-
valueToVerify = Boolean(valueToVerify);
|
|
156
|
-
} else if (datatype.toLowerCase() == "decimal") {
|
|
157
|
-
valueToVerify = parseFloat(valueToVerify);
|
|
158
|
-
} else if (datatype.toLowerCase() == "string") {
|
|
159
|
-
valueToVerify = valueToVerify.toString();
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
expect(attribute).toBe(valueToVerify, `${attribute_name} --> Expected value: ${valueToVerify}, but got: ${attribute}`);
|
|
163
|
-
assertionStatus = true; // If assertion passes, set status to true
|
|
164
|
-
|
|
165
|
-
console.log(`Attribute name : ${attribute_name} verification passed. Actual text: ${attribute}, Expected text: ${valueToVerify}.`);
|
|
166
|
-
let annotationMessage = `Attribute name : ${attribute_name} - verification passed. Actual text: ${attribute}, Expected text: ${valueToVerify}.`;
|
|
167
|
-
await amendToBrowserstack(annotationMessage, "info");
|
|
168
|
-
|
|
169
|
-
} catch (e) {
|
|
170
|
-
console.error('Error in validateAttributeData:', e);
|
|
171
|
-
console.log(`Attribute name : ${attribute_name} verification failed. Expected text: ${valueToVerify}. error: ${e.toString()}`);
|
|
172
|
-
let annotationMessage = `Attribute name : ${attribute_name} - verification failed. Expected text: ${valueToVerify}. error: ${e.toString()}`;
|
|
173
|
-
await amendToBrowserstack(annotationMessage, "error");
|
|
174
|
-
|
|
175
|
-
throw e;
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
module.exports = { callapi, validate };
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
// Function to verify text in Android app
|
|
2
|
-
import assert from 'assert';
|
|
3
|
-
const amendToBrowserstack = require("../froth_api_calls/browsersatckSessionInfo").amend2Browserstack;
|
|
4
|
-
|
|
5
|
-
async function assertText(elementSelector, expectedText) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
console.log("inside the assert text function" + elementSelector)
|
|
9
|
-
try {
|
|
10
|
-
let element = await $(elementSelector)
|
|
11
|
-
try {
|
|
12
|
-
await expect(element).toHaveText(expectedText);
|
|
13
|
-
console.log("Assertion succeeded.");
|
|
14
|
-
actualText = await element.getText();
|
|
15
|
-
let annotationMessage = `Assertion passed. Actual text: ${actualText}, Expected text: ${expectedText}.`;
|
|
16
|
-
await amendToBrowserstack(annotationMessage, "info");
|
|
17
|
-
} catch (error) {
|
|
18
|
-
console.log(`Assertion failed. Expected text: ${expectedText}.`);
|
|
19
|
-
let annotationMessage = `Assertion failed. Expected text: ${expectedText}.`;
|
|
20
|
-
await amendToBrowserstack(annotationMessage, "error");
|
|
21
|
-
if (!browser.testErrors) browser.testErrors = [];
|
|
22
|
-
// browser.testErrors.push(`Assertion failed.: ${error.message}`);
|
|
23
|
-
assert.fail(`Text assertion failed: ${error.message}`);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
} catch (error) {
|
|
28
|
-
console.error('Error occurred while verifying text:', error);
|
|
29
|
-
let annotationMessage = `Error occurred while verifying text: ${error.message}.`;
|
|
30
|
-
await amendToBrowserstack(annotationMessage, "error");
|
|
31
|
-
if (!browser.testErrors) browser.testErrors = [];
|
|
32
|
-
// browser.testErrors.push(`Assertion failed.: ${error.message}`);
|
|
33
|
-
assert.fail(`Text assertion failed: ${error.message}`);
|
|
34
|
-
// throw error;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
async function assertAttributeValue(elementSelector, attributeName, expectedText) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
console.log("inside the assertAttributeValue function" + elementSelector)
|
|
44
|
-
try {
|
|
45
|
-
let element = await $(elementSelector)
|
|
46
|
-
try {
|
|
47
|
-
await expect(element).toHaveAttribute(attributeName, expectedText);
|
|
48
|
-
let actualText;
|
|
49
|
-
actualText = await element.getAttribute(attributeName);
|
|
50
|
-
console.log("Assertion succeeded.");
|
|
51
|
-
let annotationMessage = `Assertion passed. Attribute value: ${actualText}, Expected value: ${expectedText}.`;
|
|
52
|
-
await amendToBrowserstack(annotationMessage, "info");
|
|
53
|
-
} catch (error) {
|
|
54
|
-
console.warn("Assertion failed:", error.message);
|
|
55
|
-
let annotationMessage = `Assertion failed. Expected text: ${expectedText}. ,${error.message}`;
|
|
56
|
-
await amendToBrowserstack(annotationMessage, "error");
|
|
57
|
-
console.log("Assertion failed. Expected text: ", expectedText);
|
|
58
|
-
if (!browser.testErrors) browser.testErrors = [];
|
|
59
|
-
// browser.testErrors.push(`Assertion failed.: ${error.message}`);
|
|
60
|
-
assert.fail(`Text assertion failed: ${error.message}`);
|
|
61
|
-
}
|
|
62
|
-
} catch (error) {
|
|
63
|
-
console.error('Error occurred while verifying text:', error);
|
|
64
|
-
let annotationMessage = `Error occurred while asserting Attribute: ${error.message}.`;
|
|
65
|
-
await amendToBrowserstack(annotationMessage, "error");
|
|
66
|
-
if (!browser.testErrors) browser.testErrors = [];
|
|
67
|
-
// browser.testErrors.push(`Assertion failed.: ${error.message}`);
|
|
68
|
-
assert.fail(`Text assertion failed: ${error.message}`);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// async function amendToBrowserstack(annotationMessage, level) {
|
|
75
|
-
// try {
|
|
76
|
-
// await driver.execute('browserstack_executor: {"action": "annotate", "arguments": {"data":"' + annotationMessage + '","level": "' + level + '"}}');
|
|
77
|
-
|
|
78
|
-
// } catch (error) {
|
|
79
|
-
// console.error('Error occurred while annoting into BS', error);
|
|
80
|
-
// throw error;
|
|
81
|
-
// }
|
|
82
|
-
// }
|
|
83
|
-
module.exports = { assertText, assertAttributeValue };
|
|
84
|
-
|
|
85
|
-
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
const amendToBrowserstack = require("../froth_api_calls/browsersatckSessionInfo").amend2Browserstack;
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Capture Navigation / Page Load time
|
|
6
|
-
* @param {string} pageName - (Optional) Custom name for the page
|
|
7
|
-
*/
|
|
8
|
-
async function captureLoadNavigationTime(pageName = '') {
|
|
9
|
-
let pageLoadTime;
|
|
10
|
-
try {
|
|
11
|
-
// Try modern API first
|
|
12
|
-
let perfEntries = await browser.execute(() => {
|
|
13
|
-
if (performance.getEntriesByType) {
|
|
14
|
-
const [nav] = performance.getEntriesByType('navigation');
|
|
15
|
-
return nav ? nav.toJSON() : null;
|
|
16
|
-
}
|
|
17
|
-
return null;
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
if (perfEntries && perfEntries.loadEventEnd) {
|
|
22
|
-
pageLoadTime = perfEntries.loadEventEnd;
|
|
23
|
-
} else {
|
|
24
|
-
// Fallback to old API
|
|
25
|
-
const perfTiming = await browser.execute(() => JSON.stringify(window.performance.timing));
|
|
26
|
-
const timing = JSON.parse(perfTiming);
|
|
27
|
-
pageLoadTime = timing.loadEventEnd - timing.navigationStart;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// If no custom name passed, use the page title
|
|
31
|
-
let title = pageName || await browser.getTitle();
|
|
32
|
-
|
|
33
|
-
// Clean title: remove special characters, keep words separated by space
|
|
34
|
-
title = title
|
|
35
|
-
.replace(/[^a-zA-Z0-9]+/g, ' ') // replace non-alphanumeric with space
|
|
36
|
-
.replace(/\s+/g, ' ') // collapse multiple spaces
|
|
37
|
-
.trim(); // remove leading/trailing spaces
|
|
38
|
-
|
|
39
|
-
pageLoadTime = perfEntries.loadEventEnd; // Already relative to startTime
|
|
40
|
-
pageLoadTime = (pageLoadTime / 1000).toFixed(2); // Convert ms to seconds, keep 2 decimals
|
|
41
|
-
await amendToBrowserstack(`⏱ Page Load Time for ${title}: ${pageLoadTime} seconds`, "info");
|
|
42
|
-
|
|
43
|
-
console.log(`⏱ Page Load Time for ${title}: ${pageLoadTime} seconds`);
|
|
44
|
-
} catch (error) {
|
|
45
|
-
console.error('Error capturing navigation timing:', error);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return pageLoadTime;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
module.exports = { captureLoadNavigationTime };
|
|
53
|
-
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
async function clickIfVisible(elementSelector) {
|
|
2
|
-
try {
|
|
3
|
-
let isDisplayed;
|
|
4
|
-
// Wait for the element to be visible
|
|
5
|
-
await driver.waitUntil(async () => {
|
|
6
|
-
console.log("Waiting for element to be visible");
|
|
7
|
-
const element = await $(elementSelector);
|
|
8
|
-
isDisplayed = await element.isDisplayed();
|
|
9
|
-
console.log("Element is displayed:", isDisplayed);
|
|
10
|
-
if (isDisplayed) {
|
|
11
|
-
// Get the actual text from the element
|
|
12
|
-
const element = await $(elementSelector);
|
|
13
|
-
await element.click();
|
|
14
|
-
console.log("Element is clicked successfully.");
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
}, { timeout: 30000 });
|
|
18
|
-
} catch (error) {
|
|
19
|
-
console.error("Element not found or not visible within 30 seconds");
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
async function doubleclick(elementSelector) {
|
|
24
|
-
try {
|
|
25
|
-
let isDisplayed;
|
|
26
|
-
// Wait for the element to be visible
|
|
27
|
-
await driver.waitUntil(async () => {
|
|
28
|
-
console.log("Waiting for element to be visible");
|
|
29
|
-
const element = await $(elementSelector);
|
|
30
|
-
isDisplayed = await element.isDisplayed();
|
|
31
|
-
console.log("Element is displayed:", isDisplayed);
|
|
32
|
-
if (isDisplayed) {
|
|
33
|
-
// Get the actual text from the element
|
|
34
|
-
const element = await $(elementSelector);
|
|
35
|
-
await element.doubleClick();
|
|
36
|
-
console.log("Element is double clicked successfully.");
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
}, { timeout: 30000 });
|
|
40
|
-
} catch (error) {
|
|
41
|
-
console.error("Element not found or not visible within 30 seconds");
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
async function clickByIdWithExecute(elementid) {
|
|
48
|
-
try {
|
|
49
|
-
await browser.execute(() => {
|
|
50
|
-
document.getElementById(elementid).click();
|
|
51
|
-
});
|
|
52
|
-
} catch (error) {
|
|
53
|
-
console.error("Failed to click on element with id:", elementid);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
module.exports = { clickIfVisible, clickByIdWithExecute ,doubleclick};
|