froth-webdriverio-framework 7.0.12 → 7.0.14
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.
|
@@ -106,15 +106,15 @@ module.exports = {
|
|
|
106
106
|
decrpytData
|
|
107
107
|
};
|
|
108
108
|
|
|
109
|
-
await encryptData(
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
)
|
|
113
|
-
|
|
114
|
-
const decrypted_data = await decrpytData(response)
|
|
115
|
-
const data = JSON.parse(decrypted_data)
|
|
116
|
-
console.log("decrpted data" + data)
|
|
117
|
-
return data
|
|
109
|
+
// await encryptData(
|
|
110
|
+
// data,
|
|
111
|
+
// secret_key
|
|
112
|
+
// )
|
|
113
|
+
|
|
114
|
+
// const decrypted_data = await decrpytData(response)
|
|
115
|
+
// const data = JSON.parse(decrypted_data)
|
|
116
|
+
// console.log("decrpted data" + data)
|
|
117
|
+
// return data
|
|
118
118
|
|
|
119
119
|
// Encrypt a password
|
|
120
120
|
//const encryptedPassword = encryptData("admin@1234", SECRET_KEY);
|
|
@@ -77,58 +77,69 @@ async function getBSSessionDetails(sessionType, bsUsername, bsPassword) {
|
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
80
|
+
async function sendSingleAnnotation(annotationMessage, level) {
|
|
81
|
+
try {
|
|
82
|
+
console.log(`=======> BrowserStack Annotation (single): ${annotationMessage}`);
|
|
83
|
+
if (process.env.PLATFORM === 'browserstack') {
|
|
84
|
+
await driver.execute(`browserstack_executor: {"action": "annotate", "arguments": {"data":"${annotationMessage}","level": "${level}"}}`);
|
|
85
|
+
}
|
|
86
|
+
} catch (error) {
|
|
87
|
+
console.error('Error annotating BrowserStack session:', error);
|
|
88
|
+
throw error;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
91
|
|
|
92
92
|
async function amend2Browserstack(annotationMessage, level) {
|
|
93
93
|
try {
|
|
94
|
-
const MAX_CHUNK_BYTES = 800 * 1024; // 800 KB
|
|
94
|
+
const MAX_CHUNK_BYTES = 800 * 1024; // 800 KB
|
|
95
95
|
|
|
96
|
-
//
|
|
97
|
-
|
|
96
|
+
// Convert to string
|
|
97
|
+
const messageStr =
|
|
98
98
|
typeof annotationMessage === "string"
|
|
99
99
|
? annotationMessage
|
|
100
100
|
: JSON.stringify(annotationMessage, null, 2);
|
|
101
101
|
|
|
102
|
-
//
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
102
|
+
// Escape once
|
|
103
|
+
const escapedMessage = await escapeForBrowserStack(messageStr);
|
|
104
|
+
|
|
105
|
+
// Byte size check
|
|
106
|
+
const messageBytes = Buffer.byteLength(escapedMessage, "utf8");
|
|
107
|
+
|
|
108
|
+
console.log(`BrowserStack annotation size: ${messageBytes} bytes`);
|
|
109
|
+
|
|
110
|
+
// ✅ Small payload → single annotation
|
|
111
|
+
if (messageBytes <= MAX_CHUNK_BYTES) {
|
|
112
|
+
await sendSingleAnnotation(escapedMessage, level);
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
108
115
|
|
|
109
|
-
//
|
|
110
|
-
|
|
116
|
+
// 🔁 Large payload → chunking
|
|
117
|
+
await sendChunkedAnnotations(escapedMessage, level, MAX_CHUNK_BYTES);
|
|
111
118
|
|
|
112
|
-
|
|
119
|
+
} catch (error) {
|
|
120
|
+
console.error("BrowserStack annotation failed:", error);
|
|
121
|
+
throw error;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
async function sendChunkedAnnotations(message, level, maxBytes) {
|
|
126
|
+
try {
|
|
127
|
+
const buffer = Buffer.from(message, "utf8");
|
|
113
128
|
const chunks = [];
|
|
114
|
-
|
|
115
|
-
|
|
129
|
+
|
|
130
|
+
for (let i = 0; i < buffer.length; i += maxBytes) {
|
|
131
|
+
chunks.push(buffer.subarray(i, i + maxBytes).toString("utf8"));
|
|
116
132
|
}
|
|
133
|
+
|
|
117
134
|
console.log(
|
|
118
|
-
`BrowserStack
|
|
135
|
+
`BrowserStack chunking enabled → total bytes: ${buffer.length}, chunks: ${chunks.length}`
|
|
119
136
|
);
|
|
120
137
|
|
|
121
|
-
// 5️⃣ Print + send each chunk
|
|
122
138
|
for (let i = 0; i < chunks.length; i++) {
|
|
123
|
-
const chunkMessage =
|
|
124
|
-
chunks.length > 1
|
|
125
|
-
? `PART ${i + 1}/${chunks.length}\n${chunks[i]}`
|
|
126
|
-
: chunks[i];
|
|
139
|
+
const chunkMessage = `PART ${i + 1}/${chunks.length}\n${chunks[i]}`;
|
|
127
140
|
|
|
128
|
-
|
|
129
|
-
console.log(`=======> BrowserStack Chunk ${i + 1}/${chunks.length}`, JSON.stringify(chunkMessage, null, 2));
|
|
141
|
+
console.log(`=======> BrowserStack Chunk ${i + 1}/${chunks.length}`,chunkMessage);
|
|
130
142
|
|
|
131
|
-
// 🚀 SEND TO BROWSERSTACK (WDIO-safe)
|
|
132
143
|
if (process.env.PLATFORM === "browserstack") {
|
|
133
144
|
await driver.execute(
|
|
134
145
|
`browserstack_executor: {"action":"annotate","arguments":{"data":"${chunkMessage}","level":"${level}"}}`
|
|
@@ -140,6 +151,13 @@ async function amend2Browserstack(annotationMessage, level) {
|
|
|
140
151
|
throw error;
|
|
141
152
|
}
|
|
142
153
|
}
|
|
154
|
+
async function escapeForBrowserStack(message) {
|
|
155
|
+
return message
|
|
156
|
+
.replace(/\\/g, "\\\\")
|
|
157
|
+
.replace(/"/g, '\\"')
|
|
158
|
+
.replace(/\n/g, "\\n")
|
|
159
|
+
.replace(/\r/g, "\\r");
|
|
160
|
+
}
|
|
143
161
|
|
|
144
162
|
|
|
145
163
|
|
|
@@ -263,23 +263,23 @@ module.exports = {
|
|
|
263
263
|
update_CICDRUNID_ReportUrl
|
|
264
264
|
};
|
|
265
265
|
|
|
266
|
-
async function main() {
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
main();
|
|
266
|
+
// async function main() {
|
|
267
|
+
// try {
|
|
268
|
+
// const frothUrl = "devapi.frothtestops.com";
|
|
269
|
+
// // const username = "subhra.subudhi@roboticodigital.com";
|
|
270
|
+
// // const password = "V2VsY29tZUAxMjM=";
|
|
271
|
+
|
|
272
|
+
// // const token = await getLoginToken(frothUrl, username, password);
|
|
273
|
+
// // if (!token) {
|
|
274
|
+
// // throw new Error('Login failed, no token obtained');
|
|
275
|
+
// // }
|
|
276
|
+
// const token='eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNzcyNTgyMzk5LCJpYXQiOjE3NjQ3NjU3OTQsImp0aSI6IjRhOWUyNjlkNWZhMzRlYzQ4NjZhZjk5MTc3Y2MwNzZiIiwidXNlcl9pZCI6NH0.1a_KwJvW3LOoBgzWMZBCoyGnA3eNm_XYeiah6Ql_EoA'
|
|
277
|
+
// const id = 147;
|
|
278
|
+
// const data = await getExecuitonDetails(frothUrl, token, id);
|
|
279
|
+
// console.log("Retrieved JSON Data:", data);
|
|
280
|
+
// } catch (error) {
|
|
281
|
+
// console.error('Error in main function:', error);
|
|
282
|
+
// }
|
|
283
|
+
// }
|
|
284
|
+
|
|
285
|
+
// main();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "froth-webdriverio-framework",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.14",
|
|
4
4
|
"readme": "WendriverIO Integration with [BrowserStack](https://www.browserstack.com)",
|
|
5
5
|
"description": "Selenium examples for WebdriverIO and BrowserStack App Automate",
|
|
6
6
|
"scripts": {
|