froth-webdriverio-framework 0.1.55 → 0.1.57

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.
@@ -0,0 +1,65 @@
1
+
2
+ async function getBSSessionDetails(sessionIdd,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
+ const url = `https://api.browserstack.com/${sessiontype}/sessions/${sessionId}.json`;
9
+
10
+
11
+ try {
12
+
13
+ const response = await fetch(url, {
14
+ method: 'GET',
15
+ headers: {
16
+ 'Authorization': `Basic ${basicAuth}`
17
+ }
18
+ });
19
+
20
+ if (response.ok) {
21
+ const data = await response.json();
22
+ //console.log('Session Info:', data);
23
+ // const details = JSON.parse(data);
24
+
25
+ // Accessing the public_url property
26
+ const publicUrl = data.automation_session.public_url;
27
+
28
+ console.log("public url : " + publicUrl);
29
+ // return jsondata;
30
+ } else if (response.status === 401) { // Unauthorized, token expired
31
+ // Call login function to obtain a new token
32
+ // const newToken = await getLoginToken(localStorage.getItem("SERVICE_USER"), localStorage.getItem("SERVICE_PASSWORD")); // You need to implement the login function
33
+ // Retry the request with the new token
34
+ // return getExecuitonDetails(frothUrl, newToken, id);
35
+ } else {
36
+ const errorText = await response.text();
37
+ console.error('Data fetch failed response:', errorText);
38
+ throw new Error(`HTTP error! status: ${response.status}`);
39
+ }
40
+
41
+
42
+
43
+ } catch (error) {
44
+ console.error('Error fetching data:', error);
45
+
46
+ }
47
+
48
+
49
+ }
50
+
51
+ //Execute the main function
52
+
53
+ //Main function to execute the API call
54
+ // async function main() {
55
+ // try {
56
+ // localStorage.setItem("EXECUTION_SESSIONID","297666e2fd4195de98d7da3b359669072ff41a2a");
57
+ // await getBrowserstackDetails();
58
+ // } catch (error) {
59
+ // console.error('Error in main function:', error);
60
+ // }
61
+ // }
62
+
63
+ // main();
64
+ module.exports = getBSSessionDetails;
65
+
@@ -3,7 +3,7 @@ const exeDetails = require("../api/getexecutionDetails")
3
3
  const getLoginToken = require("../api/loginapi");
4
4
  const getSuiteDetails = require("../api/getsuiteDetails");
5
5
  const { LocalStorage } = require('node-localstorage');
6
- global.localStorage = new LocalStorage('./scratch');
6
+ global.localStorage = new LocalStorage('./storage');
7
7
 
8
8
  // Description: This file contains the common configuration for the webdriverio framework.
9
9
  const commonconfig = {
@@ -68,7 +68,6 @@ const commonconfig = {
68
68
  */
69
69
  beforeTest: function (test, context) {
70
70
  console.log("Test Name:", test.title);
71
- console.log("Context Details:", context.title);
72
71
  console.log("File Name:", test.file);
73
72
 
74
73
  },
@@ -119,12 +118,13 @@ const commonconfig = {
119
118
  console.log('All tests are done.');
120
119
  const resultdata = result === 0 ? 'Pass' : 'Fail';
121
120
  console.log(`Result: ${resultdata}`);
122
-
121
+
123
122
  const resultdetails = {}
124
123
  resultdetails.excution_status = resultdata === 'Pass' ? 'PASSED' : 'FAILED'
125
124
  resultdetails.excution_time = convertMillisecondsToTime(localStorage.getItem("TOTAL_DURATION"))
126
125
  exeDetails.updateExecuitonDetails(localStorage.getItem("organisation_url"), localStorage.getItem("LOGIN_TOKEN"), localStorage.getItem("EXECUTION_ID"), resultdetails)
127
-
126
+ localStorage.clear();
127
+ console.log('Local storage has been cleared.');
128
128
  // console.log('Capabilities:');
129
129
  // console.log(capabilities);
130
130
  // console.log('Specs:');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "froth-webdriverio-framework",
3
- "version": "0.1.55",
3
+ "version": "0.1.57",
4
4
  "readme": "WendriverIO Integration with [BrowserStack]",
5
5
  "description": "WebdriverIO and BrowserStack App Automate",
6
6
  "license": "MIT",