froth-webdriverio-framework 1.0.86 → 1.0.88
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/getDBdetails.js +6 -11
- package/api/loginapi.js +1 -0
- package/{mobile/commonMethods → commonMethods}/Utils.js +15 -12
- package/commonMethods/connectToDB.js +79 -0
- package/{mobile/commonMethods → commonMethods}/getdata.js +1 -1
- package/db/dbconnections.js +34 -26
- package/package.json +1 -1
- package/storage/LOGIN_TOKEN +1 -0
- package/storage/ORGANISATION_DOMAIN_URL +1 -0
- /package/{mobile/commonMethods → commonMethods}/clickIfVisible.js +0 -0
- /package/{mobile/commonMethods → commonMethods}/scrollDownToView.js +0 -0
- /package/{mobile/commonMethods → commonMethods}/scrollRightToView.js +0 -0
- /package/{mobile/commonMethods → commonMethods}/scrollToBeginning.js +0 -0
- /package/{mobile/commonMethods → commonMethods}/scrollToEnd.js +0 -0
- /package/{mobile/commonMethods → commonMethods}/scrollToLeft.js +0 -0
- /package/{mobile/commonMethods → commonMethods}/scrollToRight.js +0 -0
- /package/{mobile/commonMethods → commonMethods}/test.js +0 -0
- /package/{mobile/commonMethods → commonMethods}/verifyText.js +0 -0
- /package/{mobile/commonMethods → commonMethods}/verifyTextInFieldAttribute.js +0 -0
package/api/getDBdetails.js
CHANGED
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
|
|
2
2
|
// Function to get data from the API using the Bearer token
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
} catch (error) {
|
|
7
|
-
console.error('Error connectToDB', error);
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
async function getDbDetails(frothUrl,token,id) {
|
|
3
|
+
const getLoginToken = require('./loginapi')
|
|
4
|
+
|
|
5
|
+
async function getDbDetails(frothUrl, token, id) {
|
|
11
6
|
|
|
12
7
|
let jsondata = {};
|
|
13
8
|
if (id != 0 || id != null || id != undefined) {
|
|
14
|
-
const url = `https://${frothUrl}/api/
|
|
9
|
+
const url = `https://${frothUrl}/api/dbconnection-retrieve/${id}/`;
|
|
15
10
|
|
|
16
11
|
try {
|
|
17
12
|
console.log("URL: " + url)
|
|
@@ -25,7 +20,7 @@ async function getDbDetails(frothUrl,token,id) {
|
|
|
25
20
|
});
|
|
26
21
|
if (response.ok) {
|
|
27
22
|
jsondata = await response.json();
|
|
28
|
-
|
|
23
|
+
console.log("jsondata:" + JSON.stringify(jsondata))
|
|
29
24
|
return jsondata;
|
|
30
25
|
|
|
31
26
|
} else if (response.status === 401) { // Unauthorized, token expired
|
|
@@ -72,4 +67,4 @@ async function getDbDetails(frothUrl,token,id) {
|
|
|
72
67
|
// }
|
|
73
68
|
|
|
74
69
|
// main();
|
|
75
|
-
module.exports = {
|
|
70
|
+
module.exports = { getDbDetails }
|
package/api/loginapi.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
async function getLoginToken(frothUrl, email, password) {
|
|
6
6
|
try {
|
|
7
7
|
const url = `https://${frothUrl}/api/login/`;
|
|
8
|
+
console.log("URL: " + url);
|
|
8
9
|
const formData = new FormData();
|
|
9
10
|
formData.append('email_or_username', email);
|
|
10
11
|
formData.append('password', Buffer.from(password, 'base64').toString('utf-8'));
|
|
@@ -8,7 +8,7 @@ let scrollToRight = null;
|
|
|
8
8
|
let scrollDownToView = null;
|
|
9
9
|
let scrollRightToView = null;
|
|
10
10
|
let verifyText = null;
|
|
11
|
-
|
|
11
|
+
let connectToDB = null;
|
|
12
12
|
if (process.env.LOCATION == 'local') {
|
|
13
13
|
|
|
14
14
|
scrollToEnd = require("./scrollToEnd");
|
|
@@ -20,19 +20,21 @@ if (process.env.LOCATION == 'local') {
|
|
|
20
20
|
scrollDownToView = require('./scrollDownToView');
|
|
21
21
|
scrollRightToView = require('./scrollRightToView');
|
|
22
22
|
verifyText = require('./verifyText');
|
|
23
|
+
connectToDB = require('./connectToDB');
|
|
23
24
|
} else {
|
|
24
|
-
scrollToEnd = require('froth-webdriverio-framework/
|
|
25
|
-
clickIfVisible = require('froth-webdriverio-framework/
|
|
26
|
-
verifyTextInFieldAttribute = require('froth-webdriverio-framework/
|
|
27
|
-
scrollToBeginning = require('froth-webdriverio-framework/
|
|
28
|
-
scrollToLeft = require('froth-webdriverio-framework/
|
|
29
|
-
scrollToRight = require('froth-webdriverio-framework/
|
|
30
|
-
scrollDownToView = require('froth-webdriverio-framework/
|
|
31
|
-
scrollRightToView = require('froth-webdriverio-framework/
|
|
32
|
-
verifyText = require('froth-webdriverio-framework/
|
|
25
|
+
scrollToEnd = require('froth-webdriverio-framework/commonMethods/scrollToEnd');
|
|
26
|
+
clickIfVisible = require('froth-webdriverio-framework/commonMethods/clickIfVisible');
|
|
27
|
+
verifyTextInFieldAttribute = require('froth-webdriverio-framework/commonMethods/verifyTextInFieldAttribute');
|
|
28
|
+
scrollToBeginning = require('froth-webdriverio-framework/commonMethods/scrollToBeginning');
|
|
29
|
+
scrollToLeft = require('froth-webdriverio-framework/commonMethods/scrollToLeft');
|
|
30
|
+
scrollToRight = require('froth-webdriverio-framework/commonMethods/scrollToRight');
|
|
31
|
+
scrollDownToView = require('froth-webdriverio-framework/commonMethods/scrollDownToView');
|
|
32
|
+
scrollRightToView = require('froth-webdriverio-framework/commonMethods/scrollRightToView');
|
|
33
|
+
verifyText = require('froth-webdriverio-framework/commonMethods/verifyText');
|
|
34
|
+
connectToDB = require('froth-webdriverio-framework/commonMethods/connectToDB');
|
|
33
35
|
}
|
|
34
36
|
//export the variabels
|
|
35
|
-
module.exports= {
|
|
37
|
+
module.exports = {
|
|
36
38
|
scrollToEnd,
|
|
37
39
|
clickIfVisible,
|
|
38
40
|
verifyTextInFieldAttribute,
|
|
@@ -41,5 +43,6 @@ module.exports= {
|
|
|
41
43
|
scrollToRight,
|
|
42
44
|
scrollDownToView,
|
|
43
45
|
scrollRightToView,
|
|
44
|
-
verifyText
|
|
46
|
+
verifyText,
|
|
47
|
+
connectToDB
|
|
45
48
|
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
|
|
2
|
+
const dbinfo = require('../api/getDBdetails');
|
|
3
|
+
const dbconnect = require('../db/dbconnections');
|
|
4
|
+
const getLoginToken = require('../api/loginapi');
|
|
5
|
+
// const { LocalStorage } = require('node-localstorage');
|
|
6
|
+
// global.BUFFER = new LocalStorage('./storage');
|
|
7
|
+
|
|
8
|
+
async function connectToDB(id, querytype, query) {
|
|
9
|
+
try {
|
|
10
|
+
const jsondata = await dbinfo.getDbDetails(BUFFER.getItem("ORGANISATION_DOMAIN_URL"), BUFFER.getItem("LOGIN_TOKEN"), id);
|
|
11
|
+
let connectionpool = await dbtype(jsondata.database_type, jsondata);
|
|
12
|
+
let result = await executeQuery(querytype, query, connectionpool);
|
|
13
|
+
return result;
|
|
14
|
+
} catch (error) {
|
|
15
|
+
console.error('Error connectToDB', error);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async function dbtype(type, jsondata) {
|
|
20
|
+
let connectionpool;
|
|
21
|
+
try {
|
|
22
|
+
switch (type) {
|
|
23
|
+
case 'MySQL':
|
|
24
|
+
connectionpool = dbconnect.connectTomysql(jsondata.host, jsondata.username, jsondata.password, jsondata.schema_name, jsondata.port_number);
|
|
25
|
+
break;
|
|
26
|
+
|
|
27
|
+
default:
|
|
28
|
+
console.log('Unknown dbtype.');
|
|
29
|
+
|
|
30
|
+
}
|
|
31
|
+
return connectionpool;
|
|
32
|
+
|
|
33
|
+
} catch (error) { console.error('Error dbtype', error); }
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
async function executeQuery(querytype, query, connectionpool) {
|
|
38
|
+
let finalResult;
|
|
39
|
+
try {
|
|
40
|
+
switch (querytype) {
|
|
41
|
+
case 'select':
|
|
42
|
+
finalResult = dbconnect.fetchDataFromDB(connectionpool, query);
|
|
43
|
+
break;
|
|
44
|
+
case 'insert':
|
|
45
|
+
connectionpool = dbconnect.connectTomysql(jsondata.hostname, jsondata.username, jsondata.password, jsondata.dbname, jsondata.portnumber);
|
|
46
|
+
break;
|
|
47
|
+
case 'update':
|
|
48
|
+
connectionpool = dbconnect.connectTomysql(jsondata.hostname, jsondata.username, jsondata.password, jsondata.dbname, jsondata.portnumber);
|
|
49
|
+
break;
|
|
50
|
+
default:
|
|
51
|
+
console.log('Unknown querytype.');
|
|
52
|
+
}
|
|
53
|
+
return finalResult;
|
|
54
|
+
} catch (error) { console.error('Error querytype', error); }
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// async function main() {
|
|
58
|
+
// try {
|
|
59
|
+
// BUFFER.setItem("ORGANISATION_DOMAIN_URL","devapi.frothtestops.com");
|
|
60
|
+
// //const query = 'SELECT id,EventID,NoPlate FROM store_images limit 2';
|
|
61
|
+
// const token = await getLoginToken("devapi.frothtestops.com", "subhra.subudhi@roboticodigital.com", "V2VsY29tZUAxMjM=");
|
|
62
|
+
// if (!token) {
|
|
63
|
+
// throw new Error('Login failed, no token obtained');
|
|
64
|
+
// }
|
|
65
|
+
// BUFFER.setItem("LOGIN_TOKEN",token);
|
|
66
|
+
|
|
67
|
+
// const result = await connectToDB(3, 'select', 'SELECT id,EventID,NoPlate FROM store_images limit 2');
|
|
68
|
+
// console.log("results are :" + JSON.stringify(result, null, 2));
|
|
69
|
+
// const data=JSON.stringify(result, null, 2)
|
|
70
|
+
// console.log("data is :" + result.totalNumberOfRecords);
|
|
71
|
+
// console.log("data is :" + result.records[0].id);
|
|
72
|
+
|
|
73
|
+
// } catch (err) {
|
|
74
|
+
// console.log('Error connecting to database:', err.stack);
|
|
75
|
+
// }
|
|
76
|
+
// }
|
|
77
|
+
|
|
78
|
+
// main()
|
|
79
|
+
module.exports = connectToDB;
|
package/db/dbconnections.js
CHANGED
|
@@ -2,7 +2,6 @@ const mysql = require('mysql2/promise');
|
|
|
2
2
|
|
|
3
3
|
// Function to establish connection to MySQL database
|
|
4
4
|
async function connectTomysql(hostname, username, password, dbname, portnumber) {
|
|
5
|
-
let connection = null;
|
|
6
5
|
try {
|
|
7
6
|
const poolConfig = {
|
|
8
7
|
host: hostname, // Replace with your database host
|
|
@@ -27,11 +26,11 @@ async function connectTomysql(hostname, username, password, dbname, portnumber)
|
|
|
27
26
|
} catch (err) {
|
|
28
27
|
console.log('Error connecting to database:', err.stack);
|
|
29
28
|
}
|
|
30
|
-
return connection;
|
|
31
29
|
}
|
|
32
30
|
|
|
33
|
-
async function
|
|
31
|
+
async function fetchDataFromDB(connectionpool, query) {
|
|
34
32
|
let connection = null;
|
|
33
|
+
let finalResult = null;
|
|
35
34
|
try {
|
|
36
35
|
connection = await connectionpool.getConnection();
|
|
37
36
|
console.log('Connected to the MySQL database.');
|
|
@@ -41,15 +40,24 @@ async function fetchDataFromSQLDB(connectionpool, query) {
|
|
|
41
40
|
|
|
42
41
|
// Store the data into an array
|
|
43
42
|
const dataArray = rows;
|
|
44
|
-
|
|
43
|
+
let recordsArray = [];
|
|
44
|
+
console.log("data is " + JSON.stringify(dataArray, null, 2));
|
|
45
45
|
// Print the values for each column in each row
|
|
46
|
-
dataArray.forEach(row => {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
});
|
|
46
|
+
// dataArray.forEach(row => {
|
|
47
|
+
// let record = {};
|
|
48
|
+
// Object.keys(row).forEach(columnName => {
|
|
49
|
+
// console.log(`${columnName}: ${row[columnName]}`);
|
|
50
|
+
// record[columnName] = row[columnName];
|
|
51
|
+
// // BUFFER.setItem(columnName, row[columnName]);
|
|
52
|
+
// });
|
|
53
|
+
// console.log('---'); // Separator for each row
|
|
54
|
+
// });
|
|
55
|
+
|
|
56
|
+
finalResult = {
|
|
57
|
+
totalNumberOfRecords: dataArray.length,
|
|
58
|
+
records: dataArray
|
|
59
|
+
};
|
|
60
|
+
console.log(JSON.stringify(finalResult, null, 2));
|
|
53
61
|
|
|
54
62
|
} catch (error) {
|
|
55
63
|
console.error('Error fetching data:', error);
|
|
@@ -57,23 +65,23 @@ async function fetchDataFromSQLDB(connectionpool, query) {
|
|
|
57
65
|
connection.release();
|
|
58
66
|
|
|
59
67
|
}
|
|
60
|
-
|
|
68
|
+
return finalResult;
|
|
61
69
|
}
|
|
62
70
|
|
|
63
71
|
// write main method to call the functions
|
|
64
72
|
|
|
65
|
-
async function main() {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
73
|
+
// async function main() {
|
|
74
|
+
// try {
|
|
75
|
+
// const connection = await connectTomysql('10.0.0.6', 'root', 'password123', 'power_seraya_step', 3406);
|
|
76
|
+
// const query = 'SELECT id,EventID,NoPlate FROM store_images limit 2';
|
|
77
|
+
// await fetchDataFromDB(connection, query);
|
|
78
|
+
// } catch (err) {
|
|
79
|
+
// console.log('Error connecting to database:', err.stack);
|
|
80
|
+
// }
|
|
81
|
+
// }
|
|
74
82
|
|
|
75
|
-
main()
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
83
|
+
// main()
|
|
84
|
+
module.exports = {
|
|
85
|
+
connectTomysql,
|
|
86
|
+
fetchDataFromDB
|
|
87
|
+
};
|
package/package.json
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNzIwNTEyNDMxLCJpYXQiOjE3MjA1MDg4MzEsImp0aSI6ImQ5MTk3NGEzODc3OTQ5MzZiMzk3NGVkNTRhNzhhNDBkIiwidXNlcl9pZCI6OTl9.abE3jatzPNFvxj492YuzDUKwZjZRFOs3cWhxySJBN_k
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
devapi.frothtestops.com
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|