Skip to content

LoadRunner File Download Scenario

LoadRunner File Download Scenario

Problem:

  • How to handle the File Download Scenario in LoadRunner?
    OR
  • How to capture the File Download Time in LoadRunner?

Explanation:

Hope, you know that VuGen does not capture client-side activity such as browsing a location in a pop-up, selecting a file from the local system, etc. Such limitations restrict a performance tester from simulating the file download scenario in LoadRunner.

Although he can easily record the file download step while script recording through VuGen, when he replays the script then VuGen does not calculate the correct response time to download the file.

Solution:

Indeed, you can not download the file in the actual format and save it on the local machine during the script replay or test execution. Instead of that, LoadRunner allows you to get the file in the raw data form. Thus, you can capture 2 things:

  1. Size of the File (The amount of data coming in the response): It signifies that the file contents are being transferred from the server to the client.
  2. Time to download the File: It helps to find out the time to virtually download a file.

Write the code below in your script to create the File Download Scenario:

//Firstly defined below variables at the top in Action.c

long Download_Size=0;
float Download_Time=0;
//Write below code after web_submit() - where you click to browse the location and download the file

lr_start_transaction("File_Download_Scenario");
Download_Size= web_get_int_property(HTTP_INFO_DOWNLOAD_SIZE);
Download_Time= web_get_int_property(HTTP_INFO_DOWNLOAD_TIME);
lr_output_message("Downloaded File Size is: %.2ld Bytes", Download_Size);
lr_output_message("File Download size is: %.2ld KB", Download_Size /1024);
lr_output_message("File Download Time is:%.2f Seconds",Download_Time / 1000);
lr_end_transaction ("File_Download_Scenario", LR_AUTO);

Example:

Action()
{
      long Download_Size=0;
      float Download_Time=0;
      ........
      ........
      ........
      ........

      web_submit(){
            .......
            .......
      }

      lr_start_transaction("File_Download_Scenario");
      Download_Size= web_get_int_property(HTTP_INFO_DOWNLOAD_SIZE);
      Download_Time= web_get_int_property(HTTP_INFO_DOWNLOAD_TIME);
      lr_output_message("Downloaded File Size is: %.2ld Bytes", Download_Size);
      lr_output_message("File Download size is: %.2ld KB", Download_Size /1024);
      lr_output_message("File Download Time is:%.2f Seconds",Download_Time / 1000);
      lr_end_transaction ("File_Download_Scenario", LR_AUTO);

}

You may be interested: