Page tree
Skip to end of metadata
Go to start of metadata

Last updated: Aug 11, 2021 18:34

Note: The Java utility presented here has been developed to help manual and performance testers to install a HAR certificate on the device and capture and download the transactional network traffic, but it is not a Perfecto product. Rather, it is an example of how you can leverage underlying Perfecto functionality

An HTTP Archive (HAR) file is a JSON-formatted archive file format for logging an application’s (either browser or a native/hybrid app) interaction with HTTP servers. The HAR file format is an evolving standard, and the information contained within it is both flexible and extensible. You can expect a HAR file to include a breakdown of timings, including:

  • How long it takes to fetch DNS information.
  • How long each object takes to be requested.
  • How long it takes to connect to the server.
  • How long it takes to transfer assets from the server to the browser of each object.

See Set up HAR files for mobile testing to install a HAR certificate and capture the network traffic via automation.

With the HAR Capture Java utility, you can work on a real device in the Perfecto UI. While manually navigating through the different screens of an application, you can use the tool to capture the transactional network traffic along with the HAR certificate installation on the device. The tool will download the HAR reports to the given location. Alternatively, you can also download the HAR reports from Perfecto reports post-execution.

Note: Please download the utility periodically, as utility will be updated\extended based on users feedback

Prerequisites

Using the sample Java utility requires the following:

1 | Install and run the Java utility

The following procedure walks you through installing and running the Java utility.

To install and run the Java utility:

  1. Download the compressed utility file.
  2. Extract the downloaded zip file.
  3. In a command-line window, navigate to the folder that contains the extracted files.
  4. Execute the following command:

    java -jar <<JARNAME.jar>>

    For example:

    java -jar JavaPerfectoHARUtility.jar

    This should bring up the Java utility window.

2 | Use the Java utility to capture network traffic

You can use the Java utility to test mobile and web applications. Continue with the steps relevant to you.

Install a HAR certificate

Note: Clear the browser cache on the device before performing the following steps in the Java utility.

This procedure walks you through using the sample Java utility to set up up HAR files for mobile testing before attempting to capture mobile network traffic of web or mobile applications. You can also view this (soundless) video to follow along.


To install a HAR certificate: 

  1. Log in to your Perfecto cloud and open the device in the Manual Testing view.
  2. In the Java utility, provide the following required details:
    • Perfecto Cloud URL: Your cloud URL, for example https://demo.app.perfectomobile.com.
    • User Security Token: Your security token for the Perfecto cloud. See also Generate a Perfecto security token.
    • Device Session ID: The session ID as copied from the device in the Perfecto cloud. For more information, see Share a session with an IDE script.

    • Transaction Name: A meaningful name for the current screen, such as AndroidCertificateInstall.
    • Output Folder: The local folder to which to download and where to store HAR reports.
    • Proxy: Select if you need to connect through a proxy to enable the Proxy Host and Proxy Port. Then provide the required information. For more information, see Identify proxy host and proxy port through Netstat. If your proxy requires credentials, provide them in the User Name and Password fields.
  3. Click Install Certificate.

  4. Wait for the confirmation and click OK.
  5. Following the instructions in the install wizard. For more details, follow the instructions in Set up HAR Files for mobile testing.
  6. When the certificate is successfully installed on the device, click Finish.
    The configured device is now ready to capture transactional network traffic.
Capture transactional network traffic

Notes

  • The following steps apply to web and mobile applications. 
  • Before capturing the traffic of a native or hybrid application, make sure the application allows 3rd-party software to capture the traffice. For details, contact your developer.

This procedure walks you through using the sample Java utility to capture mobile network traffic of web or mobile applications. You can also view this (soundless) video to follow along.


To capture transactional network traffic:

  1. Log in to your Perfecto cloud and open the device in the Manual Testing view.
  2. In the Java utility, provide the following required details:
    • Perfecto Cloud URL: Your cloud URL, for example, https://demo.app.perfectomobile.com.
    • User Security Token: Your security token for the Perfecto cloud. See also Generate a Perfecto security token.
    • Device Session ID: The session ID as copied from the device in the Perfecto cloud. For more information, see Share a session with an IDE script.

    • Transaction Name: A meaningful name for the current screen, such as AndroidLaunchApp.
    • Output Folder: The local folder to which to download and where to store HAR reports.
    • Proxy: Select if you need to connect through a proxy to enable the Proxy Host and Proxy Port. Then provide the required information. For more information, see Identify proxy host and proxy port through Netstat. If your proxy requires credentials, provide them in the User Name and Password fields.
  3. Click Start. An information message displays.

  4. Click OK to close the message. A progress bar indicates the progress of the installation. When done, a success message displays.

  5. Click OK to close the message.
  6. Perform transation operation on the device. When done, click Stop. A success message appears.

  7. Click OK to close the message.
  8. Repeat these steps for each transaction you want to capture. Make sure to update the Transation Field each time. For example, if you already captured the laucnh app flow and want to capture the login flow, enter AndroidLoginApp as a transation name, as shown in the following image.

To download the HAR file:

  1. Close the device.
  2. Click Download HAR.
  3. To confirm that the device is close, click Yes.

    The Java Utility automatically downloads the HAR file with the values provided in the Transaction Name field into the selected output directory. When the report generation is complete, a success message displays. 

  4. Click OK to close the message.
  5. Navigate to the output folder. A subfolder exists for each transaction captured. Each transaction folder contains a .zip file that includes the .har file.

  6. Extract the .zip file and load any available HAR viewer for analysis. The following sample image schos http://www.softwareishard.com/har/viewer/.

  • No labels