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