Posts tagged ‘How to capture and save file’

How to capture and save file on local machine in VuGen LoadRunner

As we know LoadRunner does not recognize the Client side activities, so the activity of saving file on local machine will not be recorded by LoadRunner. Below is the one way to resolve this.

Just before the URL which opens the PDF, capture the whole page into a string through correlation and write the captured string into a PDF file using File handling.

Sample Code:

Code Captures the PDF value in variable – c_PDF_Data

[cc lang=”c”]

char * filename = “c:\\PerfTuit.pdf”;
long File_Size;
long Download_time;
long HttpRetCode;
long file;
int flag;

/*Set the parameter size large enough to save the data.*/


/*Mention left and right boundary as blank of web_reg_save_param function to capture the pdf returned by the server.*/

web_reg_save_param(“c_PDF_Data “,”LB=”,”RB=”,”Search=Body”,LAST);

/*get the loading of PDF status in flag */


“Action=http://{p_SampleURL}/subDomain/area/ PerfTuit.aspx”,








lr_error_message(“status fail”);



/* we have captured the pdf file into string, Now we will write the captured string into the PDF file.*/

/*First we will save the size of downloaded file into variable named sizePDF*/

File_Size= web_get_int_property(HTTP_INFO_DOWNLOAD_SIZE);

/* other details*/

Download_time = web_get_int_property( HTTP_INFO_DOWNLOAD_TIME );

HttpRetCode = web_get_int_property( HTTP_INFO_RETURN_CODE );

lr_output_message(“File size is %d “,  File_Size);

lr_output_message(“Download Time is %d “,  Download_time);

lr_output_message(“HTTP Return Code is %d “,  HttpRetCode);

/*Write the string captured into file.*/
if ((file = fopen(filename, “w+”)) == NULL) {

lr_output_message (“Unable to create %s”, filename);

return -1;

fwrite(lr_eval_string(“{c_PDF_Data}”), File_Size, 1, file);