froth-webdriverio-framework 7.0.8 → 7.0.10

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.
@@ -91,32 +91,34 @@ async function getBSSessionDetails(sessionType, bsUsername, bsPassword) {
91
91
 
92
92
  async function amend2Browserstack(annotationMessage, level) {
93
93
  try {
94
- const MAX_CHUNK_SIZE = 800 * 1024; // 800 KB
94
+ const MAX_CHUNK_BYTES = 800 * 1024; // 800 KB (BYTE-based)
95
95
 
96
- // 1️⃣ Convert to string
96
+ // 1️⃣ Convert message to string
97
97
  let messageStr =
98
98
  typeof annotationMessage === "string"
99
99
  ? annotationMessage
100
100
  : JSON.stringify(annotationMessage, null, 2);
101
101
 
102
- // 2️⃣ Escape for BrowserStack executor (IMPORTANT)
102
+ // 2️⃣ Escape for BrowserStack executor
103
103
  let escapedMessage = messageStr
104
104
  .replace(/\\/g, "\\\\")
105
105
  .replace(/"/g, '\\"')
106
106
  .replace(/\n/g, "\\n")
107
107
  .replace(/\r/g, "\\r");
108
108
 
109
- // 3️⃣ Split into chunks
109
+ // 3️⃣ Convert to Buffer (UTF-8)
110
+ const buffer = Buffer.from(escapedMessage, "utf8");
111
+
112
+ // 4️⃣ Split into BYTE chunks
110
113
  const chunks = [];
111
- for (let i = 0; i < escapedMessage.length; i += MAX_CHUNK_SIZE) {
112
- chunks.push(escapedMessage.slice(i, i + MAX_CHUNK_SIZE));
114
+ for (let i = 0; i < buffer.length; i += MAX_CHUNK_BYTES) {
115
+ chunks.push(buffer.subarray(i, i + MAX_CHUNK_BYTES).toString("utf8"));
113
116
  }
114
-
115
117
  console.log(
116
- `BrowserStack Annotation → total chars: ${escapedMessage.length}, chunks: ${chunks.length}`
118
+ `BrowserStack Annotation → total bytes: ${buffer.length}, chunks: ${chunks.length}`
117
119
  );
118
120
 
119
- // 4️⃣ Print + send chunks
121
+ // 5️⃣ Print + send each chunk
120
122
  for (let i = 0; i < chunks.length; i++) {
121
123
  const chunkMessage =
122
124
  chunks.length > 1
@@ -131,7 +133,7 @@ async function amend2Browserstack(annotationMessage, level) {
131
133
 
132
134
  // 🚀 SEND TO BROWSERSTACK (WDIO-safe)
133
135
  if (process.env.PLATFORM === "browserstack") {
134
- await driver.executeScript(
136
+ await driver.execute(
135
137
  `browserstack_executor: {"action":"annotate","arguments":{"data":"${chunkMessage}","level":"${level}"}}`
136
138
  );
137
139
  }
@@ -143,44 +145,6 @@ async function amend2Browserstack(annotationMessage, level) {
143
145
  }
144
146
 
145
147
 
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
148
 
185
149
 
186
150
  module.exports = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "froth-webdriverio-framework",
3
- "version": "7.0.8",
3
+ "version": "7.0.10",
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": {