Thursday, January 08, 2009

Loadrunner download PDF file into local

参考了Motevich'sblog,today solve one issue using Loadrunner to download PDF file into local or just read it in stream:

*fp=fopen("c:\\temp\\my_file.pdf","wb");

web_set_max_html_param_len("1000");
web_reg_save_param("PDFlink",
"LB=reporting.cgi/",
"RB=\"",
"Ord=1",
"RelFrameId=1",
"Search=Body",
"IgnoreRedirections=Yes",
LAST);

web_submit_form("reporting.cgi_13",
"Action=/cgi-bin/reporting.cgi",
//"Snapshot=t13.inf",
ITEMDATA,
LAST);

web_set_max_html_param_len("300000");

web_reg_save_param("PDF_content",
"LB=",
"RB=",
"Search=Body",
LAST);

web_url("PDFparser",
"URL={servername}/cgi-bin/reporting.cgi/{PDFlink}",
LAST);

lr_eval_string_ext("{PDF_content}",strlen("{PDF_content}"),&data,&prmLen,0,0,-1);

*fwrite(data,prmLen,1,fp);

*fclose(fp);

lr_output_message("123456: %s", lr_eval_string("{PDF_content}"));

代码前边加星号是指如果不想download到本地可以省略.

No comments:

Post a Comment