Network Traffic Capture is a functionality that gives you the ability to record network traffic for HTTP/HTTPS requests during Android and iOS/iPadOS mobile app tests on real devices. This provides granular insight into your app’s behavior, facilitates debugging, and helps you determine which development team is responsible for application failure.
With this feature, traffic is recorded on our side and exposes the HAR file through your test’s endpoint, producing HTTP traffic information to help you troubleshoot.
What You'll Need
- A Sauce Labs account (Log in or sign up for a free trial license)
- A native Android, iOS, or iPadOS mobile app that makes HTTP/HTTPS requests. We currently support the following:
- Android 6.0 and higher
- For Swift: iOS 11.0 and higher
- For Objective-C: iOS (all)
Using Network Traffic Capture
To enable network traffic capturing in your tests:
On Sauce Labs, click Live > Mobile App.
After you’ve uploaded your app, return to the Live > Mobile App page, hover your mouse over your app, then select Settings.
Under Default Settings, toggle Instrumentation and Network Capture to enable the feature.
For Automated Testing only: add the networkCapture capability to your test script. Click the link below corresponding to your framework:
Now you can start your live or automated testing session. Your network logs will be captured and displayed in the test results page.
Accessing HAR Files
To download HAR files from Sauce Labs:
- Navigate to Test Results.
- Select the applicable test.
- Click the Network tab in the bottom to preview network calls.
- Click the Logs tab on the right panel and select network.har from the dropdown menu to download the report.
You can also download a HAR file programmatically using the following API request:
curl --compressed \
Viewing HAR Files
You'll need a HAR viewer to read HAR files. Sauce Labs provides a React Network Viewer HAR viewer for your convenience. For step-by-step usage instructions, see our Visualize HAR Files with the New React Network Viewer blog article.
Alternatively, some other commonly used HAR viewers include:
- Chrome devtools builtin HAR imports
- Google Admin Toolbox HAR Analyzer
- Software is Hard blog HTTP Archive Viewer
- Firefox network monitoring builtin HAR imports
HTTP Archive Format (HAR) files collect all network requests and responses made and received by the browser during testing. HAR files offer useful debugging information, such as:
- Identifying browser requests that time out
- Pinpointing requests slowing down the loading process
- Locating faulty API calls
- Android Emulators
- iOS Simulators
- Hybrid Applications (React Native, Cordova, Flutter)
- Android Chrome Browser
- iOS Safari Browser
Our network capture code depends on the fact that these classes are not obfuscated:
- Network capture works if the app uses NSURLSession or a library (like Alamofire or AFNetworking) that uses NSURLSession inside.
- Calls made by NSURLConnection (deprecated by Apple), will not be captured.