froth-webdriverio-framework 6.0.17 → 6.0.18
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 +6 -15
- package/froth_api_calls/getexecutionDetails.js +38 -123
- package/froth_common_actions/Utils.js +6 -38
- package/froth_common_actions/alert.js +6 -21
- package/froth_common_actions/apicall.js +14 -30
- package/froth_common_actions/assert.js +14 -26
- package/froth_common_actions/dropDown.js +7 -18
- package/froth_common_actions/jwt.js +12 -12
- package/froth_common_actions/random.js +29 -187
- package/froth_configs/commonconfig.js +33 -182
- package/froth_configs/setallDatailinBuffer.js +1 -1
- package/froth_configs/wdio.common.conf.js +21 -151
- package/package.json +3 -4
- package/workflows/pipeline.yml +63 -0
- package/froth_common_actions/captureNavigationTime.js +0 -53
- package/froth_common_actions/emailParsing.js +0 -161
- package/froth_common_actions/logData.js +0 -73
- package/froth_common_actions/swicthWindowTab.js +0 -36
|
@@ -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,22 +115,13 @@ async function amend2Browserstack(annotationMessage, level) {
|
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
+
//Execute the main function
|
|
118
119
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
// Execute the main function
|
|
122
|
-
|
|
123
|
-
// Main function to execute the API call
|
|
120
|
+
//Main function to execute the API call
|
|
124
121
|
// async function main() {
|
|
125
122
|
// try {
|
|
126
|
-
//
|
|
127
|
-
//
|
|
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");
|
|
123
|
+
// BUFFER.setItem("EXECUTION_SESSIONID","297666e2fd4195de98d7da3b359669072ff41a2a");
|
|
124
|
+
// await getBrowserstackDetails();
|
|
134
125
|
// } catch (error) {
|
|
135
126
|
// console.error('Error in main function:', error);
|
|
136
127
|
// }
|
|
@@ -140,6 +131,6 @@ async function amend2Browserstack(annotationMessage, level) {
|
|
|
140
131
|
module.exports = {
|
|
141
132
|
getBSSessionDetails,
|
|
142
133
|
getBSBuildDetails,
|
|
143
|
-
amend2Browserstack
|
|
134
|
+
amend2Browserstack
|
|
144
135
|
};
|
|
145
136
|
|
|
@@ -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,9 +34,11 @@ 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
|
-
|
|
37
|
+
// Call login function to obtain a new token
|
|
38
|
+
// const newToken = await getLoginToken(BUFFER.getItem("SERVICE_USER"), BUFFER.getItem("SERVICE_PASSWORD")); // You need to implement the login function
|
|
39
|
+
// Retry the request with the new token
|
|
40
|
+
// return getExecuitonDetails(frothUrl, newToken, id);
|
|
41
|
+
console.log("Unauthorized, token expired" + response.status)
|
|
40
42
|
} else {
|
|
41
43
|
const errorText = await response.text();
|
|
42
44
|
console.error(`Data fetch failed response in getExecuitonDetails: ${response.status}`);
|
|
@@ -57,7 +59,7 @@ async function getExecuitonDetails(frothUrl, token, id) {
|
|
|
57
59
|
|
|
58
60
|
async function getExecuitonScriptDetails(frothUrl, token, execution_id, script_id, script_platform) {
|
|
59
61
|
let id;
|
|
60
|
-
console.log("script id is :" + script_id
|
|
62
|
+
console.log("script id is :" + script_id+" script platform is :"+script_platform+" execution id is :"+execution_id+" token is :"+token)
|
|
61
63
|
const url = `${frothUrl}/api/execution-script-mapping/?execution_id=${execution_id}&automation_script_id=${script_id}&platform=${script_platform}`;
|
|
62
64
|
|
|
63
65
|
try {
|
|
@@ -82,6 +84,10 @@ async function getExecuitonScriptDetails(frothUrl, token, execution_id, script_i
|
|
|
82
84
|
} else if (response.status === 401) { // Unauthorized, token expired
|
|
83
85
|
console.log("Unauthorized, token expired" + response.status)
|
|
84
86
|
|
|
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);
|
|
85
91
|
} else {
|
|
86
92
|
const errorText = await response.text();
|
|
87
93
|
console.error(`Data fetch failed response in getExecuitonScriptDetails: ${response.status}`);
|
|
@@ -97,7 +103,8 @@ async function getExecuitonScriptDetails(frothUrl, token, execution_id, script_i
|
|
|
97
103
|
|
|
98
104
|
}
|
|
99
105
|
|
|
100
|
-
async function
|
|
106
|
+
async function updateExecuitonDetails(frothUrl, token, id, resultdetails) {
|
|
107
|
+
// if (id != 0) {
|
|
101
108
|
|
|
102
109
|
|
|
103
110
|
const url = `${frothUrl}/api/test-execution-update/${id}/`;
|
|
@@ -105,17 +112,22 @@ async function update_CICDRUNID_ReportUrl(frothUrl, token, id) {
|
|
|
105
112
|
try {
|
|
106
113
|
console.log("URL" + url)
|
|
107
114
|
|
|
108
|
-
|
|
115
|
+
if (resultdetails.excution_status != null) {
|
|
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"))
|
|
109
123
|
formData.append('updated_through_bot', true)
|
|
110
124
|
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"))
|
|
111
129
|
|
|
112
130
|
|
|
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
|
-
}
|
|
119
131
|
|
|
120
132
|
const response = await fetch(url, {
|
|
121
133
|
method: 'PUT',
|
|
@@ -128,130 +140,33 @@ async function update_CICDRUNID_ReportUrl(frothUrl, token, id) {
|
|
|
128
140
|
|
|
129
141
|
if (response.ok) {
|
|
130
142
|
const data = await response.json();
|
|
143
|
+
// console.log("data is :"+data)
|
|
144
|
+
|
|
131
145
|
} 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);
|
|
132
150
|
console.log("Unauthorized, token expired" + response.status)
|
|
151
|
+
|
|
133
152
|
} else {
|
|
134
153
|
const errorText = await response.text();
|
|
135
154
|
console.error(`error in updating the status into DB ${response.status}`);
|
|
155
|
+
// throw new Error(`HTTP error! status: ${response.status}`);
|
|
136
156
|
}
|
|
137
157
|
|
|
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))
|
|
179
158
|
|
|
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
|
-
}
|
|
199
159
|
|
|
200
|
-
|
|
201
|
-
}
|
|
202
160
|
} catch (error) {
|
|
203
|
-
console.error('Error
|
|
161
|
+
console.error('Error fetching data:', error);
|
|
204
162
|
|
|
205
163
|
}
|
|
164
|
+
// } else {
|
|
165
|
+
// console.error('Error fetching data: Invalid ID');
|
|
166
|
+
// }
|
|
206
167
|
|
|
207
168
|
}
|
|
208
169
|
|
|
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
|
-
}
|
|
255
170
|
async function updateScriptExecutionStatus(frothUrl, token, scriptid, script_platform, status) {
|
|
256
171
|
|
|
257
172
|
if (scriptid != 0) {
|
|
@@ -334,5 +249,5 @@ async function updateScriptExecutionStatus(frothUrl, token, scriptid, script_pla
|
|
|
334
249
|
// }
|
|
335
250
|
|
|
336
251
|
// main();
|
|
337
|
-
module.exports = { getExecuitonDetails, updateExecuitonDetails, updateScriptExecutionStatus
|
|
252
|
+
module.exports = { getExecuitonDetails, updateExecuitonDetails, updateScriptExecutionStatus };
|
|
338
253
|
|
|
@@ -20,8 +20,6 @@ let clickIfVisible = null;
|
|
|
20
20
|
let doubleClick = null;
|
|
21
21
|
|
|
22
22
|
let assertText = null;
|
|
23
|
-
|
|
24
|
-
let random = null;
|
|
25
23
|
let randomtext = null;
|
|
26
24
|
let randomnumber = null;
|
|
27
25
|
let randomfloat = null;
|
|
@@ -29,8 +27,6 @@ let randomint = null;
|
|
|
29
27
|
let randomalphanum = null;
|
|
30
28
|
let randomdecimal = null;
|
|
31
29
|
let randomregex = null;
|
|
32
|
-
let randomdate = null;
|
|
33
|
-
|
|
34
30
|
let storetext = null;
|
|
35
31
|
let storevalue = null;
|
|
36
32
|
let storeattributevalue = null;
|
|
@@ -41,23 +37,13 @@ let scrollIntoView = null;
|
|
|
41
37
|
let api = null;
|
|
42
38
|
|
|
43
39
|
let selectDropDownValue = null;
|
|
44
|
-
let selectDropDownText = null;
|
|
45
40
|
|
|
46
41
|
let acceptAlert = null;
|
|
47
42
|
let dismissAlert = null;
|
|
48
43
|
|
|
49
|
-
let generateJWT
|
|
50
|
-
|
|
51
|
-
let switchToWindowByTitle = null;
|
|
52
|
-
let switchToWindowByIndex = null;
|
|
53
|
-
|
|
54
|
-
let captureLoadNavigation = null;
|
|
55
|
-
let amendBrowserStackLog = null;
|
|
56
|
-
let logJsonDataToTable = null;
|
|
44
|
+
let generateJWT=null;
|
|
57
45
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
if (process.env.LOCATION == null || process.env.LOCATION == 'local') {
|
|
46
|
+
if (process.env.LOCATION ==null || process.env.LOCATION == 'local') {
|
|
61
47
|
basepath = ".";
|
|
62
48
|
} else {
|
|
63
49
|
basepath = "froth-webdriverio-framework/froth_common_actions";
|
|
@@ -71,19 +57,18 @@ scrollDownToView = require(basepath + '/scroll').scrollDownToView;
|
|
|
71
57
|
scrollRightToView = require(basepath + '/scroll').scrollRightToView;
|
|
72
58
|
scrollIntoView = require(basepath + '/scroll').scrollIntoView;
|
|
73
59
|
scrollUpUntilVisible = require(basepath + '/scroll').scrollupUntilVisible;
|
|
74
|
-
|
|
75
|
-
switchToWindowByIndex = require(basepath + '/swicthWindowTab').switch2WindowByIndex;
|
|
60
|
+
|
|
76
61
|
|
|
77
62
|
swipeDown = require(basepath + '/swipe').swipedown;
|
|
78
63
|
swipeLeft = require(basepath + '/swipe').swipeleft;
|
|
79
64
|
swipeRight = require(basepath + '/swipe').swiperight;
|
|
80
65
|
swipeUp = require(basepath + '/swipe').swipeup;
|
|
81
|
-
swipetoFit
|
|
66
|
+
swipetoFit= require(basepath + '/swipe').swipetofit;
|
|
82
67
|
swipeWithCoordinates = require(basepath + '/swipe').swipewithcoordinates;
|
|
83
68
|
|
|
84
69
|
clickIfVisible = require(basepath + "/click").clickIfVisible;
|
|
85
70
|
clickByIdWithExecute = require(basepath + "/click").clickByIdWithExecute;
|
|
86
|
-
doubleClick
|
|
71
|
+
doubleClick= require(basepath + "/click").doubleclick;
|
|
87
72
|
|
|
88
73
|
assertText = require(basepath + '/assert').assertText;
|
|
89
74
|
assertAttributeValue = require(basepath + '/assert').assertAttributeValue;
|
|
@@ -95,8 +80,6 @@ randomint = require(basepath + '/random').RNDINT;
|
|
|
95
80
|
randomalphanum = require(basepath + '/random').RNDALPHANUM;
|
|
96
81
|
randomdecimal = require(basepath + '/random').RNDDECIMAL;
|
|
97
82
|
randomregex = require(basepath + '/random').RNDREGEX;
|
|
98
|
-
random = require(basepath + '/random').RANDOM;
|
|
99
|
-
randomdate = require(basepath + '/random').RNDDATE;
|
|
100
83
|
|
|
101
84
|
storetext = require(basepath + '/storeToBuffer').STORETEXT;
|
|
102
85
|
storevalue = require(basepath + '/storeToBuffer').STOREVALUE;
|
|
@@ -106,18 +89,12 @@ api = require(basepath + '/apicall').callapi;
|
|
|
106
89
|
validate = require(basepath + '/apicall').validate;
|
|
107
90
|
|
|
108
91
|
selectDropDownValue = require(basepath + '/dropDown').select4mDropDownValue;
|
|
109
|
-
selectDropDownText= require(basepath + '/dropDown').select4mDropDownText;
|
|
110
92
|
|
|
111
93
|
acceptAlert = require(basepath + '/alert.js').acceptalert;
|
|
112
94
|
dismissAlert = require(basepath + '/alert.js').dismissalert;
|
|
113
95
|
|
|
114
96
|
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
97
|
|
|
120
|
-
extractEmailLinks = require(basepath + '/emailParsing');
|
|
121
98
|
//export the variabels
|
|
122
99
|
module.exports = {
|
|
123
100
|
scrollToEnd,
|
|
@@ -131,7 +108,6 @@ module.exports = {
|
|
|
131
108
|
doubleClick,
|
|
132
109
|
assertText,
|
|
133
110
|
assertAttributeValue,
|
|
134
|
-
random,
|
|
135
111
|
randomtext,
|
|
136
112
|
randomnumber,
|
|
137
113
|
randomfloat,
|
|
@@ -139,7 +115,6 @@ module.exports = {
|
|
|
139
115
|
randomalphanum,
|
|
140
116
|
randomdecimal,
|
|
141
117
|
randomregex,
|
|
142
|
-
randomdate,
|
|
143
118
|
storetext,
|
|
144
119
|
storevalue,
|
|
145
120
|
storeattributevalue,
|
|
@@ -148,7 +123,6 @@ module.exports = {
|
|
|
148
123
|
api,
|
|
149
124
|
validate,
|
|
150
125
|
selectDropDownValue,
|
|
151
|
-
selectDropDownText,
|
|
152
126
|
acceptAlert,
|
|
153
127
|
dismissAlert,
|
|
154
128
|
swipeLeft,
|
|
@@ -157,11 +131,5 @@ module.exports = {
|
|
|
157
131
|
swipeUp,
|
|
158
132
|
swipetoFit,
|
|
159
133
|
swipeWithCoordinates,
|
|
160
|
-
generateJWT
|
|
161
|
-
switchToWindowByTitle,
|
|
162
|
-
switchToWindowByIndex,
|
|
163
|
-
captureLoadNavigation,
|
|
164
|
-
amendBrowserStackLog,
|
|
165
|
-
logJsonDataToTable,
|
|
166
|
-
extractEmailLinks
|
|
134
|
+
generateJWT
|
|
167
135
|
};
|
|
@@ -1,26 +1,13 @@
|
|
|
1
1
|
async function acceptalert() {
|
|
2
2
|
|
|
3
3
|
try {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
// });
|
|
4
|
+
await browser.waitUntil(async () => {
|
|
5
|
+
return await browser.isAlertOpen();
|
|
6
|
+
}, {
|
|
7
|
+
timeout: 5000,
|
|
8
|
+
timeoutMsg: 'Expected alert to appear but it did not'
|
|
9
|
+
});
|
|
22
10
|
await browser.acceptAlert();
|
|
23
|
-
|
|
24
11
|
} catch (e) {
|
|
25
12
|
console.log("error occured while accepting alert", e)
|
|
26
13
|
}
|
|
@@ -44,6 +31,4 @@ async function dismissalert() {
|
|
|
44
31
|
|
|
45
32
|
}
|
|
46
33
|
|
|
47
|
-
|
|
48
|
-
|
|
49
34
|
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
|
-
|
|
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,33 +34,15 @@ 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
|
+
response = await axios({
|
|
40
40
|
method: method,
|
|
41
41
|
url: api_url,
|
|
42
|
-
headers: headers
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|
-
|
|
42
|
+
headers: headers,
|
|
43
|
+
data: body === null ? undefined : body // Axios allows body with GET in some cases
|
|
44
|
+
});
|
|
45
|
+
|
|
64
46
|
|
|
65
47
|
console.log("Response Data:", response.data);
|
|
66
48
|
|
|
@@ -132,7 +114,7 @@ async function validate(attribute_name, attribute, actionname, buffer, buffernam
|
|
|
132
114
|
} else if (actionname.toLowerCase() == "getbuffer") {
|
|
133
115
|
let annotationMessage = `The vlaue has been retrived from the buffer : ${buffername_value}.`;
|
|
134
116
|
await amendToBrowserstack(annotationMessage, "info");
|
|
135
|
-
return
|
|
117
|
+
return BUFFER.getItem(buffername_value);
|
|
136
118
|
|
|
137
119
|
}
|
|
138
120
|
// } catch (e) {
|
|
@@ -153,7 +135,9 @@ async function validateAttributeData(attribute_name, attribute, buffer, bufferna
|
|
|
153
135
|
valueToVerify = Number(valueToVerify);
|
|
154
136
|
} else if (datatype.toLowerCase() == "boolean") {
|
|
155
137
|
valueToVerify = Boolean(valueToVerify);
|
|
156
|
-
} else if (datatype.toLowerCase() == "
|
|
138
|
+
} else if (datatype.toLowerCase() == "float") {
|
|
139
|
+
valueToVerify = parseFloat(valueToVerify);
|
|
140
|
+
} else if (datatype.toLowerCase() == "double") {
|
|
157
141
|
valueToVerify = parseFloat(valueToVerify);
|
|
158
142
|
} else if (datatype.toLowerCase() == "string") {
|
|
159
143
|
valueToVerify = valueToVerify.toString();
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
// Function to verify text in Android app
|
|
2
|
-
import assert from 'assert';
|
|
3
|
-
const amendToBrowserstack = require("../froth_api_calls/browsersatckSessionInfo").amend2Browserstack;
|
|
4
2
|
|
|
5
3
|
async function assertText(elementSelector, expectedText) {
|
|
6
4
|
|
|
@@ -8,19 +6,18 @@ async function assertText(elementSelector, expectedText) {
|
|
|
8
6
|
console.log("inside the assert text function" + elementSelector)
|
|
9
7
|
try {
|
|
10
8
|
let element = await $(elementSelector)
|
|
9
|
+
let assertionStatus = false; // Initialize status
|
|
11
10
|
try {
|
|
12
11
|
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}`);
|
|
24
21
|
}
|
|
25
22
|
|
|
26
23
|
|
|
@@ -28,9 +25,6 @@ async function assertText(elementSelector, expectedText) {
|
|
|
28
25
|
console.error('Error occurred while verifying text:', error);
|
|
29
26
|
let annotationMessage = `Error occurred while verifying text: ${error.message}.`;
|
|
30
27
|
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
28
|
// throw error;
|
|
35
29
|
}
|
|
36
30
|
|
|
@@ -43,6 +37,7 @@ async function assertAttributeValue(elementSelector, attributeName, expectedText
|
|
|
43
37
|
console.log("inside the assertAttributeValue function" + elementSelector)
|
|
44
38
|
try {
|
|
45
39
|
let element = await $(elementSelector)
|
|
40
|
+
let assertionStatus = false; // Initialize status
|
|
46
41
|
try {
|
|
47
42
|
await expect(element).toHaveAttribute(attributeName, expectedText);
|
|
48
43
|
let actualText;
|
|
@@ -52,34 +47,27 @@ async function assertAttributeValue(elementSelector, attributeName, expectedText
|
|
|
52
47
|
await amendToBrowserstack(annotationMessage, "info");
|
|
53
48
|
} catch (error) {
|
|
54
49
|
console.warn("Assertion failed:", error.message);
|
|
55
|
-
let annotationMessage = `Assertion failed. Expected text:
|
|
50
|
+
let annotationMessage = `Assertion failed. Expected text: ,${expectedText}. ,${error.message}`;
|
|
56
51
|
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
52
|
}
|
|
62
53
|
} catch (error) {
|
|
63
54
|
console.error('Error occurred while verifying text:', error);
|
|
64
55
|
let annotationMessage = `Error occurred while asserting Attribute: ${error.message}.`;
|
|
65
56
|
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
57
|
}
|
|
70
58
|
|
|
71
59
|
|
|
72
60
|
}
|
|
73
61
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
62
|
+
async function amendToBrowserstack(annotationMessage, level) {
|
|
63
|
+
try {
|
|
64
|
+
await driver.execute('browserstack_executor: {"action": "annotate", "arguments": {"data":"' + annotationMessage + '","level": "' + level + '"}}');
|
|
77
65
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
66
|
+
} catch (error) {
|
|
67
|
+
console.error('Error occurred while verifying text:', error);
|
|
68
|
+
throw error;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
83
71
|
module.exports = { assertText, assertAttributeValue };
|
|
84
72
|
|
|
85
73
|
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
const amendToBrowserstack = require("../froth_api_calls/browsersatckSessionInfo").amend2Browserstack;
|
|
2
|
-
|
|
3
1
|
async function select4mDropDownValue(elementSelector, selectOption) {
|
|
4
2
|
try {
|
|
5
3
|
// let selectBox = await $(elementSelector);
|
|
@@ -12,23 +10,14 @@ async function select4mDropDownValue(elementSelector, selectOption) {
|
|
|
12
10
|
}
|
|
13
11
|
}
|
|
14
12
|
|
|
15
|
-
|
|
13
|
+
|
|
14
|
+
async function amendToBrowserstack(annotationMessage, level) {
|
|
16
15
|
try {
|
|
17
|
-
await
|
|
16
|
+
await driver.execute('browserstack_executor: {"action": "annotate", "arguments": {"data":"' + annotationMessage + '","level": "' + level + '"}}');
|
|
17
|
+
|
|
18
18
|
} catch (error) {
|
|
19
|
-
console.error('Error occurred while
|
|
20
|
-
|
|
21
|
-
await amendToBrowserstack(annotationMessage, "error");
|
|
19
|
+
console.error('Error occurred while verifying text:', error);
|
|
20
|
+
// throw error;
|
|
22
21
|
}
|
|
23
22
|
}
|
|
24
|
-
|
|
25
|
-
// async function amendToBrowserstack(annotationMessage, level) {
|
|
26
|
-
// try {
|
|
27
|
-
// await driver.execute('browserstack_executor: {"action": "annotate", "arguments": {"data":"' + annotationMessage + '","level": "' + level + '"}}');
|
|
28
|
-
|
|
29
|
-
// } catch (error) {
|
|
30
|
-
// console.error('Error occurred while verifying text:', error);
|
|
31
|
-
// // throw error;
|
|
32
|
-
// }
|
|
33
|
-
// }
|
|
34
|
-
module.exports = { select4mDropDownValue,select4mDropDownText };
|
|
23
|
+
module.exports = { select4mDropDownValue };
|