froth-webdriverio-framework 1.0.1 → 1.0.2

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.
Files changed (37) hide show
  1. package/api/browsersatckSessionInfo.js +73 -0
  2. package/api/getexecutionDetails.js +130 -0
  3. package/api/getsuiteDetails.js +74 -0
  4. package/api/index.js +18 -0
  5. package/api/loginapi.js +55 -0
  6. package/api/readTestdata.js +61 -0
  7. package/config/android.conf.js +45 -0
  8. package/config/common.mobile.conf.js +48 -0
  9. package/config/commonconfig.js +185 -0
  10. package/config/ios.conf.js +32 -0
  11. package/config/setenvvariable.js +13 -0
  12. package/config/web.conf.bs.js +95 -0
  13. package/config/web.conf.js +70 -0
  14. package/local.log +8 -0
  15. package/mobile/commonMethods/Utils.js +44 -0
  16. package/mobile/commonMethods/clickIfVisible.js +23 -0
  17. package/mobile/commonMethods/getdata.js +38 -0
  18. package/mobile/commonMethods/scrollDownToView.js +12 -0
  19. package/mobile/commonMethods/scrollRightToView.js +12 -0
  20. package/mobile/commonMethods/scrollToBeginning.js +12 -0
  21. package/mobile/commonMethods/scrollToEnd.js +12 -0
  22. package/mobile/commonMethods/scrollToLeft.js +12 -0
  23. package/mobile/commonMethods/scrollToRight.js +12 -0
  24. package/mobile/commonMethods/test.js +19 -0
  25. package/mobile/commonMethods/verifyText.js +28 -0
  26. package/mobile/commonMethods/verifyTextInFieldAttribute.js +17 -0
  27. package/package.json +2 -9
  28. package/.env +0 -4
  29. package/packaged/api.bundle.js +0 -3
  30. package/packaged/api.bundle.js.LICENSE.txt +0 -252
  31. package/packaged/api.bundle.js.map +0 -1
  32. package/packaged/config.bundle.js +0 -3
  33. package/packaged/config.bundle.js.LICENSE.txt +0 -13
  34. package/packaged/config.bundle.js.map +0 -1
  35. package/packaged/mobile.bundle.js +0 -3
  36. package/packaged/mobile.bundle.js.LICENSE.txt +0 -1
  37. package/packaged/mobile.bundle.js.map +0 -1
@@ -0,0 +1,73 @@
1
+
2
+ async function getBSSessionDetails(sessiontype,bs_username,bs_pwd) {
3
+ // const sessionId = sessionIdd;
4
+ const username = bs_username;
5
+ const accessKey = bs_pwd;
6
+
7
+ const basicAuth = btoa(`${username}:${accessKey}`);
8
+
9
+
10
+ try {
11
+ const sessionId = browser.sessionId;
12
+ console.log(`Session ID: ${sessionId}`);
13
+
14
+ // const sessionInfo = await browser.execute(() => {
15
+ // return window._browserstack_executor({
16
+ // action: 'getSessionDetails'
17
+ // });
18
+ // });
19
+
20
+ // console.log('BrowserStack session info:', sessionInfo);
21
+
22
+ const url = `https://api.browserstack.com/${sessiontype}/sessions/${sessionId}.json`;
23
+
24
+ const response = await fetch(url, {
25
+ method: 'GET',
26
+ headers: {
27
+ 'Authorization': `Basic ${basicAuth}`
28
+ }
29
+ });
30
+
31
+ if (response.ok) {
32
+ const data = await response.json();
33
+ console.log('Session Info:', data);
34
+
35
+ // Accessing the public_url property
36
+ const publicUrl = data.automation_session.public_url;
37
+ BUFFER.setItem("BS_PUBLIC_URL",publicUrl)
38
+ console.log("public url : " + publicUrl);
39
+ // return jsondata;
40
+ } else if (response.status === 401) { //
41
+ console.log("Unauthorized, token expired")
42
+
43
+ } else {
44
+ const errorText = await response.text();
45
+ console.error('Data fetch failed response:', errorText);
46
+ throw new Error(`HTTP error! status: ${response.status}`);
47
+ }
48
+
49
+
50
+
51
+ } catch (error) {
52
+ console.error('Error fetching data:', error);
53
+
54
+ }
55
+
56
+
57
+ }
58
+
59
+ //Execute the main function
60
+
61
+ //Main function to execute the API call
62
+ // async function main() {
63
+ // try {
64
+ // BUFFER.setItem("EXECUTION_SESSIONID","297666e2fd4195de98d7da3b359669072ff41a2a");
65
+ // await getBrowserstackDetails();
66
+ // } catch (error) {
67
+ // console.error('Error in main function:', error);
68
+ // }
69
+ // }
70
+
71
+ // main();
72
+ module.exports = getBSSessionDetails;
73
+
@@ -0,0 +1,130 @@
1
+
2
+ const getLoginToken = require("../api/loginapi.js")
3
+ // Function to get data from the API using the Bearer token
4
+
5
+ async function getExecuitonDetails(frothUrl, token, id) {
6
+ let jsondata = {};
7
+ if (id != 0) {
8
+ const url = `https://${frothUrl}/api/test-execution-retrieve/${id}`;
9
+
10
+ try {
11
+ // const token = await login(service_username, Buffer.from(service_password, 'base64').toString('utf-8')); // Wait for the login function to resolve and get the token
12
+ // if (!token) {
13
+ // throw new Error('Login failed, no token obtained');
14
+ // }
15
+ const response = await fetch(url, {
16
+ method: 'GET',
17
+ headers: {
18
+ 'Authorization': `Bearer ${token}`,
19
+ 'Content-Type': 'application/json'
20
+
21
+ }
22
+ });
23
+ if (response.ok) {
24
+ const data = await response.json();
25
+ console.log(data)
26
+ jsondata.automation_suite_id = data.automation_suite_id;
27
+ jsondata.test_cycle_id = data.test_cycle_id;
28
+ console.log("json data :" + JSON.stringify(jsondata));
29
+
30
+ return jsondata;
31
+ } else if (response.status === 401) { // Unauthorized, token expired
32
+ // Call login function to obtain a new token
33
+ const newToken = await getLoginToken(BUFFER.getItem("SERVICE_USER"), BUFFER.getItem("SERVICE_PASSWORD")); // You need to implement the login function
34
+ // Retry the request with the new token
35
+ return getExecuitonDetails(frothUrl, newToken, id);
36
+ } else {
37
+ const errorText = await response.text();
38
+ console.error('Data fetch failed response:', errorText);
39
+ throw new Error(`HTTP error! status: ${response.status}`);
40
+ }
41
+
42
+
43
+
44
+ } catch (error) {
45
+ console.error('Error fetching data:', error);
46
+
47
+ }
48
+ } else {
49
+ console.error('Error fetching data: Invalid ID');
50
+ }
51
+
52
+ }
53
+
54
+ async function updateExecuitonDetails(frothUrl, token, id, resultdetails) {
55
+ if (id != 0) {
56
+ const url = `https://${frothUrl}/api/test-execution-update/${id}/`;
57
+
58
+ try {
59
+ console.log("resultdetails" + JSON.stringify(resultdetails))
60
+ const formData = new FormData();
61
+ formData.append('excution_status', resultdetails.excution_status);
62
+ formData.append('excution_time', resultdetails.excution_time);
63
+ formData.append('id', BUFFER.getItem("EXECUTION_ID"))
64
+
65
+ const response = await fetch(url, {
66
+ method: 'PUT',
67
+ headers: {
68
+ 'Authorization': `Bearer ${token}`
69
+ },
70
+ body: formData
71
+
72
+ });
73
+
74
+ if (response.ok) {
75
+ const data = await response.json();
76
+ console.log(data)
77
+
78
+ } else if (response.status === 401) { // Unauthorized, token expired
79
+ // Call login function to obtain a new token
80
+ const newToken = await getLoginToken(BUFFER.getItem("SERVICE_USER"), BUFFER.getItem("SERVICE_PASSWORD")); // You need to implement the login function
81
+ // Retry the request with the new token
82
+ return updateExecuitonDetails(frothUrl, newToken, id,resultdetails);
83
+ } else {
84
+ const errorText = await response.text();
85
+ console.error('Data fetch failed response:', errorText);
86
+ throw new Error(`HTTP error! status: ${response.status}`);
87
+ }
88
+
89
+
90
+
91
+ } catch (error) {
92
+ console.error('Error fetching data:', error);
93
+
94
+ }
95
+ } else {
96
+ console.error('Error fetching data: Invalid ID');
97
+ }
98
+
99
+ }
100
+ //Execute the main function
101
+
102
+ //Main function to execute the API call
103
+ // async function main() {
104
+ // try {
105
+ // const frothUrl = "devapi.frothtestops.com";
106
+ // const username = "subhra.subudhi@roboticodigital.com";
107
+ // const password = "V2VsY29tZUAxMjM=";
108
+
109
+ // const token = await getLoginToken(frothUrl, username, password);
110
+ // if (!token) {
111
+ // throw new Error('Login failed, no token obtained');
112
+ // }
113
+
114
+ // const id = 208;
115
+ // // const data = await getExecuitonDetails(frothUrl, token, id);
116
+ // // console.log("Retrieved JSON Data:", data);
117
+ // const resultdetails = {}
118
+ // const resultdata = "Pass"
119
+ // const duration = "31355ms"
120
+ // resultdetails.excution_status = resultdata === 'Pass' ? 'PASSED' : 'FAILED'
121
+ // //resultdetails.excution_time = convertMillisecondsToTime(duration)
122
+ // await updateExecuitonDetails(frothUrl, token, id, resultdetails);
123
+ // } catch (error) {
124
+ // console.error('Error in main function:', error);
125
+ // }
126
+ // }
127
+
128
+ // main();
129
+ module.exports = { getExecuitonDetails, updateExecuitonDetails };
130
+
@@ -0,0 +1,74 @@
1
+
2
+ const getLoginToken = require("../api/loginapi");
3
+
4
+ // Function to get data from the API using the Bearer token
5
+ async function getSuiteDetails(frothUrl, token, id) {
6
+ let jsondata = {};
7
+ if ( id != 0) {
8
+ const url = `https://${frothUrl}/api/automationsuite-retrieve/${id}/`;
9
+
10
+ try {
11
+
12
+ const response = await fetch(url, {
13
+ method: 'GET',
14
+ headers: {
15
+ 'Authorization': `Bearer ${token}`,
16
+ 'Content-Type': 'application/json'
17
+
18
+ }
19
+ });
20
+ if (response.ok) {
21
+ const data = await response.json();
22
+ console.log(data)
23
+ jsondata.automation_suite_id = data.id;
24
+ jsondata.automation_suite_name = data.automation_suite_name;
25
+ jsondata.test_data_id = data.test_data_id;
26
+ console.log("json data :" + JSON.stringify(jsondata));
27
+
28
+ return jsondata;
29
+
30
+ } else if (response.status === 401) { // Unauthorized, token expired
31
+ // Call login function to obtain a new token
32
+ const newToken = await getLoginToken(BUFFER.getItem("SERVICE_USER"), BUFFER.getItem("SERVICE_PASSWORD")); // You need to implement the login function
33
+ // Retry the request with the new token
34
+ return getSuiteDetails(frothUrl, newToken, id);
35
+ }
36
+ else {
37
+ const errorText = await response.text();
38
+ console.error('Data fetch failed response:', errorText);
39
+ throw new Error(`HTTP error! status: ${response.status}`);
40
+ }
41
+
42
+
43
+
44
+ } catch (error) {
45
+ console.error('Error fetching data:', error);
46
+
47
+ }
48
+ } else {
49
+ console.error('Error fetching data: Invalid ID');
50
+ }
51
+
52
+ }
53
+
54
+ // async function main() {
55
+ // try {
56
+ // const frothUrl = "devapi.frothtestops.com";
57
+ // const username = "subhra.subudhi@roboticodigital.com";
58
+ // const password = "V2VsY29tZUAxMjM=";
59
+
60
+ // const token = await getLoginToken(frothUrl, username, password);
61
+ // if (!token) {
62
+ // throw new Error('Login failed, no token obtained');
63
+ // }
64
+
65
+ // const id = 106;
66
+ // const data = await getSuiteDetails(frothUrl, token, id);
67
+ // console.log("Retrieved JSON Data:", data);
68
+ // } catch (error) {
69
+ // console.error('Error in main function:', error);
70
+ // }
71
+ // }
72
+
73
+ // main();
74
+ module.exports = getSuiteDetails;
package/api/index.js ADDED
@@ -0,0 +1,18 @@
1
+ const express = require('express')
2
+ const app = express()
3
+ const port = 5000
4
+
5
+ let count = 0;
6
+
7
+ app.get('/api', (req, res) => {
8
+ res.json({count})
9
+ })
10
+
11
+ app.post('/api', (req, res) => {
12
+ ++count;
13
+ res.json({count});
14
+ });
15
+
16
+ app.listen(port, () => {
17
+ console.log(`Example app listening on port ${port}`)
18
+ })
@@ -0,0 +1,55 @@
1
+ //const fetch = require('node-fetch'); // Import the fetch function
2
+ //const FormData = require('form-data'); // Import the FormData constructor
3
+
4
+
5
+ async function getLoginToken(frothUrl,email,password) {
6
+ const url = `https://${frothUrl}/api/login/`;
7
+ const formData = new FormData();
8
+ formData.append('email', email);
9
+ formData.append('password', Buffer.from(password, 'base64').toString('utf-8'));
10
+
11
+ const response = await fetch(url, {
12
+ method: 'POST',
13
+ headers: {
14
+ 'accept': 'application/json',
15
+ // 'X-CSRFToken': 'hSb92VZT0AFMKaekBUSdlZjfHMIzhzvOyk6e5i8ZrVv6B15EtN8WLps3oyV2MOY1'
16
+ },
17
+ body: formData
18
+ });
19
+
20
+ if (response.ok) {
21
+ const data = await response.json();
22
+ console.log('Token:', data.access_token);
23
+ return data.access_token;
24
+ } else {
25
+ console.error('Login failed:', response.statusText);
26
+ return null;
27
+ }
28
+
29
+ }
30
+
31
+ // async function main() {
32
+ // try {
33
+ // const frothUrl = "devapi.frothtestops.com";
34
+ // const username = "subhra.subudhi@roboticodigital.com";
35
+ // const password = "V2VsY29tZUAxMjM=";
36
+
37
+ // const token = await getLoginToken(frothUrl, username, password);
38
+ // if (!token) {
39
+ // throw new Error('Login failed, no token obtained');
40
+ // }
41
+
42
+
43
+
44
+ // } catch (error) {
45
+ // console.error('Error in main function:', error);
46
+ // }
47
+ // }
48
+
49
+ // main();
50
+
51
+ module.exports = getLoginToken;
52
+
53
+
54
+
55
+
@@ -0,0 +1,61 @@
1
+ const login = require('./loginapi.js');
2
+
3
+ // Function to get data from the API using the Bearer token
4
+ async function getDataById(frothUrl, token, id) {
5
+
6
+ if (id != 0) {
7
+ const url = `https://${frothUrl}/api/testdata-retrieve/${id}/`;
8
+
9
+ try {
10
+
11
+ const response = await fetch(url, {
12
+ method: 'GET',
13
+ headers: {
14
+ 'Authorization': `Bearer ${token}`,
15
+ 'Content-Type': 'application/json'
16
+ }
17
+ });
18
+
19
+ if (response.ok) {
20
+ const data = await response.json();
21
+ // Convert the key-value data to a JSON string
22
+ const jsonData = data.key_value_data;
23
+ // Convert the array into an object with keys as property names
24
+ const buffer = jsonData.reduce((obj, item) => {
25
+ obj[item.key] = item.value;
26
+ BUFFER.setItem(item.key,item.value);
27
+ return obj;
28
+ }, {});
29
+ // Set the buffer as an environment variable
30
+ // const stringData = JSON.stringify(buffer);
31
+ // console.log('JSON DATA : ', stringData);
32
+ return buffer;
33
+ }
34
+ else if (response.status === 401) { // Unauthorized, token expired
35
+ // Call login function to obtain a new token
36
+ const newToken = await getLoginToken(BUFFER.getItem("SERVICE_USER"), BUFFER.getItem("SERVICE_PASSWORD")); // You need to implement the login function
37
+ // Retry the request with the new token
38
+ return getDataById(frothUrl, newToken, id);
39
+ }
40
+ else {
41
+ const errorText = await response.text();
42
+ console.error('Data fetch failed response:', errorText);
43
+ throw new Error(`HTTP error! status: ${response.status}`);
44
+ }
45
+
46
+
47
+
48
+ } catch (error) {
49
+ console.error('Error fetching data:', error);
50
+
51
+ }
52
+ } else {
53
+ console.error('Error fetching data: Invalid ID');
54
+ }
55
+
56
+ }
57
+ module.exports = getDataById;
58
+
59
+ // Execute the main function
60
+
61
+ //console.log("Retrieved JSON Data from local storage:", getDataById("devapi.frothtestops.com", 78, "asdfa"));
@@ -0,0 +1,45 @@
1
+ const deepmerge = require('deepmerge')
2
+ const commonmobileconfig = require('./common.mobile.conf');
3
+ console.log("BUILD_NUMBER:", process.env.BUILD_NUMBER);
4
+
5
+ const androidConfig = deepmerge.all([commonmobileconfig, {
6
+ services: [
7
+ [
8
+ 'browserstack',
9
+ {
10
+ testObservability: true,
11
+ buildName: "ANDROID BUILD 1",
12
+ buildIdentifier: process.env.BUILD_NUMBER || "default_build_identifier",
13
+ browserstackLocal: false,
14
+ opts: { forcelocal: false },
15
+ app: process.env.BROWSERSTACK_APP_PATH || 'bs://a224145c09eb22e67c21ef65b29d32ae7aa78bb0'
16
+ }
17
+ ]
18
+ ],
19
+
20
+ capabilities: [{
21
+ 'bstack:options': {
22
+ deviceName: process.env.DEVICENAME || 'Samsung Galaxy A11',
23
+ platformVersion: process.env.OSVERSION || '10.0',
24
+ platformName: 'android',
25
+ interactiveDebugging: true
26
+ }
27
+ }],
28
+
29
+
30
+ }]);
31
+
32
+ // console.log("Merged Android Config:", JSON.stringify(androidConfig, null, 2));
33
+
34
+ // androidConfig.capabilities.forEach(function (caps) {
35
+ // for (var i in androidConfig.commonCapabilities) {
36
+ // console.log("i:", i);
37
+ // console.log("caps[i]:", caps[i]);
38
+ // console.log("androidConfig.commonCapabilities[i]:", androidConfig.commonCapabilities[i]);
39
+ // caps[i] = caps[i] || androidConfig.commonCapabilities[i];
40
+ // }
41
+ // });
42
+
43
+ module.exports = androidConfig;
44
+
45
+
@@ -0,0 +1,48 @@
1
+ const deepmerge = require('deepmerge')
2
+ const commonconfig = require('./commonconfig');
3
+
4
+ const commonmobconfig = deepmerge.all([commonconfig,{
5
+ user: process.env.BROWSERSTACK_USERNAME || 'naveen_OSt3Pw',
6
+ key: process.env.BROWSERSTACK_ACCESS_KEY || 'AuzPy8cHZ7sCBmMXakKe',
7
+
8
+ exclude: [],
9
+ logLevel: 'info',
10
+ coloredLogs: true,
11
+ screenshotPath: './errorShots/',
12
+ baseUrl: '',
13
+ waitforTimeout: 90000,
14
+ connectionRetryTimeout: 90000,
15
+ connectionRetryCount: 3,
16
+
17
+ framework: 'mocha',
18
+ mochaOpts: {
19
+ ui: 'bdd',
20
+ timeout: 90000
21
+ },
22
+
23
+
24
+
25
+ maxInstances: 10,
26
+
27
+ updateJob: false,
28
+ reporters: [
29
+ 'spec',
30
+ // ['allure', {
31
+ // outputDir: './androidReports/allure-results', // Specify the output directory
32
+ // disableWebdriverStepsReporting: true,
33
+ // disableWebdriverScreenshotsReporting: true,
34
+ // }],
35
+ ],
36
+ commonCapabilities: {
37
+ 'bstack:options': {
38
+ projectName: process.env.PROJECTNAME || "roboticodigital",
39
+ sessionName: 'Automation test session',
40
+ debug: true,
41
+ networkLogs: true
42
+ }
43
+ },
44
+
45
+
46
+ }]);
47
+
48
+ module.exports = commonmobconfig;