froth-webdriverio-framework 6.0.35 → 6.0.36
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/android/samplescript_x.js +202 -0
- package/android_suites/samplsuite_x.js +13 -0
- package/froth_configs/commonconfig.js +32 -32
- package/froth_configs/wdio.common.conf.js +49 -137
- package/log/key-metrics.json +12 -1118
- package/log/sdk-cli-debug.log +189 -613
- package/log/sdk-cli.log +60 -4464
- package/logs/bstack-wdio-service.log +151 -0
- package/logs/percy.log +6 -0
- package/package.json +26 -40
- package/browserstack.err +0 -1
- package/froth_common_actions/Utils.js +0 -167
- package/froth_common_actions/alert.js +0 -49
- package/froth_common_actions/apicall.js +0 -179
- package/froth_common_actions/assert.js +0 -85
- package/froth_common_actions/captureNavigationTime.js +0 -53
- package/froth_common_actions/click.js +0 -57
- package/froth_common_actions/dropDown.js +0 -34
- package/froth_common_actions/emailParsing.js +0 -161
- package/froth_common_actions/jwt.js +0 -64
- package/froth_common_actions/logData.js +0 -73
- package/froth_common_actions/random.js +0 -230
- package/froth_common_actions/scroll.js +0 -104
- package/froth_common_actions/storeToBuffer.js +0 -45
- package/froth_common_actions/swicthWindowTab.js +0 -36
- package/froth_common_actions/swipe.js +0 -219
- package/froth_configs/baseconfig.js +0 -51
- package/froth_configs/setallDatailinBuffer.js +0 -100
- package/froth_configs/wdio.common.conf_Samplegit.js +0 -35
- package/froth_configs/wdio.common.conf_back.js +0 -171
- package/local.log +0 -1
- package/log/key-metrics.json.lock +0 -0
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
const axios = require('axios');
|
|
2
|
-
|
|
3
|
-
const amendToBrowserstack = require("../froth_api_calls/browsersatckSessionInfo").amend2Browserstack;
|
|
4
|
-
|
|
5
|
-
async function callapi(methodtype, api_url, queryParams, payloaddetails, body_type, authentication, headersdetails, attachments) {
|
|
6
|
-
let response;
|
|
7
|
-
// if (queryParams && Object.keys(queryParams).length > 0) {
|
|
8
|
-
// const queryString = new URLSearchParams(queryParams).toString();
|
|
9
|
-
// api_url += `?${queryString}`;
|
|
10
|
-
// }
|
|
11
|
-
console.log("Final API URL:", api_url);
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
try {
|
|
15
|
-
|
|
16
|
-
let method = methodtype.toUpperCase();
|
|
17
|
-
let headers = await formheaders(authentication, headersdetails, body_type);
|
|
18
|
-
let body = null;
|
|
19
|
-
console.log("Body Type:", body_type);
|
|
20
|
-
console.log("method:", method);
|
|
21
|
-
console.log("headers:", headers);
|
|
22
|
-
|
|
23
|
-
if (body_type === "raw" && payloaddetails && Object.keys(payloaddetails).length > 0) {
|
|
24
|
-
console.log("Payload (JSON):", JSON.stringify(payloaddetails));
|
|
25
|
-
body = JSON.stringify(payloaddetails);
|
|
26
|
-
console.log("Payload (raw):", body);
|
|
27
|
-
} else if (body_type === "form-data" && payloaddetails) {
|
|
28
|
-
body = await jsonToFormData(payloaddetails);
|
|
29
|
-
console.log("Payload (FormData):", body);
|
|
30
|
-
for (let [key, value] of body.entries()) {
|
|
31
|
-
console.log(`FormData Key: ${key}, Value: ${value}`);
|
|
32
|
-
}
|
|
33
|
-
} else {
|
|
34
|
-
console.log("No body sent (body_type not provided or empty payload).");
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
console.warn("Warning: GET request with a body is non-standard and may not work with all APIs.");
|
|
39
|
-
const config = {
|
|
40
|
-
method: method,
|
|
41
|
-
url: api_url,
|
|
42
|
-
headers: headers
|
|
43
|
-
};
|
|
44
|
-
const isBodyEmpty =
|
|
45
|
-
body === null ||
|
|
46
|
-
body === undefined ||
|
|
47
|
-
body === ''
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
if (!isBodyEmpty) {
|
|
51
|
-
config.data = body;
|
|
52
|
-
}
|
|
53
|
-
console.log("body:", body);
|
|
54
|
-
console.log("Config for API call:", config);
|
|
55
|
-
response = await axios(config);
|
|
56
|
-
|
|
57
|
-
// response = await axios({
|
|
58
|
-
// method: method,
|
|
59
|
-
// url: api_url,
|
|
60
|
-
// headers: headers,
|
|
61
|
-
// data: body === null ? undefined : body // Axios allows body with GET in some cases
|
|
62
|
-
// });
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
console.log("Response Data:", response.data);
|
|
66
|
-
|
|
67
|
-
} catch (error) {
|
|
68
|
-
console.error('Error during API call in call api menthod:', error);
|
|
69
|
-
let annotationMessage = 'Error during API call:' + error.response ? error.response.data : error.message;
|
|
70
|
-
await amendToBrowserstack(annotationMessage, "error");
|
|
71
|
-
throw error;
|
|
72
|
-
}
|
|
73
|
-
return response;
|
|
74
|
-
}
|
|
75
|
-
async function jsonToFormData(json) {
|
|
76
|
-
const formData = new FormData();
|
|
77
|
-
|
|
78
|
-
function appendFormData(data, parentKey = '') {
|
|
79
|
-
if (data && typeof data === 'object' && !Array.isArray(data)) {
|
|
80
|
-
for (const key in data) {
|
|
81
|
-
if (data.hasOwnProperty(key)) {
|
|
82
|
-
appendFormData(data[key], parentKey ? `${parentKey}[${key}]` : key);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
} else {
|
|
86
|
-
formData.append(parentKey, data);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
appendFormData(json);
|
|
91
|
-
console.log("FormData in json to formdata:", formData);
|
|
92
|
-
return formData;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// Function to form headers
|
|
96
|
-
async function formheaders(authentication, headers, body_type) {
|
|
97
|
-
try {
|
|
98
|
-
if (!headers || typeof headers !== "object") {
|
|
99
|
-
headers = {};
|
|
100
|
-
}
|
|
101
|
-
if (body_type === "raw") {
|
|
102
|
-
headers['Content-Type'] = 'application/json';
|
|
103
|
-
}
|
|
104
|
-
// Add authentication headers based on the type
|
|
105
|
-
if (authentication && authentication.auth_type) {
|
|
106
|
-
if (authentication.auth_type?.toLowerCase() === 'bearer') {
|
|
107
|
-
console.log('Bearer token:', authentication.token);
|
|
108
|
-
headers.Authorization = `Bearer ` + authentication.token;
|
|
109
|
-
} else if (authentication.auth_type?.toLowerCase() === 'basic') {
|
|
110
|
-
headers.Authorization = `Basic ` + btoa(authentication.username + `:` + authentication.password);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
console.log('Headers:', headers);
|
|
114
|
-
} catch (e) {
|
|
115
|
-
|
|
116
|
-
console.error('Error in formheaders:', e);
|
|
117
|
-
let annotationMessage = `Error during API call: ${error.response?.data || error.message}`;
|
|
118
|
-
await amendToBrowserstack(annotationMessage, "error");
|
|
119
|
-
}
|
|
120
|
-
return headers;
|
|
121
|
-
|
|
122
|
-
}
|
|
123
|
-
async function validate(attribute_name, attribute, actionname, buffer, buffername_value, datatype) {
|
|
124
|
-
|
|
125
|
-
if (actionname.toLowerCase() == "verify") {
|
|
126
|
-
await validateAttributeData(attribute_name, attribute, buffer, buffername_value, datatype);
|
|
127
|
-
} else if (actionname.toLowerCase() == "setbuffer") {
|
|
128
|
-
BUFFER.setItem(buffername_value, attribute);
|
|
129
|
-
let annotationMessage = `The vlaue has been stored in the buffer : ${buffername_value}.`;
|
|
130
|
-
await amendToBrowserstack(annotationMessage, "info");
|
|
131
|
-
|
|
132
|
-
} else if (actionname.toLowerCase() == "getbuffer") {
|
|
133
|
-
let annotationMessage = `The vlaue has been retrived from the buffer : ${buffername_value}.`;
|
|
134
|
-
await amendToBrowserstack(annotationMessage, "info");
|
|
135
|
-
return await BUFFER.getItem(buffername_value);
|
|
136
|
-
|
|
137
|
-
}
|
|
138
|
-
// } catch (e) {
|
|
139
|
-
// console.error('Error in validate method:', e);
|
|
140
|
-
// throw e;
|
|
141
|
-
// }
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
async function validateAttributeData(attribute_name, attribute, buffer, buffername_value, datatype) {
|
|
145
|
-
let assertionStatus = false; // Initialize status
|
|
146
|
-
let valueToVerify;
|
|
147
|
-
|
|
148
|
-
try {
|
|
149
|
-
//if buffer is true, get the value from buffer
|
|
150
|
-
buffer ? valueToVerify = BUFFER.getItem(buffername_value) : valueToVerify = buffername_value;
|
|
151
|
-
|
|
152
|
-
if (datatype.toLowerCase() == "integer") {
|
|
153
|
-
valueToVerify = Number(valueToVerify);
|
|
154
|
-
} else if (datatype.toLowerCase() == "boolean") {
|
|
155
|
-
valueToVerify = Boolean(valueToVerify);
|
|
156
|
-
} else if (datatype.toLowerCase() == "decimal") {
|
|
157
|
-
valueToVerify = parseFloat(valueToVerify);
|
|
158
|
-
} else if (datatype.toLowerCase() == "string") {
|
|
159
|
-
valueToVerify = valueToVerify.toString();
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
expect(attribute).toBe(valueToVerify, `${attribute_name} --> Expected value: ${valueToVerify}, but got: ${attribute}`);
|
|
163
|
-
assertionStatus = true; // If assertion passes, set status to true
|
|
164
|
-
|
|
165
|
-
console.log(`Attribute name : ${attribute_name} verification passed. Actual text: ${attribute}, Expected text: ${valueToVerify}.`);
|
|
166
|
-
let annotationMessage = `Attribute name : ${attribute_name} - verification passed. Actual text: ${attribute}, Expected text: ${valueToVerify}.`;
|
|
167
|
-
await amendToBrowserstack(annotationMessage, "info");
|
|
168
|
-
|
|
169
|
-
} catch (e) {
|
|
170
|
-
console.error('Error in validateAttributeData:', e);
|
|
171
|
-
console.log(`Attribute name : ${attribute_name} verification failed. Expected text: ${valueToVerify}. error: ${e.toString()}`);
|
|
172
|
-
let annotationMessage = `Attribute name : ${attribute_name} - verification failed. Expected text: ${valueToVerify}. error: ${e.toString()}`;
|
|
173
|
-
await amendToBrowserstack(annotationMessage, "error");
|
|
174
|
-
|
|
175
|
-
throw e;
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
module.exports = { callapi, validate };
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
// Function to verify text in Android app
|
|
2
|
-
import assert from 'assert';
|
|
3
|
-
const amendToBrowserstack = require("../froth_api_calls/browsersatckSessionInfo").amend2Browserstack;
|
|
4
|
-
|
|
5
|
-
async function assertText(elementSelector, expectedText) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
console.log("inside the assert text function" + elementSelector)
|
|
9
|
-
try {
|
|
10
|
-
let element = await $(elementSelector)
|
|
11
|
-
try {
|
|
12
|
-
await expect(element).toHaveText(expectedText);
|
|
13
|
-
console.log("Assertion succeeded.");
|
|
14
|
-
actualText = await element.getText();
|
|
15
|
-
let annotationMessage = `Assertion passed. Actual text: ${actualText}, Expected text: ${expectedText}.`;
|
|
16
|
-
await amendToBrowserstack(annotationMessage, "info");
|
|
17
|
-
} catch (error) {
|
|
18
|
-
console.log(`Assertion failed. Expected text: ${expectedText}.`);
|
|
19
|
-
let annotationMessage = `Assertion failed. Expected text: ${expectedText}.`;
|
|
20
|
-
await amendToBrowserstack(annotationMessage, "error");
|
|
21
|
-
if (!browser.testErrors) browser.testErrors = [];
|
|
22
|
-
// browser.testErrors.push(`Assertion failed.: ${error.message}`);
|
|
23
|
-
assert.fail(`Text assertion failed: ${error.message}`);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
} catch (error) {
|
|
28
|
-
console.error('Error occurred while verifying text:', error);
|
|
29
|
-
let annotationMessage = `Error occurred while verifying text: ${error.message}.`;
|
|
30
|
-
await amendToBrowserstack(annotationMessage, "error");
|
|
31
|
-
if (!browser.testErrors) browser.testErrors = [];
|
|
32
|
-
// browser.testErrors.push(`Assertion failed.: ${error.message}`);
|
|
33
|
-
assert.fail(`Text assertion failed: ${error.message}`);
|
|
34
|
-
// throw error;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
async function assertAttributeValue(elementSelector, attributeName, expectedText) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
console.log("inside the assertAttributeValue function" + elementSelector)
|
|
44
|
-
try {
|
|
45
|
-
let element = await $(elementSelector)
|
|
46
|
-
try {
|
|
47
|
-
await expect(element).toHaveAttribute(attributeName, expectedText);
|
|
48
|
-
let actualText;
|
|
49
|
-
actualText = await element.getAttribute(attributeName);
|
|
50
|
-
console.log("Assertion succeeded.");
|
|
51
|
-
let annotationMessage = `Assertion passed. Attribute value: ${actualText}, Expected value: ${expectedText}.`;
|
|
52
|
-
await amendToBrowserstack(annotationMessage, "info");
|
|
53
|
-
} catch (error) {
|
|
54
|
-
console.warn("Assertion failed:", error.message);
|
|
55
|
-
let annotationMessage = `Assertion failed. Expected text: ${expectedText}. ,${error.message}`;
|
|
56
|
-
await amendToBrowserstack(annotationMessage, "error");
|
|
57
|
-
console.log("Assertion failed. Expected text: ", expectedText);
|
|
58
|
-
if (!browser.testErrors) browser.testErrors = [];
|
|
59
|
-
// browser.testErrors.push(`Assertion failed.: ${error.message}`);
|
|
60
|
-
assert.fail(`Text assertion failed: ${error.message}`);
|
|
61
|
-
}
|
|
62
|
-
} catch (error) {
|
|
63
|
-
console.error('Error occurred while verifying text:', error);
|
|
64
|
-
let annotationMessage = `Error occurred while asserting Attribute: ${error.message}.`;
|
|
65
|
-
await amendToBrowserstack(annotationMessage, "error");
|
|
66
|
-
if (!browser.testErrors) browser.testErrors = [];
|
|
67
|
-
// browser.testErrors.push(`Assertion failed.: ${error.message}`);
|
|
68
|
-
assert.fail(`Text assertion failed: ${error.message}`);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// async function amendToBrowserstack(annotationMessage, level) {
|
|
75
|
-
// try {
|
|
76
|
-
// await driver.execute('browserstack_executor: {"action": "annotate", "arguments": {"data":"' + annotationMessage + '","level": "' + level + '"}}');
|
|
77
|
-
|
|
78
|
-
// } catch (error) {
|
|
79
|
-
// console.error('Error occurred while annoting into BS', error);
|
|
80
|
-
// throw error;
|
|
81
|
-
// }
|
|
82
|
-
// }
|
|
83
|
-
module.exports = { assertText, assertAttributeValue };
|
|
84
|
-
|
|
85
|
-
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
const amendToBrowserstack = require("../froth_api_calls/browsersatckSessionInfo").amend2Browserstack;
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Capture Navigation / Page Load time
|
|
6
|
-
* @param {string} pageName - (Optional) Custom name for the page
|
|
7
|
-
*/
|
|
8
|
-
async function captureLoadNavigationTime(pageName = '') {
|
|
9
|
-
let pageLoadTime;
|
|
10
|
-
try {
|
|
11
|
-
// Try modern API first
|
|
12
|
-
let perfEntries = await browser.execute(() => {
|
|
13
|
-
if (performance.getEntriesByType) {
|
|
14
|
-
const [nav] = performance.getEntriesByType('navigation');
|
|
15
|
-
return nav ? nav.toJSON() : null;
|
|
16
|
-
}
|
|
17
|
-
return null;
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
if (perfEntries && perfEntries.loadEventEnd) {
|
|
22
|
-
pageLoadTime = perfEntries.loadEventEnd;
|
|
23
|
-
} else {
|
|
24
|
-
// Fallback to old API
|
|
25
|
-
const perfTiming = await browser.execute(() => JSON.stringify(window.performance.timing));
|
|
26
|
-
const timing = JSON.parse(perfTiming);
|
|
27
|
-
pageLoadTime = timing.loadEventEnd - timing.navigationStart;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// If no custom name passed, use the page title
|
|
31
|
-
let title = pageName || await browser.getTitle();
|
|
32
|
-
|
|
33
|
-
// Clean title: remove special characters, keep words separated by space
|
|
34
|
-
title = title
|
|
35
|
-
.replace(/[^a-zA-Z0-9]+/g, ' ') // replace non-alphanumeric with space
|
|
36
|
-
.replace(/\s+/g, ' ') // collapse multiple spaces
|
|
37
|
-
.trim(); // remove leading/trailing spaces
|
|
38
|
-
|
|
39
|
-
pageLoadTime = perfEntries.loadEventEnd; // Already relative to startTime
|
|
40
|
-
pageLoadTime = (pageLoadTime / 1000).toFixed(2); // Convert ms to seconds, keep 2 decimals
|
|
41
|
-
await amendToBrowserstack(`⏱ Page Load Time for ${title}: ${pageLoadTime} seconds`, "info");
|
|
42
|
-
|
|
43
|
-
console.log(`⏱ Page Load Time for ${title}: ${pageLoadTime} seconds`);
|
|
44
|
-
} catch (error) {
|
|
45
|
-
console.error('Error capturing navigation timing:', error);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return pageLoadTime;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
module.exports = { captureLoadNavigationTime };
|
|
53
|
-
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
async function clickIfVisible(elementSelector) {
|
|
2
|
-
try {
|
|
3
|
-
let isDisplayed;
|
|
4
|
-
// Wait for the element to be visible
|
|
5
|
-
await driver.waitUntil(async () => {
|
|
6
|
-
console.log("Waiting for element to be visible");
|
|
7
|
-
const element = await $(elementSelector);
|
|
8
|
-
isDisplayed = await element.isDisplayed();
|
|
9
|
-
console.log("Element is displayed:", isDisplayed);
|
|
10
|
-
if (isDisplayed) {
|
|
11
|
-
// Get the actual text from the element
|
|
12
|
-
const element = await $(elementSelector);
|
|
13
|
-
await element.click();
|
|
14
|
-
console.log("Element is clicked successfully.");
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
}, { timeout: 30000 });
|
|
18
|
-
} catch (error) {
|
|
19
|
-
console.error("Element not found or not visible within 30 seconds");
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
async function doubleclick(elementSelector) {
|
|
24
|
-
try {
|
|
25
|
-
let isDisplayed;
|
|
26
|
-
// Wait for the element to be visible
|
|
27
|
-
await driver.waitUntil(async () => {
|
|
28
|
-
console.log("Waiting for element to be visible");
|
|
29
|
-
const element = await $(elementSelector);
|
|
30
|
-
isDisplayed = await element.isDisplayed();
|
|
31
|
-
console.log("Element is displayed:", isDisplayed);
|
|
32
|
-
if (isDisplayed) {
|
|
33
|
-
// Get the actual text from the element
|
|
34
|
-
const element = await $(elementSelector);
|
|
35
|
-
await element.doubleClick();
|
|
36
|
-
console.log("Element is double clicked successfully.");
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
}, { timeout: 30000 });
|
|
40
|
-
} catch (error) {
|
|
41
|
-
console.error("Element not found or not visible within 30 seconds");
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
async function clickByIdWithExecute(elementid) {
|
|
48
|
-
try {
|
|
49
|
-
await browser.execute(() => {
|
|
50
|
-
document.getElementById(elementid).click();
|
|
51
|
-
});
|
|
52
|
-
} catch (error) {
|
|
53
|
-
console.error("Failed to click on element with id:", elementid);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
module.exports = { clickIfVisible, clickByIdWithExecute ,doubleclick};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
const amendToBrowserstack = require("../froth_api_calls/browsersatckSessionInfo").amend2Browserstack;
|
|
2
|
-
|
|
3
|
-
async function select4mDropDownValue(elementSelector, selectOption) {
|
|
4
|
-
try {
|
|
5
|
-
// let selectBox = await $(elementSelector);
|
|
6
|
-
await $(elementSelector).selectByAttribute('value', selectOption);
|
|
7
|
-
|
|
8
|
-
} catch (error) {
|
|
9
|
-
console.error('Error occurred while selecting the option:', error);
|
|
10
|
-
let annotationMessage = `Error occurred while selecting the option: ${error.message}.`;
|
|
11
|
-
await amendToBrowserstack(annotationMessage, "error");
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
async function select4mDropDownText(elementSelector, visibleText) {
|
|
16
|
-
try {
|
|
17
|
-
await $(elementSelector).selectByVisibleText(visibleText);
|
|
18
|
-
} catch (error) {
|
|
19
|
-
console.error('Error occurred while selecting the option by text:', error);
|
|
20
|
-
let annotationMessage = `Error occurred while selecting the option by text: ${error.message}.`;
|
|
21
|
-
await amendToBrowserstack(annotationMessage, "error");
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// async function amendToBrowserstack(annotationMessage, level) {
|
|
26
|
-
// try {
|
|
27
|
-
// await driver.execute('browserstack_executor: {"action": "annotate", "arguments": {"data":"' + annotationMessage + '","level": "' + level + '"}}');
|
|
28
|
-
|
|
29
|
-
// } catch (error) {
|
|
30
|
-
// console.error('Error occurred while verifying text:', error);
|
|
31
|
-
// // throw error;
|
|
32
|
-
// }
|
|
33
|
-
// }
|
|
34
|
-
module.exports = { select4mDropDownValue,select4mDropDownText };
|
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
// // process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
|
|
2
|
-
|
|
3
|
-
// const Imap = require('imap');
|
|
4
|
-
// const { simpleParser } = require('mailparser');
|
|
5
|
-
// const cheerio = require('cheerio');
|
|
6
|
-
|
|
7
|
-
// /**
|
|
8
|
-
// * Connects to an IMAP inbox, parses emails, and extracts all unique links.
|
|
9
|
-
// * @param {Object} config - IMAP config { user, password, host, port, tls }
|
|
10
|
-
// * @param {Object} [filter] - Optional filter { subject, from }
|
|
11
|
-
// * @returns {Promise<Array<{link: string, text: string}>>}
|
|
12
|
-
// */
|
|
13
|
-
// async function getEmailLinks(username,app_password, subjectdetails,fromemail) {
|
|
14
|
-
// const config = {
|
|
15
|
-
// user: username,
|
|
16
|
-
// password: app_password,
|
|
17
|
-
// host: 'imap.gmail.com',
|
|
18
|
-
// port: 993,
|
|
19
|
-
// tls: true
|
|
20
|
-
// };
|
|
21
|
-
// const filter = {
|
|
22
|
-
// subject: subjectdetails,
|
|
23
|
-
// from: fromemail
|
|
24
|
-
// };
|
|
25
|
-
// const imap = new Imap(config);
|
|
26
|
-
|
|
27
|
-
// function openInbox(cb) {
|
|
28
|
-
// imap.openBox('INBOX', true, cb);
|
|
29
|
-
// }
|
|
30
|
-
|
|
31
|
-
// return new Promise((resolve, reject) => {
|
|
32
|
-
// let results = new Map();
|
|
33
|
-
// let allLinks = [];
|
|
34
|
-
// let parseDone;
|
|
35
|
-
// const parsePromise = new Promise(res => { parseDone = res; });
|
|
36
|
-
|
|
37
|
-
// imap.once('ready', function () {
|
|
38
|
-
// openInbox(function (err, box) {
|
|
39
|
-
// if (err) return cleanup(err);
|
|
40
|
-
|
|
41
|
-
// // Build search criteria
|
|
42
|
-
// let searchCriteria = ['ALL'];
|
|
43
|
-
// if (filter.subject) searchCriteria.push(['HEADER', 'SUBJECT', filter.subject]);
|
|
44
|
-
// if (filter.from) searchCriteria.push(['FROM', filter.from]);
|
|
45
|
-
|
|
46
|
-
// imap.search(searchCriteria, function (err, uids) {
|
|
47
|
-
// if (err) return cleanup(err);
|
|
48
|
-
// if (!uids.length) return cleanup(null, []);
|
|
49
|
-
|
|
50
|
-
// // Sort UIDs descending to get the latest email first
|
|
51
|
-
// uids = uids.sort((a, b) => b - a);
|
|
52
|
-
// // Only fetch the latest email
|
|
53
|
-
// const latestUid = uids[0];
|
|
54
|
-
// const fetch = imap.fetch([latestUid], { bodies: '' });
|
|
55
|
-
// fetch.on('message', function (msg) {
|
|
56
|
-
// let buffer = '';
|
|
57
|
-
// msg.on('body', function (stream) {
|
|
58
|
-
// stream.on('data', function (chunk) {
|
|
59
|
-
// buffer += chunk.toString('utf8');
|
|
60
|
-
// });
|
|
61
|
-
// });
|
|
62
|
-
// msg.once('end', async function () {
|
|
63
|
-
// try {
|
|
64
|
-
// const parsed = await simpleParser(buffer);
|
|
65
|
-
// let links = [];
|
|
66
|
-
|
|
67
|
-
// // Extract from HTML with element context
|
|
68
|
-
// if (parsed.html) {
|
|
69
|
-
// const $ = cheerio.load(parsed.html);
|
|
70
|
-
// $('a[href], button[href], [role="button"][href], img[src], area[href]').each((_, el) => {
|
|
71
|
-
// let link = null;
|
|
72
|
-
// let text = '';
|
|
73
|
-
// let elementType = el.tagName;
|
|
74
|
-
// if (elementType === 'a' || elementType === 'area') {
|
|
75
|
-
// link = $(el).attr('href');
|
|
76
|
-
// text = $(el).text().trim() || link;
|
|
77
|
-
// } else if (elementType === 'img') {
|
|
78
|
-
// link = $(el).attr('src');
|
|
79
|
-
// text = $(el).attr('alt') || link;
|
|
80
|
-
// } else if (elementType === 'button' || $(el).attr('role') === 'button') {
|
|
81
|
-
// link = $(el).attr('href');
|
|
82
|
-
// text = $(el).text().trim() || link;
|
|
83
|
-
// }
|
|
84
|
-
// if (link) {
|
|
85
|
-
// links.push({ link, text, element: elementType });
|
|
86
|
-
// }
|
|
87
|
-
// });
|
|
88
|
-
// }
|
|
89
|
-
|
|
90
|
-
// // Extract from plaintext
|
|
91
|
-
// if (parsed.text) {
|
|
92
|
-
// const urlRegex = /(https?:\/\/[^\s]+)/g;
|
|
93
|
-
// let match;
|
|
94
|
-
// while ((match = urlRegex.exec(parsed.text))) {
|
|
95
|
-
// links.push({ link: match[1], text: match[1], element: 'text' });
|
|
96
|
-
// }
|
|
97
|
-
// }
|
|
98
|
-
|
|
99
|
-
// // Deduplicate by link and element context
|
|
100
|
-
// for (const l of links) {
|
|
101
|
-
// const key = l.link + '|' + l.element + '|' + l.text;
|
|
102
|
-
// if (!results.has(key)) {
|
|
103
|
-
// results.set(key, { link: l.link, text: l.text, element: l.element });
|
|
104
|
-
// }
|
|
105
|
-
// }
|
|
106
|
-
// allLinks = Array.from(results.values());
|
|
107
|
-
// parseDone();
|
|
108
|
-
// } catch (e) {
|
|
109
|
-
// // Log and continue
|
|
110
|
-
// console.error('Parse error:', e);
|
|
111
|
-
// parseDone();
|
|
112
|
-
// }
|
|
113
|
-
// });
|
|
114
|
-
// });
|
|
115
|
-
// fetch.once('error', cleanup);
|
|
116
|
-
// fetch.once('end', async () => {
|
|
117
|
-
// await parsePromise;
|
|
118
|
-
// cleanup(null, allLinks);
|
|
119
|
-
// });
|
|
120
|
-
// });
|
|
121
|
-
// });
|
|
122
|
-
// });
|
|
123
|
-
|
|
124
|
-
// imap.once('error', cleanup);
|
|
125
|
-
|
|
126
|
-
// function cleanup(err, data) {
|
|
127
|
-
// imap.end();
|
|
128
|
-
// if (err) reject(err);
|
|
129
|
-
// else resolve(data);
|
|
130
|
-
// }
|
|
131
|
-
|
|
132
|
-
// imap.connect();
|
|
133
|
-
// });
|
|
134
|
-
// }
|
|
135
|
-
|
|
136
|
-
// async function findLinks(links,searchText) {
|
|
137
|
-
// const findLinkByText = (links, searchText) => {
|
|
138
|
-
// return links.find(l => l.text && l.text.toLowerCase().includes(searchText.toLowerCase()));
|
|
139
|
-
// };
|
|
140
|
-
// // Example usage:
|
|
141
|
-
// const found = findLinkByText(links, searchText);
|
|
142
|
-
// return found ? found.link : null;
|
|
143
|
-
// }
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
// // Example main function for direct execution
|
|
147
|
-
// // if (require.main === module) {
|
|
148
|
-
// // (async () => {
|
|
149
|
-
|
|
150
|
-
// // const links = await extractEmailLinks('gfntesting44@gmail.com','wtrd qfee dicr hpba', "GFN Testing, review your Google Account settings","no-reply@google.com");
|
|
151
|
-
// // console.log('Extracted links in main:', links);
|
|
152
|
-
// // const foundLink = await findLinks(links,"Privacy Policy");
|
|
153
|
-
// // console.log('Found Link: ', foundLink);
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
// // })();
|
|
157
|
-
|
|
158
|
-
// // }
|
|
159
|
-
|
|
160
|
-
// module.exports = { getEmailLinks ,findLinks}
|
|
161
|
-
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
// JWT generation script adapted from
|
|
2
|
-
// https://gist.github.com/corbanb/db03150abbe899285d6a86cc480f674d
|
|
3
|
-
const CryptoJS = require('crypto-js');
|
|
4
|
-
|
|
5
|
-
var jwtSecret = "PJJP3CB51A29E8B9A70B29AB5FA3FC5FAFEFB34CFD881D629F3C892E9DF9F169AFA3PJPJ"
|
|
6
|
-
|
|
7
|
-
// Set headers for JWT
|
|
8
|
-
var header = {
|
|
9
|
-
'typ': 'JWT',
|
|
10
|
-
'alg': 'HS256'
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
// Prepare timestamp in seconds
|
|
14
|
-
var currentTimestamp = Math.floor(Date.now() / 1000)
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
function base64urlEncode(source) {
|
|
18
|
-
let encoded = CryptoJS.enc.Base64.stringify(source);
|
|
19
|
-
encoded = encoded.replace(/=+$/, ''); // Remove padding
|
|
20
|
-
encoded = encoded.replace(/\+/g, '-'); // Replace "+" with "-"
|
|
21
|
-
encoded = encoded.replace(/\//g, '_'); // Replace "/" with "_"
|
|
22
|
-
return encoded;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function generateJWTToken(payload) {
|
|
26
|
-
// Encode the header
|
|
27
|
-
const stringifiedHeader = CryptoJS.enc.Utf8.parse(JSON.stringify(header));
|
|
28
|
-
const encodedHeader = base64urlEncode(stringifiedHeader);
|
|
29
|
-
|
|
30
|
-
// Encode the payload
|
|
31
|
-
const stringifiedPayload = CryptoJS.enc.Utf8.parse(JSON.stringify(payload));
|
|
32
|
-
const encodedPayload = base64urlEncode(stringifiedPayload);
|
|
33
|
-
|
|
34
|
-
// Combine the header and payload
|
|
35
|
-
const token = `${encodedHeader}.${encodedPayload}`;
|
|
36
|
-
|
|
37
|
-
// Sign the token
|
|
38
|
-
const signature = CryptoJS.HmacSHA256(token, jwtSecret);
|
|
39
|
-
const encodedSignature = base64urlEncode(signature);
|
|
40
|
-
|
|
41
|
-
// Return the full token
|
|
42
|
-
return `${token}.${encodedSignature}`;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
//const jwt = generateJWT();
|
|
46
|
-
//pm.environment.set('jwt_signed', signedToken)
|
|
47
|
-
//console.log('Signed and encoded JWT', jwt)
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
// function main() {
|
|
51
|
-
// // JWT Payload
|
|
52
|
-
// const payload = {
|
|
53
|
-
// iss: "YTLC_TEST_AUTOMATION_APP",
|
|
54
|
-
// iat: currentTimestamp, // Issued at
|
|
55
|
-
// exp: currentTimestamp + 200, // Expiry time: 30 seconds from issuance
|
|
56
|
-
// user_agent: {
|
|
57
|
-
// id: "janga.reddy@ytl.com"
|
|
58
|
-
// }
|
|
59
|
-
// };
|
|
60
|
-
|
|
61
|
-
// console.log('JWT signed token:', generateJWTToken(payload));
|
|
62
|
-
// }
|
|
63
|
-
//main()
|
|
64
|
-
module.exports = { generateJWTToken}
|