Solution 1:
First you need to try recording script from Chrome, because in chrome it did not ask for saving file , it directly open up PDF in new tab and you can use that URL as request in LR.Also you can take help from below Blog for file saving.
http://motevich.blogspot.in/2008/04/loadrunner-how-to-record-pdf-file.html.
By this activity , we were able to find "how much time it took to open that PDF"
Solution 2:
The complete code for downloading file to the local disk, calculate the download size and response time.
long fp,Download_Size=0;
float Download_Time=0;
char *data;
unsigned long prmLen;
long Download_Size=0;
//Truncate to zero length or create file for writing.
fp = fopen("c:tempmy_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",
..............................
.............................
.............................
LAST);
Download_Size= web_get_int_property(HTTP_INFO_DOWNLOAD_SIZE);
Download_Time= web_get_int_property(HTTP_INFO_DOWNLOAD_TIME);
//Get the download size.
lr_eval_string_ext("{FILED}", strlen("{FILED}"), &data, &prmLen, 0, 0, -1);
//Write the data saved to an output file.
fwrite(data, prmLen, 1, fp);
//Close the file pointer.
fclose(fp);
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);
You can use the above c script to download the .pdf/ .xls or .xlsx file.
http://www.myloadtest.com/check-pdf-files-with-loadrunner/
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, 0, 0, -1);
//Write the data saved to an output file.
fwrite(data, prmLen, 1, fp);
//Close the file pointer.
fclose(fp);
long fp,Download_Size=0;
float Download_Time=0;
char *data;
unsigned long prmLen;
long Download_Size=0;
//Truncate to zero length or create file for writing.
fp = fopen("c:tempmy_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",
..............................
.............................
.............................
LAST);
Download_Size= web_get_int_property(HTTP_INFO_DOWNLOAD_SIZE);
Download_Time= web_get_int_property(HTTP_INFO_DOWNLOAD_TIME);
//Get the download size.
lr_eval_string_ext("{FILED}", strlen("{FILED}"), &data, &prmLen, 0, 0, -1);
//Write the data saved to an output file.
fwrite(data, prmLen, 1, fp);
//Close the file pointer.
fclose(fp);
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);
You can use the above c script to download the .pdf/ .xls or .xlsx file.
http://www.myloadtest.com/check-pdf-files-with-loadrunner/
Alternative code--
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, 0, 0, -1);
//Write the data saved to an output file.
fwrite(data, prmLen, 1, fp);
//Close the file pointer.
fclose(fp);
No comments:
Post a Comment