froth-webdriverio-framework 3.0.48 → 3.0.50
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.
|
@@ -53,9 +53,9 @@ async function getExecuitonDetails(frothUrl, token, id) {
|
|
|
53
53
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
async function getExecuitonScriptDetails(frothUrl, token, execution_id, script_id) {
|
|
56
|
+
async function getExecuitonScriptDetails(frothUrl, token, execution_id, script_id,script_platform) {
|
|
57
57
|
let id;
|
|
58
|
-
const url = `${frothUrl}/api/execution-script-mapping/?execution_id=${execution_id}&automation_script_id=${script_id}`;
|
|
58
|
+
const url = `${frothUrl}/api/execution-script-mapping/?execution_id=${execution_id}&automation_script_id=${script_id}&platform=${script_platform}`;
|
|
59
59
|
|
|
60
60
|
try {
|
|
61
61
|
console.log("URL: " + url)
|
|
@@ -151,11 +151,12 @@ async function updateExecuitonDetails(frothUrl, token, id, resultdetails) {
|
|
|
151
151
|
|
|
152
152
|
}
|
|
153
153
|
|
|
154
|
-
async function updateScriptExecutionStatus(frothUrl, token, scriptid, status) {
|
|
154
|
+
async function updateScriptExecutionStatus(frothUrl, token, scriptid,script_platform, status) {
|
|
155
155
|
|
|
156
156
|
if (scriptid != 0) {
|
|
157
157
|
try {
|
|
158
|
-
|
|
158
|
+
console.log("script platform is "+script_platform)
|
|
159
|
+
const id = await getExecuitonScriptDetails(frothUrl, token, BUFFER.getItem("FROTH_EXECUTION_ID"), scriptid,script_platform)
|
|
159
160
|
console.log("ID is :" + id)
|
|
160
161
|
const url = `${frothUrl}/api/script-status-percentage/${id}/`;
|
|
161
162
|
const formData = new FormData();
|
|
@@ -181,7 +182,7 @@ async function updateScriptExecutionStatus(frothUrl, token, scriptid, status) {
|
|
|
181
182
|
// Call login function to obtain a new token
|
|
182
183
|
const newToken = await getLoginToken(BUFFER.getItem("SERVICE_USER"), BUFFER.getItem("SERVICE_PASSWORD")); // You need to implement the login function
|
|
183
184
|
// Retry the request with the new token
|
|
184
|
-
return updateScriptExecutionStatus(frothUrl, newToken,
|
|
185
|
+
return updateScriptExecutionStatus(frothUrl, newToken, scriptid,script_platform, status);
|
|
185
186
|
} else {
|
|
186
187
|
const errorText = await response.text();
|
|
187
188
|
console.error(`error in updating the status into DB ${response.status}`);
|
package/api/getsuiteDetails.js
CHANGED
|
@@ -28,6 +28,8 @@ async function getSuiteDetails(frothUrl, token, id) {
|
|
|
28
28
|
const automationScripts = jsondata.script_details.reduce((obj, item) => {
|
|
29
29
|
obj[item.script_Id] = item.script_Id;
|
|
30
30
|
BUFFER.setItem(item.scriptName, item.scriptId);
|
|
31
|
+
BUFFER.setItem(item.scriptName+"_PLATFORM", item.platform);
|
|
32
|
+
|
|
31
33
|
return obj;
|
|
32
34
|
}, {});
|
|
33
35
|
jsondata.test_sequence = data.test_sequence;
|
package/commonMethods/apicall.js
CHANGED
|
@@ -11,9 +11,9 @@ async function callapi(method, api_url, queryParams, payloaddetails, authenticat
|
|
|
11
11
|
|
|
12
12
|
if (payloaddetails && Object.keys(payloaddetails).length > 0) {
|
|
13
13
|
console.log("Payload Details:", JSON.stringify(payloaddetails));
|
|
14
|
-
formData= await jsonToFormData(payloaddetails);
|
|
14
|
+
formData = await jsonToFormData(payloaddetails);
|
|
15
15
|
console.log("FormData:", JSON.stringify(formData));
|
|
16
|
-
|
|
16
|
+
// Object.entries(payloaddetails).forEach(([key, value]) => formData.append(key, value));
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
try {
|
|
@@ -39,22 +39,22 @@ async function callapi(method, api_url, queryParams, payloaddetails, authenticat
|
|
|
39
39
|
}
|
|
40
40
|
async function jsonToFormData(json) {
|
|
41
41
|
const formData = new FormData();
|
|
42
|
-
|
|
42
|
+
|
|
43
43
|
function appendFormData(data, parentKey = '') {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
if (data && typeof data === 'object' && !Array.isArray(data)) {
|
|
45
|
+
for (const key in data) {
|
|
46
|
+
if (data.hasOwnProperty(key)) {
|
|
47
|
+
appendFormData(data[key], parentKey ? `${parentKey}[${key}]` : key);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
} else {
|
|
51
|
+
formData.append(parentKey, data);
|
|
49
52
|
}
|
|
50
|
-
} else {
|
|
51
|
-
formData.append(parentKey, data);
|
|
52
|
-
}
|
|
53
53
|
}
|
|
54
|
-
|
|
54
|
+
|
|
55
55
|
appendFormData(json);
|
|
56
56
|
return formData;
|
|
57
|
-
|
|
57
|
+
}
|
|
58
58
|
|
|
59
59
|
// Function to form headers
|
|
60
60
|
async function formheaders(authentication, headers) {
|
|
@@ -76,48 +76,61 @@ async function formheaders(authentication, headers) {
|
|
|
76
76
|
return headers;
|
|
77
77
|
|
|
78
78
|
}
|
|
79
|
-
async function validate(attribute, actionname, buffer,
|
|
80
|
-
let valueToVerify;
|
|
79
|
+
async function validate(attribute_name, attribute, actionname, buffer, buffername_value, datatype) {
|
|
81
80
|
|
|
82
81
|
try {
|
|
83
|
-
let assertionStatus = false; // Initialize status
|
|
84
82
|
|
|
85
83
|
if (actionname.toLowerCase() == "verify") {
|
|
86
|
-
|
|
87
|
-
//if buffer is true, get the value from buffer
|
|
88
|
-
buffer ? valueToVerify = BUFFER.getItem(value) : valueToVerify = value;
|
|
89
|
-
|
|
90
|
-
if (datatype.toLowerCase() == "integer") {
|
|
91
|
-
valueToVerify = Number(valueToVerify);
|
|
92
|
-
} else if (datatype.toLowerCase() == "boolean") {
|
|
93
|
-
valueToVerify = Boolean(valueToVerify);
|
|
94
|
-
}
|
|
95
|
-
expect(attribute).toBe(valueToVerify, `Expected value: ${valueToVerify}, but got: ${attribute}`);
|
|
96
|
-
assertionStatus = true; // If assertion passes, set status to true
|
|
97
|
-
console.log("Verification succeeded.");
|
|
98
|
-
let annotationMessage = `Verification passed. Actual text: ${attribute}, Expected text: ${valueToVerify}.`;
|
|
99
|
-
await amendToBrowserstack(annotationMessage, "info");
|
|
100
|
-
|
|
84
|
+
await validateAttributeData(attribute_name,attribute,buffer, buffername_value, datatype);
|
|
101
85
|
} else if (actionname.toLowerCase() == "setbuffer") {
|
|
102
|
-
BUFFER.setItem(
|
|
86
|
+
BUFFER.setItem(buffername_value, attribute);
|
|
103
87
|
} else if (actionname.toLowerCase() == "getbuffer") {
|
|
104
|
-
return BUFFER.getItem(
|
|
88
|
+
return BUFFER.getItem(buffername_value);
|
|
105
89
|
}
|
|
106
90
|
} catch (e) {
|
|
107
|
-
console.error('Error in validate:', e);
|
|
108
|
-
console.log(`Validation failed. Expected text: ${valueToVerify}.`);
|
|
109
|
-
let annotationMessage = `Verification failed. Expected text: ${valueToVerify}.`;
|
|
110
|
-
await amendToBrowserstack(annotationMessage, "error");
|
|
91
|
+
console.error('Error in validate method:', e);
|
|
111
92
|
}
|
|
112
93
|
}
|
|
113
94
|
|
|
95
|
+
async function validateAttributeData(attribute_name,attribute,buffer, buffername_value, datatype) {
|
|
96
|
+
let assertionStatus = false; // Initialize status
|
|
97
|
+
let valueToVerify;
|
|
98
|
+
|
|
99
|
+
try {
|
|
100
|
+
//if buffer is true, get the value from buffer
|
|
101
|
+
buffer ? valueToVerify = BUFFER.getItem(buffername_value) : valueToVerify = buffername_value;
|
|
102
|
+
|
|
103
|
+
if (datatype.toLowerCase() == "integer") {
|
|
104
|
+
valueToVerify = Number(valueToVerify);
|
|
105
|
+
} else if (datatype.toLowerCase() == "boolean") {
|
|
106
|
+
valueToVerify = Boolean(valueToVerify);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
expect(attribute).toBe(valueToVerify, `${attribute_name} --> Expected value: ${valueToVerify}, but got: ${attribute}`);
|
|
110
|
+
assertionStatus = true; // If assertion passes, set status to true
|
|
111
|
+
|
|
112
|
+
console.log("Verification succeeded.");
|
|
113
|
+
let annotationMessage = `${attribute_name} Verification passed. Actual text: ${attribute}, Expected text: ${valueToVerify}.`;
|
|
114
|
+
|
|
115
|
+
if (process.env.BROWSERSTACK)
|
|
116
|
+
await amendToBrowserstack(annotationMessage, "info");
|
|
117
|
+
|
|
118
|
+
} catch (e) {
|
|
119
|
+
console.error('Error in validateAttributeData:', e);
|
|
120
|
+
console.log(`${attribute_name} Validation failed. Expected text: ${valueToVerify}.`);
|
|
121
|
+
let annotationMessage = `${attribute_name} Verification failed. Expected text: ${valueToVerify}.`;
|
|
122
|
+
|
|
123
|
+
if (process.env.BROWSERSTACK)
|
|
124
|
+
await amendToBrowserstack(annotationMessage, "error");
|
|
125
|
+
}
|
|
126
|
+
}
|
|
114
127
|
async function amendToBrowserstack(annotationMessage, level) {
|
|
115
128
|
try {
|
|
116
|
-
|
|
117
|
-
|
|
129
|
+
await driver.execute('browserstack_executor: {"action": "annotate", "arguments": {"data":"' + annotationMessage + '","level": "' + level + '"}}');
|
|
130
|
+
|
|
118
131
|
} catch (error) {
|
|
119
|
-
|
|
120
|
-
|
|
132
|
+
console.error('Error occurred while annoting to BS :', error);
|
|
133
|
+
throw error;
|
|
121
134
|
}
|
|
122
|
-
|
|
135
|
+
}
|
|
123
136
|
module.exports = { callapi, validate };
|
package/config/commonconfig.js
CHANGED
|
@@ -102,10 +102,13 @@ const commonconfig = {
|
|
|
102
102
|
// scriptresult = "FAILED"
|
|
103
103
|
}
|
|
104
104
|
let scriptid = BUFFER.getItem(fileName.replace(".js", ""))
|
|
105
|
+
let script_platform = BUFFER.getItem(fileName.replace(".js", "")+"_PLATFORM")
|
|
106
|
+
|
|
105
107
|
await exeDetails.updateScriptExecutionStatus(
|
|
106
108
|
BUFFER.getItem("ORGANISATION_DOMAIN_URL"),
|
|
107
109
|
BUFFER.getItem("FROTH_LOGIN_TOKEN"),
|
|
108
110
|
scriptid,
|
|
111
|
+
script_platform.toLowerCase(),
|
|
109
112
|
scriptresult)
|
|
110
113
|
|
|
111
114
|
},
|