froth-webdriverio-framework 0.1.56 → 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
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "froth-webdriverio-framework",
3
- "version": "0.1.56",
3
+ "version": "0.1.57",
4
4
  "readme": "WendriverIO Integration with [BrowserStack]",
5
5
  "description": "WebdriverIO and BrowserStack App Automate",
6
6
  "license": "MIT",