Friday, 15 May 2015

Loadrunner :How to record PDF file saving

long fp;
char *data;
unsigned long prmLen;

web_url("writings.html",
"URL=http://www.testing.com/writings.html",
"TargetFrame=",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t1.inf",
"Mode=HTML",
LAST);

//Truncate to zero length or create file for writing.
fp = fopen("c:\\temp\\my_file.pdf","wb");

//Set the parameter size large enough to save the data.
web_set_max_html_param_len("200000");

//Use web_reg_save_param with the correct boundary to capture the data returned by the server.
web_reg_save_param("FILED","LB=","RB=","Search=Body",LAST);

web_url("PDF",
"URL=http://www.testing.com/writings/automate.pdf",
"TargetFrame=",
"Resource=0",
"RecContentType=application/pdf",
"Referer=http://www.testing.com/writings.html",
"Snapshot=t2.inf",
"Mode=HTML",
LAST);

//Get the download size.
lr_eval_string_ext("{FILED}", strlen("{FILED}"), &data, &prmLen, 00, -1);

//Write the data saved to an output file.
fwrite(data, prmLen, 1, fp);

//Close the file pointer.
fclose(fp);

2 comments: