@capillarytech/cap-ui-dev-tools 1.6.0 → 1.8.0
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/package.json
CHANGED
|
@@ -64,8 +64,6 @@ class WebdriverIOCapVisionRecorder {
|
|
|
64
64
|
/** @type {boolean} */
|
|
65
65
|
this.cdpNetworkLoggingSetup = false;
|
|
66
66
|
|
|
67
|
-
/** @type {Object<string, string>} */
|
|
68
|
-
this.requestMap = {};
|
|
69
67
|
}
|
|
70
68
|
|
|
71
69
|
/**
|
|
@@ -163,47 +161,32 @@ class WebdriverIOCapVisionRecorder {
|
|
|
163
161
|
this.browser.removeAllListeners('Network.requestWillBeSent');
|
|
164
162
|
this.browser.removeAllListeners('Network.responseReceived');
|
|
165
163
|
this.browser.removeAllListeners('Network.loadingFailed');
|
|
166
|
-
this.requestMap = {};
|
|
167
164
|
} catch (e) {
|
|
168
165
|
// Ignore errors when removing listeners
|
|
169
166
|
}
|
|
170
167
|
}
|
|
171
168
|
|
|
172
|
-
// Track requests to map requestId to URL
|
|
173
|
-
this.browser.on('Network.requestWillBeSent', (params) => {
|
|
174
|
-
const { requestId, request } = params;
|
|
175
|
-
this.requestMap[requestId] = request.url;
|
|
176
|
-
});
|
|
177
|
-
|
|
178
169
|
this.browser.on('Network.responseReceived', async (params) => {
|
|
179
170
|
const { response } = params;
|
|
180
171
|
const url = response.url;
|
|
181
|
-
const
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
const { requestId } = params;
|
|
200
|
-
const url = this.requestMap[requestId] || 'unknown';
|
|
201
|
-
const cap_requestId = params?.response?.headers['x-cap-request-id'] || 'N/A';
|
|
202
|
-
|
|
203
|
-
await this.browser.execute((url, cap_requestId) => {
|
|
204
|
-
console.log(`❌ Request failed (ID: ${cap_requestId})`, url);
|
|
205
|
-
}, url, cap_requestId);
|
|
206
|
-
|
|
172
|
+
const statusCode = response.status;
|
|
173
|
+
const cap_requestId = response.headers['x-cap-request-id'] || 'N/A';
|
|
174
|
+
|
|
175
|
+
if (statusCode >= 400) {
|
|
176
|
+
await this.browser.execute((url, cap_requestId, statusCode) => {
|
|
177
|
+
console.error(
|
|
178
|
+
'%c🔴 Network Request',
|
|
179
|
+
'color: #4CAF50; font-weight: bold; font-size: 12px;',
|
|
180
|
+
'\n 📍 URL:',
|
|
181
|
+
url,
|
|
182
|
+
'\n 🆔 Request ID:',
|
|
183
|
+
cap_requestId,
|
|
184
|
+
'\n 🔴 Status Code:',
|
|
185
|
+
statusCode,
|
|
186
|
+
'\n'
|
|
187
|
+
);
|
|
188
|
+
}, url, cap_requestId, statusCode);
|
|
189
|
+
}
|
|
207
190
|
});
|
|
208
191
|
|
|
209
192
|
this.cdpNetworkLoggingSetup = true;
|
|
Binary file
|