Labels

Saturday, October 19, 2013

Get Downloaded File Size And Time In VUGEN

There might be the situations you come across where you have to download the PDF, excels, any report while scripting and need to measure its donwload time and size of the downloaded file. Normally, vugen do not record any requests for downloading or opening an PDF, excel or any report in file formats. The only way I hae come across is to use web_get_int_porperty().This function can be used after the request where you perform the action for downloading or opening an file.The proper place can be identified by entering the comments in the script while recording. We can pass few constants as parameter to this function which will give the download time in milliseconds and file size in bytes.

 i = web_get_int_property(HTTP_INFO_DOWNLOAD_TIME); //returns time in milliseconds to download file
  j = web_get_int_property(HTTP_INFO_DOWNLOAD_SIZE); //returns size in Bytes for downloaded file
To record download time and size for each iteration per vuserwe can implement file writing code in our scripts to log the same in custom way.

  lr_output_message("The download time of the PDF was: %d milliseconds",i);
  lr_output_message("The download size of the PDF file was: %d Bytes",j);

 web_save_timestamp_param("pEndTime",LAST);
 lr_think_time(x);
 if ((fp = fopen(filename, "a+")) == NULL) {
 lr_error_message("Unable to create %s", filename);
return -1;
}
else
{
 fprintf( fp,
  "%s,%s,",i,j,);
 }
 fclose( fp );

No comments:

Post a Comment