|
| 1 | +--- |
| 2 | +id: extended-debugging-options |
| 3 | +title: Extended Debugging Options for Selenium Testing |
| 4 | +hide_title: false |
| 5 | +sidebar_label: Extended Debugging Options |
| 6 | +description: Learn how to use Extended Debugging Options on LambdaTest to intercept network requests, throttle CPU and network conditions, capture console logs, and download HAR files for advanced test debugging and performance analysis. |
| 7 | +keywords: |
| 8 | +- extended debugging options |
| 9 | +- selenium debugging |
| 10 | +- intercept network requests |
| 11 | +- throttle cpu selenium |
| 12 | +- throttle network selenium |
| 13 | +- har file download |
| 14 | +- selenium console logs |
| 15 | +url: https://www.lambdatest.com/support/docs/extended-debugging-options/ |
| 16 | +site_name: LambdaTest |
| 17 | +slug: extended-debugging-options/ |
| 18 | +--- |
| 19 | + |
| 20 | +LambdaTest's Extended Debugging Options provide powerful capabilities to debug and optimize your Selenium tests by giving you granular control over network behavior, system performance, and diagnostic data collection. These advanced debugging features allow you to intercept and modify network requests, simulate various CPU and network conditions, capture detailed console logs, and download comprehensive network analysis files—all within your test automation workflow. |
| 21 | + |
| 22 | +With Extended Debugging Options, you can replicate real-world scenarios such as slow networks, resource-constrained devices, API failures, and connectivity issues, ensuring your application delivers a robust user experience across diverse conditions and environments. |
| 23 | + |
| 24 | +## How can Extended Debugging Options help you? |
| 25 | + |
| 26 | +Extended Debugging Options on LambdaTest provide comprehensive capabilities for advanced testing and debugging scenarios: |
| 27 | + |
| 28 | +- **Network Request Control**: Intercept and modify outgoing requests to test API failures, redirects, and mock responses without setting up complex backend infrastructure. |
| 29 | +- **Performance Testing**: Simulate various CPU and network throttling conditions to understand how your application performs on low-end devices or poor network connections. |
| 30 | +- **Enhanced Debugging**: Capture console logs in real-time to identify JavaScript errors and warnings during test execution. |
| 31 | +- **Network Analysis**: Download HAR (HTTP Archive) files to perform detailed analysis of network traffic, load times, and resource optimization. |
| 32 | +- **Realistic Test Scenarios**: Create test conditions that mirror real-world user experiences, including offline modes, slow connections, and server errors. |
| 33 | + |
| 34 | +## Available Extended Debugging Methods |
| 35 | + |
| 36 | +LambdaTest supports the following extended debugging methods: |
| 37 | + |
| 38 | +| Method | Description | |
| 39 | +|--------|-------------| |
| 40 | +| `lt:intercept` | Intercept and modify network requests | |
| 41 | +| `lt:throttleCPU` | Simulate different CPU performance levels | |
| 42 | +| `lt:throttleNetwork` | Configure and simulate network conditions | |
| 43 | +| `lt:log` | Capture JavaScript console logs | |
| 44 | +| `lt:downloadHAR` | Download HTTP Archive files for analysis | |
| 45 | + |
| 46 | +--- |
| 47 | + |
| 48 | +## 1. Intercept Network Requests |
| 49 | + |
| 50 | +The `lt:intercept` method allows you to intercept and modify network requests, enabling you to test how your application behaves under different network conditions, mock API responses, and simulate error scenarios. |
| 51 | + |
| 52 | +### Parameters |
| 53 | + |
| 54 | +| Parameter | Type | Required | Description | |
| 55 | +|-----------|------|----------|-------------| |
| 56 | +| `url` | String | Yes | URL pattern to intercept. Wildcards (*) are supported. | |
| 57 | +| `redirect` | String | No | Redirect the request to a different URL. | |
| 58 | +| `response` | Object | No | Mock the response with custom headers and body. | |
| 59 | +| `error` | String | No | Inject an error response. Supported values: `Failed`, `Aborted`, `TimedOut`, `AccessDenied`, etc. | |
| 60 | + |
| 61 | +### Method 1: Redirect Requests |
| 62 | + |
| 63 | +Redirect outgoing requests to a different URL using `lt:intercept` with the `redirect` parameter. |
| 64 | + |
| 65 | +**Example Request:** |
| 66 | + |
| 67 | +```json |
| 68 | +{ |
| 69 | + "command": "lt:intercept", |
| 70 | + "parameters": { |
| 71 | + "url": "https://example.com/api/*", |
| 72 | + "redirect": "https://mock-server.com/api/v1" |
| 73 | + } |
| 74 | +} |
| 75 | +``` |
| 76 | + |
| 77 | +**Example Response:** |
| 78 | + |
| 79 | +```json |
| 80 | +{ |
| 81 | + "status": "success", |
| 82 | + "message": "Requests to 'https://example.com/api/*' will be redirected to 'https://mock-server.com/api/v1'" |
| 83 | +} |
| 84 | +``` |
| 85 | + |
| 86 | +### Method 2: Mock Response |
| 87 | + |
| 88 | +Mock a custom response for the intercepted URL using `lt:intercept` with the `response` parameter. |
| 89 | + |
| 90 | +**Example Request:** |
| 91 | + |
| 92 | +```json |
| 93 | +{ |
| 94 | + "command": "lt:intercept", |
| 95 | + "parameters": { |
| 96 | + "url": "https://example.com/api/todos", |
| 97 | + "response": { |
| 98 | + "headers": { |
| 99 | + "Content-Type": "application/json" |
| 100 | + }, |
| 101 | + "body": [{ |
| 102 | + "title": "Test ToDo", |
| 103 | + "completed": false |
| 104 | + }] |
| 105 | + } |
| 106 | + } |
| 107 | +} |
| 108 | +``` |
| 109 | + |
| 110 | +**Example Response:** |
| 111 | + |
| 112 | +```json |
| 113 | +{ |
| 114 | + "status": "success", |
| 115 | + "message": "Mock response configured for 'https://example.com/api/todos'" |
| 116 | +} |
| 117 | +``` |
| 118 | + |
| 119 | +### Method 3: Simulate Error Response |
| 120 | + |
| 121 | +Inject error responses to test how your application handles failures using `lt:intercept` with the `error` parameter. |
| 122 | + |
| 123 | +**Example Request:** |
| 124 | + |
| 125 | +```json |
| 126 | +{ |
| 127 | + "command": "lt:intercept", |
| 128 | + "parameters": { |
| 129 | + "url": "https://example.com/images/*", |
| 130 | + "error": "Failed" |
| 131 | + } |
| 132 | +} |
| 133 | +``` |
| 134 | + |
| 135 | +**Example Response:** |
| 136 | + |
| 137 | +```json |
| 138 | +{ |
| 139 | + "status": "success", |
| 140 | + "message": "Error 'Failed' configured for 'https://example.com/images/*'" |
| 141 | +} |
| 142 | +``` |
| 143 | + |
| 144 | +:::info Supported Error Types |
| 145 | +Common error types include: `Failed`, `Aborted`, `TimedOut`, `AccessDenied`, `ConnectionClosed`, `ConnectionReset`, `InternetDisconnected`, `NameNotResolved`, and more. |
| 146 | +::: |
| 147 | + |
| 148 | +--- |
| 149 | + |
| 150 | +## 2. Throttle CPU Performance |
| 151 | + |
| 152 | +The `lt:throttleCPU` method simulates lower or higher CPU usage on the testing device, allowing you to measure your application's performance under resource constraints. |
| 153 | + |
| 154 | +### Parameters |
| 155 | + |
| 156 | +| Parameter | Type | Required | Description | |
| 157 | +|-----------|------|----------|-------------| |
| 158 | +| `rate` | Integer | Yes | Rate of slowdown. Example: `2` equals 2x slowdown, `4` equals 4x slowdown. | |
| 159 | + |
| 160 | +### How to Use |
| 161 | + |
| 162 | +**Example Request:** |
| 163 | + |
| 164 | +```json |
| 165 | +{ |
| 166 | + "command": "lt:throttleCPU", |
| 167 | + "parameters": { |
| 168 | + "rate": 3 |
| 169 | + } |
| 170 | +} |
| 171 | +``` |
| 172 | + |
| 173 | +**Example Response:** |
| 174 | + |
| 175 | +```json |
| 176 | +{ |
| 177 | + "status": "success", |
| 178 | + "message": "CPU throttled to 3x slowdown." |
| 179 | +} |
| 180 | +``` |
| 181 | + |
| 182 | +:::info CPU Throttling Rates |
| 183 | +- A rate of `1` means no throttling (normal CPU performance) |
| 184 | +- A rate of `2` means 2x slower than normal |
| 185 | +- A rate of `4` means 4x slower than normal |
| 186 | +- Higher values simulate lower-end devices or heavy CPU load scenarios |
| 187 | +::: |
| 188 | + |
| 189 | +--- |
| 190 | + |
| 191 | +## 3. Throttle Network Conditions |
| 192 | + |
| 193 | +The `lt:throttleNetwork` method enables you to simulate various network conditions including slower speeds, high latency, and offline modes. This helps ensure your application performs well across different connection types. |
| 194 | + |
| 195 | +### Parameters |
| 196 | + |
| 197 | +| Parameter | Type | Required | Description | |
| 198 | +|-----------|------|----------|-------------| |
| 199 | +| `condition` | String/Object | Yes | Predefined network profile (e.g., `GPRS`, `3G`, `4G`) or custom configuration object. | |
| 200 | +| `download` | Integer | No | Download speed in kb/s (used with custom configuration). | |
| 201 | +| `upload` | Integer | No | Upload speed in kb/s (used with custom configuration). | |
| 202 | +| `latency` | Integer | No | Round Trip Time (RTT) in milliseconds (used with custom configuration). | |
| 203 | + |
| 204 | +### Custom Network Configuration |
| 205 | + |
| 206 | +**Example Request:** |
| 207 | + |
| 208 | +```json |
| 209 | +{ |
| 210 | + "command": "lt:throttleNetwork", |
| 211 | + "parameters": { |
| 212 | + "condition": { |
| 213 | + "download": 1000, |
| 214 | + "upload": 500, |
| 215 | + "latency": 40 |
| 216 | + } |
| 217 | + } |
| 218 | +} |
| 219 | +``` |
| 220 | + |
| 221 | +**Example Response:** |
| 222 | + |
| 223 | +```json |
| 224 | +{ |
| 225 | + "status": "success", |
| 226 | + "message": "Network conditions set with 1000 kb/s download, 500 kb/s upload, and 40 ms latency." |
| 227 | +} |
| 228 | +``` |
| 229 | + |
| 230 | +### Predefined Network Profiles |
| 231 | + |
| 232 | +LambdaTest provides predefined network profiles for quick testing across common connection types: |
| 233 | + |
| 234 | +| Profile | Download Speed | Upload Speed | Latency (ms) | |
| 235 | +|---------|----------------|--------------|--------------| |
| 236 | +| `offline` | 0 kb/s | 0 kb/s | 0 | |
| 237 | +| `GPRS` | 50 kb/s | 20 kb/s | 500 | |
| 238 | +| `Regular 2G` | 250 kb/s | 50 kb/s | 300 | |
| 239 | +| `Good 2G` | 450 kb/s | 150 kb/s | 150 | |
| 240 | +| `Regular 3G` | 750 kb/s | 250 kb/s | 100 | |
| 241 | +| `Good 3G` | 1 Mb/s | 750 kb/s | 40 | |
| 242 | +| `Regular 4G` | 4 Mb/s | 3 Mb/s | 20 | |
| 243 | +| `DSL` | 2 Mb/s | 1 Mb/s | 5 | |
| 244 | +| `WiFi` | 30 Mb/s | 15 Mb/s | 2 | |
| 245 | +| `online` | No Restrictions | No Restrictions | No Restrictions | |
| 246 | + |
| 247 | +**Example with Predefined Profile:** |
| 248 | + |
| 249 | +```json |
| 250 | +{ |
| 251 | + "command": "lt:throttleNetwork", |
| 252 | + "parameters": { |
| 253 | + "condition": "Regular 3G" |
| 254 | + } |
| 255 | +} |
| 256 | +``` |
| 257 | + |
| 258 | +--- |
| 259 | + |
| 260 | +## 4. Capture Console Logs |
| 261 | + |
| 262 | +The `lt:log` method captures JavaScript console logs from the browser session, helping you identify errors, warnings, and debug information during test execution. |
| 263 | + |
| 264 | +### Parameters |
| 265 | + |
| 266 | +| Parameter | Type | Required | Description | |
| 267 | +|-----------|------|----------|-------------| |
| 268 | +| `type` | String | Yes | Log type to capture. Supported values: `console`, `error`, etc. | |
| 269 | + |
| 270 | +### How to Use |
| 271 | + |
| 272 | +**Example Request:** |
| 273 | + |
| 274 | +```json |
| 275 | +{ |
| 276 | + "command": "lt:log", |
| 277 | + "parameters": { |
| 278 | + "type": "console" |
| 279 | + } |
| 280 | +} |
| 281 | +``` |
| 282 | + |
| 283 | +**Example Response:** |
| 284 | + |
| 285 | +```json |
| 286 | +{ |
| 287 | + "status": "success", |
| 288 | + "message": "Console logs captured successfully." |
| 289 | +} |
| 290 | +``` |
| 291 | + |
| 292 | +:::info Log Types |
| 293 | +- `console`: Captures all console logs including log, info, warn, and error messages |
| 294 | +- `error`: Captures only error messages for focused debugging |
| 295 | +::: |
| 296 | + |
| 297 | +--- |
| 298 | + |
| 299 | +## 5. Download HAR File |
| 300 | + |
| 301 | +The `lt:downloadHAR` method downloads network activity data in HAR (HTTP Archive) format, enabling detailed analysis of network performance, resource loading times, and HTTP transactions. |
| 302 | + |
| 303 | +### Parameters |
| 304 | + |
| 305 | +| Parameter | Type | Required | Description | |
| 306 | +|-----------|------|----------|-------------| |
| 307 | +| `job_id` | String | Yes | Unique job identifier for the test session. | |
| 308 | +| `output_file` | String | Yes | Filename to save the HAR file. | |
| 309 | + |
| 310 | +### How to Use |
| 311 | + |
| 312 | +**Example Request:** |
| 313 | + |
| 314 | +```json |
| 315 | +{ |
| 316 | + "command": "lt:downloadHAR", |
| 317 | + "parameters": { |
| 318 | + "job_id": "123456", |
| 319 | + "output_file": "network.har" |
| 320 | + } |
| 321 | +} |
| 322 | +``` |
| 323 | + |
| 324 | +**Example Response:** |
| 325 | + |
| 326 | +```json |
| 327 | +{ |
| 328 | + "status": "success", |
| 329 | + "message": "HAR file downloaded as 'network.har'." |
| 330 | +} |
| 331 | +``` |
| 332 | + |
| 333 | +:::info HAR File Analysis |
| 334 | +HAR files can be analyzed using tools like: |
| 335 | +- Chrome DevTools (Network tab → right-click → "Save all as HAR") |
| 336 | +- Online HAR analyzers |
| 337 | +- Performance monitoring tools |
| 338 | + |
| 339 | +These files contain detailed information about request/response headers, timing data, cookies, and more. |
| 340 | +::: |
| 341 | + |
| 342 | +--- |
| 343 | + |
| 344 | +## Best Practices |
| 345 | + |
| 346 | +When using Extended Debugging Options on LambdaTest, consider the following best practices: |
| 347 | + |
| 348 | +- **Use Wildcards Wisely**: When intercepting requests, use specific URL patterns to avoid unintended interceptions. |
| 349 | +- **Test Incrementally**: Start with mild throttling conditions and gradually increase constraints to identify performance breaking points. |
| 350 | +- **Combine Methods**: Use multiple methods together (e.g., network throttling + CPU throttling) to simulate realistic low-end device scenarios. |
| 351 | +- **Capture Logs Early**: Enable console log capturing at the start of your test to ensure all debug information is collected. |
| 352 | +- **Analyze HAR Files**: Download HAR files for failed tests to identify network-related issues and performance bottlenecks. |
| 353 | + |
| 354 | +By leveraging these Extended Debugging Options, you can create comprehensive test scenarios that validate your application's behavior under diverse real-world conditions, ensuring a robust and reliable user experience. |
0 commit comments