Skip to main content

Network Capture

warning

Network capture are currently available on WebOS, Tizen, and tvOS only. Additional platform support will be rolled out incrementally.

Overview

Network capture for HTTP traffic is available for Appium sessions. After a capture has completed an HTTP archive (HAR) file will be available for download by members of your organization via the TV Labs sessions dashboard.

Network capture can be started in two different ways:

  • Appium capabilities
  • Appium execute method

Using Capabilities

Network capture can be enabled on session start by setting the tvlabs:log_network capability to true in the Appium session capabilities.

{
"tvlabs:constraints": {
"platform_key": "web_os"
},
"tvlabs:build": "...",
"tvlabs:log_network": true
}

Using Execute Method

Network capture can be started or stopped in a middle of a session by using an Appium execute method. The execute methods described below are available on all platforms that support network capture.

tvlabs: startNetworkCapture

Starts network capture for the current session.

warning

On non-Chromium based platforms, after starting a network capture in an application that uses HTTP keep-alive, the application may need to be re-launched to ensure any open network connections are re-established and intercepted. This can be done with the terminateApp and activateApp methods.

Arguments:

  • reload (optional, boolean)
    • Whether to reload the page after starting network capture
    • Chromium-based platforms only
    • Default: true
  • cache (optional, boolean)
    • Whether to enable or disable the page cache
    • Chromium-based platforms only
    • Default: false

Example:

// Start a network capture with defaults
await driver.execute('tvlabs: startNetworkCapture');

// Start a network capture without reloading the page
await driver.execute('tvlabs: startNetworkCapture', {
reload: false,
});

tvlabs: stopNetworkCapture

Stops network capture and finalizes the HAR file for download. If the session network capture was started using capabilities, this method may be used to stop the capture before the session ends.

Arguments: None

Example:

// Stop an already running capture
await driver.execute('tvlabs: stopNetworkCapture');

Viewing network logs

To download the HAR file for a session where network logging was enabled, navigate to the session in the TV Labs sessions dashboard. Scroll down and find the "Network Logs" section, and select the HTTP archives you wish to download.

Download network logs

note

Network logs may take a few moments to be available for download after the session ends.

There are many online tools available to view HAR files, but the easiest way is to import them into the Chrome DevTools. Open the DevTools within Chrome, select the "Network" tab, and look for the "Import HAR" button

Network logs in Chrome DevTools