froth-webdriverio-framework 7.0.6 → 7.0.8
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.
|
@@ -88,46 +88,101 @@ async function getBSSessionDetails(sessionType, bsUsername, bsPassword) {
|
|
|
88
88
|
// throw error;
|
|
89
89
|
// }
|
|
90
90
|
// }
|
|
91
|
+
|
|
91
92
|
async function amend2Browserstack(annotationMessage, level) {
|
|
92
93
|
try {
|
|
93
94
|
const MAX_CHUNK_SIZE = 800 * 1024; // 800 KB
|
|
94
95
|
|
|
95
|
-
// Convert
|
|
96
|
-
let messageStr =
|
|
96
|
+
// 1️⃣ Convert to string
|
|
97
|
+
let messageStr =
|
|
98
|
+
typeof annotationMessage === "string"
|
|
99
|
+
? annotationMessage
|
|
100
|
+
: JSON.stringify(annotationMessage, null, 2);
|
|
101
|
+
|
|
102
|
+
// 2️⃣ Escape for BrowserStack executor (IMPORTANT)
|
|
103
|
+
let escapedMessage = messageStr
|
|
104
|
+
.replace(/\\/g, "\\\\")
|
|
105
|
+
.replace(/"/g, '\\"')
|
|
106
|
+
.replace(/\n/g, "\\n")
|
|
107
|
+
.replace(/\r/g, "\\r");
|
|
97
108
|
|
|
98
|
-
// Split into chunks
|
|
109
|
+
// 3️⃣ Split into chunks
|
|
99
110
|
const chunks = [];
|
|
100
|
-
for (let i = 0; i <
|
|
101
|
-
chunks.push(
|
|
111
|
+
for (let i = 0; i < escapedMessage.length; i += MAX_CHUNK_SIZE) {
|
|
112
|
+
chunks.push(escapedMessage.slice(i, i + MAX_CHUNK_SIZE));
|
|
102
113
|
}
|
|
103
114
|
|
|
104
|
-
|
|
115
|
+
console.log(
|
|
116
|
+
`BrowserStack Annotation → total chars: ${escapedMessage.length}, chunks: ${chunks.length}`
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
// 4️⃣ Print + send chunks
|
|
105
120
|
for (let i = 0; i < chunks.length; i++) {
|
|
106
|
-
const chunkMessage =
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
+
const chunkMessage =
|
|
122
|
+
chunks.length > 1
|
|
123
|
+
? `PART ${i + 1}/${chunks.length}\n${chunks[i]}`
|
|
124
|
+
: chunks[i];
|
|
125
|
+
|
|
126
|
+
// 🔍 LOCAL LOG
|
|
127
|
+
console.log("=======================================");
|
|
128
|
+
console.log(`BrowserStack Chunk ${i + 1}/${chunks.length}`);
|
|
129
|
+
console.log(chunkMessage);
|
|
130
|
+
console.log("=======================================");
|
|
131
|
+
|
|
132
|
+
// 🚀 SEND TO BROWSERSTACK (WDIO-safe)
|
|
133
|
+
if (process.env.PLATFORM === "browserstack") {
|
|
134
|
+
await driver.executeScript(
|
|
135
|
+
`browserstack_executor: {"action":"annotate","arguments":{"data":"${chunkMessage}","level":"${level}"}}`
|
|
136
|
+
);
|
|
121
137
|
}
|
|
122
138
|
}
|
|
123
|
-
|
|
124
139
|
} catch (error) {
|
|
125
|
-
console.error(
|
|
140
|
+
console.error("BrowserStack annotation failed:", error);
|
|
126
141
|
throw error;
|
|
127
142
|
}
|
|
128
143
|
}
|
|
129
144
|
|
|
130
145
|
|
|
146
|
+
// async function amend2Browserstack(annotationMessage, level) {
|
|
147
|
+
// try {
|
|
148
|
+
// const MAX_CHUNK_SIZE = 800 * 1024; // 800 KB
|
|
149
|
+
|
|
150
|
+
// // Convert message to string in case it's not
|
|
151
|
+
// let messageStr = typeof annotationMessage === "string" ? annotationMessage : JSON.stringify(annotationMessage);
|
|
152
|
+
|
|
153
|
+
// // Split into chunks if needed
|
|
154
|
+
// const chunks = [];
|
|
155
|
+
// for (let i = 0; i < messageStr.length; i += MAX_CHUNK_SIZE) {
|
|
156
|
+
// chunks.push(messageStr.slice(i, i + MAX_CHUNK_SIZE));
|
|
157
|
+
// }
|
|
158
|
+
|
|
159
|
+
// // Send each chunk to BrowserStack sequentially
|
|
160
|
+
// for (let i = 0; i < chunks.length; i++) {
|
|
161
|
+
// const chunkMessage = chunks.length > 1
|
|
162
|
+
// ? `PART ${i + 1}/${chunks.length}\n${chunks[i]}`
|
|
163
|
+
// : chunks[i];
|
|
164
|
+
|
|
165
|
+
// console.log(`Annotation message: ${chunkMessage}`);
|
|
166
|
+
|
|
167
|
+
// if (process.env.PLATFORM === 'browserstack' || process.env.PLATFORM === 'browserstacklocal') {
|
|
168
|
+
// // await driver.execute(`browserstack_executor: {"action": "annotate", "arguments": {"data":"${JSON.stringify(chunkMessage)}","level": "${level}"}}`);
|
|
169
|
+
// await driver.execute("browserstack_executor", {
|
|
170
|
+
// action: "annotate",
|
|
171
|
+
// arguments: {
|
|
172
|
+
// data: chunkMessage,
|
|
173
|
+
// level: level
|
|
174
|
+
// }
|
|
175
|
+
// });
|
|
176
|
+
// }
|
|
177
|
+
// }
|
|
178
|
+
|
|
179
|
+
// } catch (error) {
|
|
180
|
+
// console.error('Error annotating BrowserStack session:', error);
|
|
181
|
+
// throw error;
|
|
182
|
+
// }
|
|
183
|
+
// }
|
|
184
|
+
|
|
185
|
+
|
|
131
186
|
module.exports = {
|
|
132
187
|
getBSSessionDetails,
|
|
133
188
|
getBSBuildDetails,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "froth-webdriverio-framework",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.8",
|
|
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": {
|