froth-webdriverio-framework 6.0.18 → 6.0.19
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/browsersatckSessionInfo.js +15 -6
- package/froth_api_calls/getexecutionDetails.js +123 -38
- package/froth_common_actions/Utils.js +38 -6
- package/froth_common_actions/alert.js +21 -6
- package/froth_common_actions/apicall.js +30 -14
- package/froth_common_actions/assert.js +26 -14
- package/froth_common_actions/captureNavigationTime.js +53 -0
- package/froth_common_actions/dropDown.js +18 -7
- package/froth_common_actions/emailParsing.js +161 -0
- package/froth_common_actions/jwt.js +12 -12
- package/froth_common_actions/logData.js +73 -0
- package/froth_common_actions/random.js +187 -29
- package/froth_common_actions/swicthWindowTab.js +36 -0
- package/froth_configs/commonconfig.js +160 -31
- package/froth_configs/setallDatailinBuffer.js +1 -1
- package/froth_configs/wdio.common.conf.js +73 -11
- package/package.json +4 -3
- package/workflows/pipeline.yml +0 -63
|
@@ -106,7 +106,7 @@ async function amend2Browserstack(annotationMessage, level) {
|
|
|
106
106
|
try {
|
|
107
107
|
|
|
108
108
|
console.log("Annotation message inside amend2Browserstack:" + annotationMessage)
|
|
109
|
-
if (process.env.PLATFORM === 'browserstack')
|
|
109
|
+
if (process.env.PLATFORM === 'browserstack')
|
|
110
110
|
await driver.execute('browserstack_executor: {"action": "annotate", "arguments": {"data":"' + annotationMessage + '","level": "' + level + '"}}');
|
|
111
111
|
|
|
112
112
|
} catch (error) {
|
|
@@ -115,13 +115,22 @@ async function amend2Browserstack(annotationMessage, level) {
|
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
//Execute the main function
|
|
119
118
|
|
|
120
|
-
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
// Execute the main function
|
|
122
|
+
|
|
123
|
+
// Main function to execute the API call
|
|
121
124
|
// async function main() {
|
|
122
125
|
// try {
|
|
123
|
-
//
|
|
124
|
-
//
|
|
126
|
+
// /// BUFFER.setItem("EXECUTION_SESSIONID","297666e2fd4195de98d7da3b359669072ff41a2a");
|
|
127
|
+
// const login=0.30;
|
|
128
|
+
// const landing=0.30;
|
|
129
|
+
// const home=0.30;
|
|
130
|
+
// const payment=0.30;
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
// await amend2Browserstack("\n Page load time for login page:"+login+"\n Page load time for landing page:"+landing+"\n Page load time for home page:"+home+"\n Page load time for payment page:"+payment, "info");
|
|
125
134
|
// } catch (error) {
|
|
126
135
|
// console.error('Error in main function:', error);
|
|
127
136
|
// }
|
|
@@ -131,6 +140,6 @@ async function amend2Browserstack(annotationMessage, level) {
|
|
|
131
140
|
module.exports = {
|
|
132
141
|
getBSSessionDetails,
|
|
133
142
|
getBSBuildDetails,
|
|
134
|
-
amend2Browserstack
|
|
143
|
+
amend2Browserstack,
|
|
135
144
|
};
|
|
136
145
|
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
async function getExecuitonDetails(frothUrl, token, id) {
|
|
6
6
|
let jsondata = {};
|
|
7
7
|
if (id != 0 || id != null || id != undefined) {
|
|
8
|
-
const url = `${frothUrl}/api/test-execution-retrieve/${id}
|
|
8
|
+
const url = `${frothUrl}/api/test-execution-retrieve/${id}/`;
|
|
9
9
|
|
|
10
10
|
try {
|
|
11
11
|
console.log("URL: " + url)
|
|
@@ -34,11 +34,9 @@ async function getExecuitonDetails(frothUrl, token, id) {
|
|
|
34
34
|
|
|
35
35
|
return jsondata;
|
|
36
36
|
} else if (response.status === 401) { // Unauthorized, token expired
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
// return getExecuitonDetails(frothUrl, newToken, id);
|
|
41
|
-
console.log("Unauthorized, token expired" + response.status)
|
|
37
|
+
|
|
38
|
+
console.error("Unauthorized, token expired" + response.status);
|
|
39
|
+
|
|
42
40
|
} else {
|
|
43
41
|
const errorText = await response.text();
|
|
44
42
|
console.error(`Data fetch failed response in getExecuitonDetails: ${response.status}`);
|
|
@@ -59,7 +57,7 @@ async function getExecuitonDetails(frothUrl, token, id) {
|
|
|
59
57
|
|
|
60
58
|
async function getExecuitonScriptDetails(frothUrl, token, execution_id, script_id, script_platform) {
|
|
61
59
|
let id;
|
|
62
|
-
console.log("script id is :" + script_id+" script platform is :"+script_platform+" execution id is :"+execution_id+" token is :"+token)
|
|
60
|
+
console.log("script id is :" + script_id + " script platform is :" + script_platform + " execution id is :" + execution_id + " token is :" + token)
|
|
63
61
|
const url = `${frothUrl}/api/execution-script-mapping/?execution_id=${execution_id}&automation_script_id=${script_id}&platform=${script_platform}`;
|
|
64
62
|
|
|
65
63
|
try {
|
|
@@ -84,10 +82,6 @@ async function getExecuitonScriptDetails(frothUrl, token, execution_id, script_i
|
|
|
84
82
|
} else if (response.status === 401) { // Unauthorized, token expired
|
|
85
83
|
console.log("Unauthorized, token expired" + response.status)
|
|
86
84
|
|
|
87
|
-
// Call login function to obtain a new token
|
|
88
|
-
// const newToken = await getLoginToken(BUFFER.getItem("SERVICE_USER"), BUFFER.getItem("SERVICE_PASSWORD")); // You need to implement the login function
|
|
89
|
-
// Retry the request with the new token
|
|
90
|
-
// return getExecuitonScriptDetails(frothUrl, newToken, execution_id, script_id);
|
|
91
85
|
} else {
|
|
92
86
|
const errorText = await response.text();
|
|
93
87
|
console.error(`Data fetch failed response in getExecuitonScriptDetails: ${response.status}`);
|
|
@@ -103,8 +97,7 @@ async function getExecuitonScriptDetails(frothUrl, token, execution_id, script_i
|
|
|
103
97
|
|
|
104
98
|
}
|
|
105
99
|
|
|
106
|
-
async function
|
|
107
|
-
// if (id != 0) {
|
|
100
|
+
async function update_CICDRUNID_ReportUrl(frothUrl, token, id) {
|
|
108
101
|
|
|
109
102
|
|
|
110
103
|
const url = `${frothUrl}/api/test-execution-update/${id}/`;
|
|
@@ -112,22 +105,17 @@ async function updateExecuitonDetails(frothUrl, token, id, resultdetails) {
|
|
|
112
105
|
try {
|
|
113
106
|
console.log("URL" + url)
|
|
114
107
|
|
|
115
|
-
|
|
116
|
-
formData.append('excution_status', resultdetails.excution_status);
|
|
117
|
-
}
|
|
118
|
-
if (resultdetails.excution_time != null) {
|
|
119
|
-
formData.append('excution_time', resultdetails.excution_time);
|
|
120
|
-
}
|
|
121
|
-
formData.append('id', BUFFER.getItem("FROTH_EXECUTION_ID"))
|
|
122
|
-
formData.append('report_url', BUFFER.getItem("REPORT_URL"))
|
|
108
|
+
// formData.append('id', BUFFER.getItem("FROTH_EXECUTION_ID"))
|
|
123
109
|
formData.append('updated_through_bot', true)
|
|
124
110
|
formData.append('run_id', process.env.CICD_RUN_ID)
|
|
125
|
-
if (resultdetails.comments != null)
|
|
126
|
-
formData.append('comments', JSON.stringify(resultdetails.comments))
|
|
127
|
-
|
|
128
|
-
console.log("Report URL:" + BUFFER.getItem("REPORT_URL"))
|
|
129
111
|
|
|
130
112
|
|
|
113
|
+
if (BUFFER.getItem("REPORT_URL") === null)
|
|
114
|
+
console.log("Report URL is null")
|
|
115
|
+
else {
|
|
116
|
+
console.log("Report URL:" + BUFFER.getItem("REPORT_URL"))
|
|
117
|
+
formData.append('report_url', BUFFER.getItem("REPORT_URL"))
|
|
118
|
+
}
|
|
131
119
|
|
|
132
120
|
const response = await fetch(url, {
|
|
133
121
|
method: 'PUT',
|
|
@@ -140,33 +128,130 @@ async function updateExecuitonDetails(frothUrl, token, id, resultdetails) {
|
|
|
140
128
|
|
|
141
129
|
if (response.ok) {
|
|
142
130
|
const data = await response.json();
|
|
143
|
-
// console.log("data is :"+data)
|
|
144
|
-
|
|
145
131
|
} else if (response.status === 401) { // Unauthorized, token expired
|
|
146
|
-
// Call login function to obtain a new token
|
|
147
|
-
// const newToken = await getLoginToken(BUFFER.getItem("SERVICE_USER"), BUFFER.getItem("SERVICE_PASSWORD")); // You need to implement the login function
|
|
148
|
-
// // Retry the request with the new token
|
|
149
|
-
// return updateExecuitonDetails(frothUrl, newToken, id, resultdetails);
|
|
150
132
|
console.log("Unauthorized, token expired" + response.status)
|
|
151
|
-
|
|
152
133
|
} else {
|
|
153
134
|
const errorText = await response.text();
|
|
154
135
|
console.error(`error in updating the status into DB ${response.status}`);
|
|
155
|
-
// throw new Error(`HTTP error! status: ${response.status}`);
|
|
156
136
|
}
|
|
157
137
|
|
|
138
|
+
} catch (error) {
|
|
139
|
+
console.error('Error fetching data:', error);
|
|
140
|
+
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
async function updateExecuitonDetails(frothUrl, token, id, resultdetails) {
|
|
147
|
+
try {
|
|
148
|
+
console.log("in update execution details UPDATE_EXECUTION: " + BUFFER.getItem("UPDATE_EXECUTION"))
|
|
149
|
+
if (BUFFER.getItem("FROTH_UPDATE_EXECUTION") === 'TRUE') {
|
|
150
|
+
console.log("Execution already updated.")
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
const url = `${frothUrl}/api/test-execution-update/${id}/`;
|
|
154
|
+
const formData = new FormData();
|
|
155
|
+
|
|
156
|
+
console.log("URL" + url)
|
|
157
|
+
console.log("Execution details :" + resultdetails.excution_status + " == " + resultdetails.excution_time + " == " + resultdetails.comments)
|
|
158
|
+
formData.append('updated_through_bot', true)
|
|
159
|
+
|
|
160
|
+
if (resultdetails.excution_status === null) {
|
|
161
|
+
console.log("Execution status is null")
|
|
162
|
+
} else
|
|
163
|
+
formData.append('excution_status', resultdetails.excution_status);
|
|
164
|
+
|
|
165
|
+
if (resultdetails.excution_time === null || resultdetails.excution_time === "NaN:NaN:NaN") {
|
|
166
|
+
console.log("Execution time is null")
|
|
167
|
+
} else
|
|
168
|
+
formData.append('excution_time', resultdetails.excution_time);
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
if (resultdetails.comments === null)
|
|
172
|
+
console.log("Comments is null")
|
|
173
|
+
else if (resultdetails.comments.length === 0)
|
|
174
|
+
console.log("Comments is empty")
|
|
175
|
+
else
|
|
176
|
+
formData.append('comments', resultdetails.comments.join('<br>'))
|
|
177
|
+
|
|
178
|
+
// formData.append('comments', JSON.stringify(resultdetails.comments))
|
|
158
179
|
|
|
180
|
+
const response = await fetch(url, {
|
|
181
|
+
method: 'PUT',
|
|
182
|
+
headers: {
|
|
183
|
+
'Authorization': `Bearer ${token}`
|
|
184
|
+
},
|
|
185
|
+
body: formData
|
|
186
|
+
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
if (response.ok) {
|
|
190
|
+
const data = await response.json();
|
|
191
|
+
BUFFER.setItem("FROTH_UPDATE_EXECUTION", 'TRUE')
|
|
192
|
+
} else if (response.status === 401) { // Unauthorized, token expired
|
|
193
|
+
console.log("Unauthorized, token expired" + response.status)
|
|
194
|
+
} else {
|
|
195
|
+
const errorText = await response.text();
|
|
196
|
+
console.error(`error in updating the status into DB ${response.status}`);
|
|
197
|
+
// throw new Error(`HTTP error! status: ${response.status}`);
|
|
198
|
+
}
|
|
159
199
|
|
|
200
|
+
|
|
201
|
+
}
|
|
160
202
|
} catch (error) {
|
|
161
|
-
console.error('Error
|
|
203
|
+
console.error('Error in updateExecuitonDetails :', error);
|
|
162
204
|
|
|
163
205
|
}
|
|
164
|
-
// } else {
|
|
165
|
-
// console.error('Error fetching data: Invalid ID');
|
|
166
|
-
// }
|
|
167
206
|
|
|
168
207
|
}
|
|
169
208
|
|
|
209
|
+
|
|
210
|
+
async function updateScriptExecutionStatus(frothUrl, token, scriptid, script_platform, status) {
|
|
211
|
+
|
|
212
|
+
if (scriptid != 0) {
|
|
213
|
+
try {
|
|
214
|
+
console.log("script platform is " + script_platform)
|
|
215
|
+
const id = await getExecuitonScriptDetails(frothUrl, token, BUFFER.getItem("FROTH_EXECUTION_ID"), scriptid, script_platform)
|
|
216
|
+
console.log("ID is :" + id)
|
|
217
|
+
const url = `${frothUrl}/api/script-status-percentage/${id}/`;
|
|
218
|
+
const formData = new FormData();
|
|
219
|
+
|
|
220
|
+
console.log("URL" + url)
|
|
221
|
+
// formData.append('execution_id', BUFFER.getItem("EXECUTION_ID"))
|
|
222
|
+
formData.append('script_status', status)
|
|
223
|
+
formData.append('updated_through_bot', true)
|
|
224
|
+
|
|
225
|
+
const response = await fetch(url, {
|
|
226
|
+
method: 'PUT',
|
|
227
|
+
headers: {
|
|
228
|
+
'Authorization': `Bearer ${token}`
|
|
229
|
+
},
|
|
230
|
+
body: formData
|
|
231
|
+
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
if (response.ok) {
|
|
235
|
+
const data = await response.json();
|
|
236
|
+
// console.log("data is :"+data)
|
|
237
|
+
|
|
238
|
+
} else if (response.status === 401) { // Unauthorized, token expired
|
|
239
|
+
|
|
240
|
+
console.log("Unauthorized, token expired" + response.status)
|
|
241
|
+
|
|
242
|
+
} else {
|
|
243
|
+
const errorText = await response.text();
|
|
244
|
+
console.error(`error in updating the status into DB ${response.status}`);
|
|
245
|
+
}
|
|
246
|
+
} catch (error) {
|
|
247
|
+
console.error('Error updating data for script status:', error);
|
|
248
|
+
|
|
249
|
+
}
|
|
250
|
+
} else {
|
|
251
|
+
console.error('Else: Error updating data for script status: Invalid ID');
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
}
|
|
170
255
|
async function updateScriptExecutionStatus(frothUrl, token, scriptid, script_platform, status) {
|
|
171
256
|
|
|
172
257
|
if (scriptid != 0) {
|
|
@@ -249,5 +334,5 @@ async function updateScriptExecutionStatus(frothUrl, token, scriptid, script_pla
|
|
|
249
334
|
// }
|
|
250
335
|
|
|
251
336
|
// main();
|
|
252
|
-
module.exports = { getExecuitonDetails, updateExecuitonDetails, updateScriptExecutionStatus };
|
|
337
|
+
module.exports = { getExecuitonDetails, updateExecuitonDetails, updateScriptExecutionStatus, update_CICDRUNID_ReportUrl };
|
|
253
338
|
|
|
@@ -20,6 +20,8 @@ let clickIfVisible = null;
|
|
|
20
20
|
let doubleClick = null;
|
|
21
21
|
|
|
22
22
|
let assertText = null;
|
|
23
|
+
|
|
24
|
+
let random = null;
|
|
23
25
|
let randomtext = null;
|
|
24
26
|
let randomnumber = null;
|
|
25
27
|
let randomfloat = null;
|
|
@@ -27,6 +29,8 @@ let randomint = null;
|
|
|
27
29
|
let randomalphanum = null;
|
|
28
30
|
let randomdecimal = null;
|
|
29
31
|
let randomregex = null;
|
|
32
|
+
let randomdate = null;
|
|
33
|
+
|
|
30
34
|
let storetext = null;
|
|
31
35
|
let storevalue = null;
|
|
32
36
|
let storeattributevalue = null;
|
|
@@ -37,13 +41,23 @@ let scrollIntoView = null;
|
|
|
37
41
|
let api = null;
|
|
38
42
|
|
|
39
43
|
let selectDropDownValue = null;
|
|
44
|
+
let selectDropDownText = null;
|
|
40
45
|
|
|
41
46
|
let acceptAlert = null;
|
|
42
47
|
let dismissAlert = null;
|
|
43
48
|
|
|
44
|
-
let generateJWT=null;
|
|
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;
|
|
45
57
|
|
|
46
|
-
|
|
58
|
+
let extractEmailLinks = null;
|
|
59
|
+
|
|
60
|
+
if (process.env.LOCATION == null || process.env.LOCATION == 'local') {
|
|
47
61
|
basepath = ".";
|
|
48
62
|
} else {
|
|
49
63
|
basepath = "froth-webdriverio-framework/froth_common_actions";
|
|
@@ -57,18 +71,19 @@ scrollDownToView = require(basepath + '/scroll').scrollDownToView;
|
|
|
57
71
|
scrollRightToView = require(basepath + '/scroll').scrollRightToView;
|
|
58
72
|
scrollIntoView = require(basepath + '/scroll').scrollIntoView;
|
|
59
73
|
scrollUpUntilVisible = require(basepath + '/scroll').scrollupUntilVisible;
|
|
60
|
-
|
|
74
|
+
switchToWindowByTitle = require(basepath + '/swicthWindowTab').switch2WindowByTitle;
|
|
75
|
+
switchToWindowByIndex = require(basepath + '/swicthWindowTab').switch2WindowByIndex;
|
|
61
76
|
|
|
62
77
|
swipeDown = require(basepath + '/swipe').swipedown;
|
|
63
78
|
swipeLeft = require(basepath + '/swipe').swipeleft;
|
|
64
79
|
swipeRight = require(basepath + '/swipe').swiperight;
|
|
65
80
|
swipeUp = require(basepath + '/swipe').swipeup;
|
|
66
|
-
swipetoFit= require(basepath + '/swipe').swipetofit;
|
|
81
|
+
swipetoFit = require(basepath + '/swipe').swipetofit;
|
|
67
82
|
swipeWithCoordinates = require(basepath + '/swipe').swipewithcoordinates;
|
|
68
83
|
|
|
69
84
|
clickIfVisible = require(basepath + "/click").clickIfVisible;
|
|
70
85
|
clickByIdWithExecute = require(basepath + "/click").clickByIdWithExecute;
|
|
71
|
-
doubleClick= require(basepath + "/click").doubleclick;
|
|
86
|
+
doubleClick = require(basepath + "/click").doubleclick;
|
|
72
87
|
|
|
73
88
|
assertText = require(basepath + '/assert').assertText;
|
|
74
89
|
assertAttributeValue = require(basepath + '/assert').assertAttributeValue;
|
|
@@ -80,6 +95,8 @@ randomint = require(basepath + '/random').RNDINT;
|
|
|
80
95
|
randomalphanum = require(basepath + '/random').RNDALPHANUM;
|
|
81
96
|
randomdecimal = require(basepath + '/random').RNDDECIMAL;
|
|
82
97
|
randomregex = require(basepath + '/random').RNDREGEX;
|
|
98
|
+
random = require(basepath + '/random').RANDOM;
|
|
99
|
+
randomdate = require(basepath + '/random').RNDDATE;
|
|
83
100
|
|
|
84
101
|
storetext = require(basepath + '/storeToBuffer').STORETEXT;
|
|
85
102
|
storevalue = require(basepath + '/storeToBuffer').STOREVALUE;
|
|
@@ -89,12 +106,18 @@ api = require(basepath + '/apicall').callapi;
|
|
|
89
106
|
validate = require(basepath + '/apicall').validate;
|
|
90
107
|
|
|
91
108
|
selectDropDownValue = require(basepath + '/dropDown').select4mDropDownValue;
|
|
109
|
+
selectDropDownText= require(basepath + '/dropDown').select4mDropDownText;
|
|
92
110
|
|
|
93
111
|
acceptAlert = require(basepath + '/alert.js').acceptalert;
|
|
94
112
|
dismissAlert = require(basepath + '/alert.js').dismissalert;
|
|
95
113
|
|
|
96
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;
|
|
97
119
|
|
|
120
|
+
extractEmailLinks = require(basepath + '/emailParsing');
|
|
98
121
|
//export the variabels
|
|
99
122
|
module.exports = {
|
|
100
123
|
scrollToEnd,
|
|
@@ -108,6 +131,7 @@ module.exports = {
|
|
|
108
131
|
doubleClick,
|
|
109
132
|
assertText,
|
|
110
133
|
assertAttributeValue,
|
|
134
|
+
random,
|
|
111
135
|
randomtext,
|
|
112
136
|
randomnumber,
|
|
113
137
|
randomfloat,
|
|
@@ -115,6 +139,7 @@ module.exports = {
|
|
|
115
139
|
randomalphanum,
|
|
116
140
|
randomdecimal,
|
|
117
141
|
randomregex,
|
|
142
|
+
randomdate,
|
|
118
143
|
storetext,
|
|
119
144
|
storevalue,
|
|
120
145
|
storeattributevalue,
|
|
@@ -123,6 +148,7 @@ module.exports = {
|
|
|
123
148
|
api,
|
|
124
149
|
validate,
|
|
125
150
|
selectDropDownValue,
|
|
151
|
+
selectDropDownText,
|
|
126
152
|
acceptAlert,
|
|
127
153
|
dismissAlert,
|
|
128
154
|
swipeLeft,
|
|
@@ -131,5 +157,11 @@ module.exports = {
|
|
|
131
157
|
swipeUp,
|
|
132
158
|
swipetoFit,
|
|
133
159
|
swipeWithCoordinates,
|
|
134
|
-
generateJWT
|
|
160
|
+
generateJWT,
|
|
161
|
+
switchToWindowByTitle,
|
|
162
|
+
switchToWindowByIndex,
|
|
163
|
+
captureLoadNavigation,
|
|
164
|
+
amendBrowserStackLog,
|
|
165
|
+
logJsonDataToTable,
|
|
166
|
+
extractEmailLinks
|
|
135
167
|
};
|
|
@@ -1,13 +1,26 @@
|
|
|
1
1
|
async function acceptalert() {
|
|
2
2
|
|
|
3
3
|
try {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
+
// });
|
|
10
22
|
await browser.acceptAlert();
|
|
23
|
+
|
|
11
24
|
} catch (e) {
|
|
12
25
|
console.log("error occured while accepting alert", e)
|
|
13
26
|
}
|
|
@@ -31,4 +44,6 @@ async function dismissalert() {
|
|
|
31
44
|
|
|
32
45
|
}
|
|
33
46
|
|
|
47
|
+
|
|
48
|
+
|
|
34
49
|
module.exports = { acceptalert, dismissalert };
|
|
@@ -4,10 +4,10 @@ const amendToBrowserstack = require("../froth_api_calls/browsersatckSessionInfo"
|
|
|
4
4
|
|
|
5
5
|
async function callapi(methodtype, api_url, queryParams, payloaddetails, body_type, authentication, headersdetails, attachments) {
|
|
6
6
|
let response;
|
|
7
|
-
if (queryParams && Object.keys(queryParams).length > 0) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
7
|
+
// if (queryParams && Object.keys(queryParams).length > 0) {
|
|
8
|
+
// const queryString = new URLSearchParams(queryParams).toString();
|
|
9
|
+
// api_url += `?${queryString}`;
|
|
10
|
+
// }
|
|
11
11
|
console.log("Final API URL:", api_url);
|
|
12
12
|
|
|
13
13
|
|
|
@@ -34,15 +34,33 @@ async function callapi(methodtype, api_url, queryParams, payloaddetails, body_ty
|
|
|
34
34
|
console.log("No body sent (body_type not provided or empty payload).");
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
|
|
38
38
|
console.warn("Warning: GET request with a body is non-standard and may not work with all APIs.");
|
|
39
|
-
|
|
39
|
+
const config = {
|
|
40
40
|
method: method,
|
|
41
41
|
url: api_url,
|
|
42
|
-
headers: headers
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|
+
|
|
46
64
|
|
|
47
65
|
console.log("Response Data:", response.data);
|
|
48
66
|
|
|
@@ -114,7 +132,7 @@ async function validate(attribute_name, attribute, actionname, buffer, buffernam
|
|
|
114
132
|
} else if (actionname.toLowerCase() == "getbuffer") {
|
|
115
133
|
let annotationMessage = `The vlaue has been retrived from the buffer : ${buffername_value}.`;
|
|
116
134
|
await amendToBrowserstack(annotationMessage, "info");
|
|
117
|
-
return BUFFER.getItem(buffername_value);
|
|
135
|
+
return await BUFFER.getItem(buffername_value);
|
|
118
136
|
|
|
119
137
|
}
|
|
120
138
|
// } catch (e) {
|
|
@@ -135,9 +153,7 @@ async function validateAttributeData(attribute_name, attribute, buffer, bufferna
|
|
|
135
153
|
valueToVerify = Number(valueToVerify);
|
|
136
154
|
} else if (datatype.toLowerCase() == "boolean") {
|
|
137
155
|
valueToVerify = Boolean(valueToVerify);
|
|
138
|
-
} else if (datatype.toLowerCase() == "
|
|
139
|
-
valueToVerify = parseFloat(valueToVerify);
|
|
140
|
-
} else if (datatype.toLowerCase() == "double") {
|
|
156
|
+
} else if (datatype.toLowerCase() == "decimal") {
|
|
141
157
|
valueToVerify = parseFloat(valueToVerify);
|
|
142
158
|
} else if (datatype.toLowerCase() == "string") {
|
|
143
159
|
valueToVerify = valueToVerify.toString();
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
// Function to verify text in Android app
|
|
2
|
+
import assert from 'assert';
|
|
3
|
+
const amendToBrowserstack = require("../froth_api_calls/browsersatckSessionInfo").amend2Browserstack;
|
|
2
4
|
|
|
3
5
|
async function assertText(elementSelector, expectedText) {
|
|
4
6
|
|
|
@@ -6,18 +8,19 @@ async function assertText(elementSelector, expectedText) {
|
|
|
6
8
|
console.log("inside the assert text function" + elementSelector)
|
|
7
9
|
try {
|
|
8
10
|
let element = await $(elementSelector)
|
|
9
|
-
let assertionStatus = false; // Initialize status
|
|
10
11
|
try {
|
|
11
12
|
await expect(element).toHaveText(expectedText);
|
|
12
|
-
assertionStatus = true; // If assertion passes, set status to true
|
|
13
13
|
console.log("Assertion succeeded.");
|
|
14
14
|
actualText = await element.getText();
|
|
15
15
|
let annotationMessage = `Assertion passed. Actual text: ${actualText}, Expected text: ${expectedText}.`;
|
|
16
16
|
await amendToBrowserstack(annotationMessage, "info");
|
|
17
17
|
} catch (error) {
|
|
18
|
-
console.log(`Assertion failed. Expected text:
|
|
19
|
-
let annotationMessage = `Assertion failed. Expected text:
|
|
18
|
+
console.log(`Assertion failed. Expected text: ${expectedText}.`);
|
|
19
|
+
let annotationMessage = `Assertion failed. Expected text: ${expectedText}.`;
|
|
20
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}`);
|
|
21
24
|
}
|
|
22
25
|
|
|
23
26
|
|
|
@@ -25,6 +28,9 @@ async function assertText(elementSelector, expectedText) {
|
|
|
25
28
|
console.error('Error occurred while verifying text:', error);
|
|
26
29
|
let annotationMessage = `Error occurred while verifying text: ${error.message}.`;
|
|
27
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}`);
|
|
28
34
|
// throw error;
|
|
29
35
|
}
|
|
30
36
|
|
|
@@ -37,7 +43,6 @@ async function assertAttributeValue(elementSelector, attributeName, expectedText
|
|
|
37
43
|
console.log("inside the assertAttributeValue function" + elementSelector)
|
|
38
44
|
try {
|
|
39
45
|
let element = await $(elementSelector)
|
|
40
|
-
let assertionStatus = false; // Initialize status
|
|
41
46
|
try {
|
|
42
47
|
await expect(element).toHaveAttribute(attributeName, expectedText);
|
|
43
48
|
let actualText;
|
|
@@ -47,27 +52,34 @@ async function assertAttributeValue(elementSelector, attributeName, expectedText
|
|
|
47
52
|
await amendToBrowserstack(annotationMessage, "info");
|
|
48
53
|
} catch (error) {
|
|
49
54
|
console.warn("Assertion failed:", error.message);
|
|
50
|
-
let annotationMessage = `Assertion failed. Expected text:
|
|
55
|
+
let annotationMessage = `Assertion failed. Expected text: ${expectedText}. ,${error.message}`;
|
|
51
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}`);
|
|
52
61
|
}
|
|
53
62
|
} catch (error) {
|
|
54
63
|
console.error('Error occurred while verifying text:', error);
|
|
55
64
|
let annotationMessage = `Error occurred while asserting Attribute: ${error.message}.`;
|
|
56
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}`);
|
|
57
69
|
}
|
|
58
70
|
|
|
59
71
|
|
|
60
72
|
}
|
|
61
73
|
|
|
62
|
-
async function amendToBrowserstack(annotationMessage, level) {
|
|
63
|
-
|
|
64
|
-
|
|
74
|
+
// async function amendToBrowserstack(annotationMessage, level) {
|
|
75
|
+
// try {
|
|
76
|
+
// await driver.execute('browserstack_executor: {"action": "annotate", "arguments": {"data":"' + annotationMessage + '","level": "' + level + '"}}');
|
|
65
77
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
78
|
+
// } catch (error) {
|
|
79
|
+
// console.error('Error occurred while annoting into BS', error);
|
|
80
|
+
// throw error;
|
|
81
|
+
// }
|
|
82
|
+
// }
|
|
71
83
|
module.exports = { assertText, assertAttributeValue };
|
|
72
84
|
|
|
73
85
|
|
|
@@ -0,0 +1,53 @@
|
|
|
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
|
+
|