froth-webdriverio-framework 1.0.13 → 1.0.16
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/api/readTestdata.js +27 -5
- package/config/commonconfig.js +2 -0
- package/config/setallDatailinBuffer.js +10 -17
- package/package.json +1 -1
package/api/readTestdata.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
const login = require('./loginapi.js');
|
|
2
1
|
|
|
3
2
|
// Function to get data from the API using the Bearer token
|
|
4
3
|
async function getDataById(frothUrl, token, id) {
|
|
@@ -7,7 +6,7 @@ async function getDataById(frothUrl, token, id) {
|
|
|
7
6
|
const url = `https://${frothUrl}/api/testdata-retrieve/${id}/`;
|
|
8
7
|
|
|
9
8
|
try {
|
|
10
|
-
|
|
9
|
+
console.log("inside detdataby id ")
|
|
11
10
|
const response = await fetch(url, {
|
|
12
11
|
method: 'GET',
|
|
13
12
|
headers: {
|
|
@@ -15,6 +14,7 @@ async function getDataById(frothUrl, token, id) {
|
|
|
15
14
|
'Content-Type': 'application/json'
|
|
16
15
|
}
|
|
17
16
|
});
|
|
17
|
+
console.log("reponse ok ")
|
|
18
18
|
|
|
19
19
|
if (response.ok) {
|
|
20
20
|
const data = await response.json();
|
|
@@ -23,7 +23,7 @@ async function getDataById(frothUrl, token, id) {
|
|
|
23
23
|
// Convert the array into an object with keys as property names
|
|
24
24
|
const buffer = jsonData.reduce((obj, item) => {
|
|
25
25
|
obj[item.key] = item.value;
|
|
26
|
-
BUFFER.setItem(item.key,item.value);
|
|
26
|
+
BUFFER.setItem(item.key, item.value);
|
|
27
27
|
return obj;
|
|
28
28
|
}, {});
|
|
29
29
|
// Set the buffer as an environment variable
|
|
@@ -54,8 +54,30 @@ async function getDataById(frothUrl, token, id) {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
}
|
|
57
|
-
|
|
57
|
+
|
|
58
58
|
|
|
59
59
|
// Execute the main function
|
|
60
|
+
async function main() {
|
|
61
|
+
try {
|
|
62
|
+
const frothUrl = "devapi.frothtestops.com";
|
|
63
|
+
const username = "subhra.subudhi@roboticodigital.com";
|
|
64
|
+
const password = "V2VsY29tZUAxMjM=";
|
|
65
|
+
|
|
66
|
+
const token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNzE4ODk2NjMzLCJpYXQiOjE3MTg4OTMwMzMsImp0aSI6ImM2NDJlODk3NDI5MjQ1YTliN2E1YmYyYWEzOTMwYjY4IiwidXNlcl9pZCI6MTk0fQ.Om2kXmuhquY1xooCXWacyArCezff2B4qu_joTStyhsA"
|
|
67
|
+
// if (!token) {
|
|
68
|
+
// throw new Error('Login failed, no token obtained');
|
|
69
|
+
// }
|
|
70
|
+
|
|
71
|
+
const id = 94;
|
|
72
|
+
// const data = await getExecuitonDetails(frothUrl, token, id);
|
|
73
|
+
// console.log("Retrieved JSON Data:", data);
|
|
74
|
+
|
|
75
|
+
await getDataById(frothUrl, token, id);
|
|
76
|
+
} catch (error) {
|
|
77
|
+
console.error('Error in main function:', error);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
main();
|
|
60
82
|
|
|
61
|
-
|
|
83
|
+
module.exports = getDataById;
|
package/config/commonconfig.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
const setAllDetails = require("./setallDatailinBuffer")
|
|
2
|
+
const { LocalStorage } = require('node-localstorage');
|
|
3
|
+
global.BUFFER = new LocalStorage('./storage');
|
|
2
4
|
|
|
3
5
|
const getBSSessionDetails = require("../api/browsersatckSessionInfo")
|
|
4
6
|
// Description: This file contains the common configuration for the webdriverio framework.
|
|
@@ -4,8 +4,6 @@ const getintegrationdetails = require("../api/getintegrationDetails");
|
|
|
4
4
|
const getLoginToken = require("../api/loginapi");
|
|
5
5
|
const getSuiteDetails = require("../api/getsuiteDetails");
|
|
6
6
|
|
|
7
|
-
const { LocalStorage } = require('node-localstorage');
|
|
8
|
-
global.BUFFER = new LocalStorage('./storage');
|
|
9
7
|
|
|
10
8
|
|
|
11
9
|
async function setEnvVariables() {
|
|
@@ -17,15 +15,7 @@ async function setEnvVariables() {
|
|
|
17
15
|
BUFFER.setItem("SERVICE_USER", "frothbot@roboticodigital.com");
|
|
18
16
|
BUFFER.setItem("SERVICE_PASSWORD", "RnJvdGh0ZXN0b3BzQDU1NQ==");
|
|
19
17
|
|
|
20
|
-
|
|
21
|
-
// const bufferContents = {};
|
|
22
|
-
// const data = global.BUFFER
|
|
23
|
-
// for (let i = 0; i < data.length; i++) {
|
|
24
|
-
// const key = data.key(i);
|
|
25
|
-
// bufferContents[key] = data.getItem(key);
|
|
26
|
-
// }
|
|
27
|
-
|
|
28
|
-
// console.log("BUFFER contents:", bufferContents);
|
|
18
|
+
|
|
29
19
|
}
|
|
30
20
|
|
|
31
21
|
async function setLoginToken() {
|
|
@@ -79,6 +69,8 @@ async function setSuiteDetails() {
|
|
|
79
69
|
process.env.BROWSERSTACK_APP_PATH = getSuiteDetail.browser_stack_urls;
|
|
80
70
|
console.log("BROWSERSTACK_APP_PATH" + process.env.BROWSERSTACK_APP_PATH)
|
|
81
71
|
process.env.TESTDATA_ID = getSuiteDetail.test_data_id;
|
|
72
|
+
console.log("ALL JSON DATA:" + JSON.stringify(BUFFER));
|
|
73
|
+
console.log("ALL JSON DATA in env variable :" + JSON.stringify(process.env));
|
|
82
74
|
|
|
83
75
|
} catch (error) {
|
|
84
76
|
// console.error('Error in main function:', error);
|
|
@@ -86,14 +78,15 @@ async function setSuiteDetails() {
|
|
|
86
78
|
}
|
|
87
79
|
async function setTestDataDetails() {
|
|
88
80
|
try {
|
|
81
|
+
console.log("setTestDataDetails" );
|
|
89
82
|
const jsonobject = await getDataById(BUFFER.getItem("ORGANISATION_DOMAIN_URL"), BUFFER.getItem("LOGIN_TOKEN"), BUFFER.getItem("TESTDATA_ID"));
|
|
90
|
-
if (jsonobject == null) {
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
|
|
83
|
+
// if (jsonobject == null) {
|
|
84
|
+
// console.log("Test data is not available");
|
|
85
|
+
// }
|
|
86
|
+
// else {
|
|
87
|
+
// BUFFER.setItem("BUFFER", JSON.stringify(jsonobject))
|
|
95
88
|
|
|
96
|
-
}
|
|
89
|
+
// }
|
|
97
90
|
} catch (error) {
|
|
98
91
|
// console.error('Error in main function:', error);
|
|
99
92
|
}
|