一个问题引发的LoadRunner9.5脚本

本文通过具体案例展示了如何使用LoadRunner 9.5进行网站性能测试。包括了测试脚本的编写过程,发送自定义请求的方法,以及如何模拟用户行为进行多次数据提交等关键步骤。

问题来源:http://topic.youkuaiyun.com/u/20091018/17/a04b1ab8-57af-42e8-a6b1-48413c6da1c3.html?53659

 

我用LoadRunner9.5实现了一下,下面是action中的代码

 

ContractedBlock.gif ExpandedBlockStart.gif Loadrunner Script

   
Action()
{

int m,n;
char leon[ 512 ];
int leon1;
web_url(
" www.fjgsgl.com " ,
" URL=http://www.fjgsgl.com/ " ,
" TargetFrame= " ,
" Resource=0 " ,
" RecContentType=text/html " ,
" Referer= " ,
" Snapshot=t1.inf " ,
" Mode=HTML " ,
EXTRARES,
" URL=/focus.swf " ,ENDITEM,
" URL=/main.files/105x75.jpg " ,ENDITEM,
" URL=/main.files/fqgs002.gif " ,ENDITEM,
" URL=/main.files/fqgs001.jpg " ,ENDITEM,
" URL=/Foosun_Plus/Ads/CreateJs/RightBottom.js " ,ENDITEM,
LAST);

web_custom_request(
" urs.asmx " ,
" URL=https://urs.microsoft.com/urs.asmx?MSPRU-Client-Key=S4uXVHsMw2lMYlhTRRlyXA%3d%3d&MSPRU-Patented-Lock=ts5iAr%2b/rnw%3d " ,
" Method=POST " ,
" TargetFrame= " ,
" Resource=0 " ,
" RecContentType=text/xml " ,
" Referer= " ,
" Snapshot=t2.inf " ,
" Mode=HTML " ,
" EncType=text/xml;charset=utf-8 " ,
" Body= <soap:Envelope xmlns:soap=\ " http: // schemas.xmlsoap.org/soap/envelope/\ " xmlns:xsi=\ " http://www.w3.org/2001/XMLSchema-instance \ " xmlns:xsd=\ " http://www.w3.org/2001/XMLSchema \ " xmlns:soapenc=\ " http://schemas.xmlsoap.org/soap/encoding/ \ "> <soap:Body> <Lookup xmlns=\ " http://Microsoft.STS.STSWeb/ \ "> <r soapenc:arrayType=\ "xsd:string[1]\ "> <string> http://www.fjgsgl.com </string> </r> <ID> {A0AB7674-8D67-4F4D-B5E1-96FAEADFB79D} </ID> <v soapenc:arrayType=\ "xsd:string[5]\ "> <string> 7.0.6004.6 </string> <string> 7.00.6000.16730 </string> <string> 7.0.5730.13 </string> <string> 5.1.2600.2.0 </string> <string> zh-cn </string> </v> </Lookup> </soap:Body> </soap:Envelope> ",
LAST);

web_custom_request(
" urs.asmx_2 " ,
" URL=https://urs.microsoft.com/urs.asmx?MSPRU-Client-Key=uOt2PA6dKVA1gk9vIGgXLg%3d%3d&MSPRU-Patented-Lock=OaIDEoRE/yI%3d " ,
" Method=POST " ,
" TargetFrame= " ,
" Resource=0 " ,
" RecContentType=text/xml " ,
" Referer= " ,
" Snapshot=t3.inf " ,
" Mode=HTML " ,
" EncType=text/xml;charset=utf-8 " ,
" Body= <soap:Envelope xmlns:soap=\ " http: // schemas.xmlsoap.org/soap/envelope/\ " xmlns:xsi=\ " http://www.w3.org/2001/XMLSchema-instance \ " xmlns:xsd=\ " http://www.w3.org/2001/XMLSchema \ " xmlns:soapenc=\ " http://schemas.xmlsoap.org/soap/encoding/ \ "> <soap:Body> <Lookup xmlns=\ " http://Microsoft.STS.STSWeb/ \ "> <r soapenc:arrayType=\ "xsd:string[1]\ "> <string> http://www.fjgsgg.com/zfbz.asp </string> </r> <ID> {A0AB7674-8D67-4F4D-B5E1-96FAEADFB79D} </ID> <v soapenc:arrayType=\ "xsd:string[5]\ "> <string> 7.0.6004.6 </string> <string> 7.00.6000.16730 </string> <string> 7.0.5730.13 </string> <string> 5.1.2600.2.0 </string> <string> zh-cn </string> </v> </Lookup> </soap:Body> </soap:Envelope> ",
EXTRARES,
" URL=http://www.fjgsgl.com/files/2009/60.jpg " , " Referer=http://www.fjgsgl.com/focus.swf " ,ENDITEM,
" URL=http://www.fjgsgl.com/Files/2009/DSC00600.JPG " , " Referer=http://www.fjgsgl.com/focus.swf " ,ENDITEM,
" URL=http://www.fjgsgl.com/Files/W020080103316475157468.jpg " , " Referer=http://www.fjgsgl.com/focus.swf " ,ENDITEM,
" URL=http://www.fjgsgl.com/Files/kxfzg090328.jpg " , " Referer=http://www.fjgsgl.com/focus.swf " ,ENDITEM,
" URL=http://www.fjgsgl.com/Files/slogan1024.jpg " , " Referer=http://www.fjgsgl.com/focus.swf " ,ENDITEM,
" URL=http://www.fjgsgl.com/main.files/lihoulin400x215.jpg " , " Referer=http://www.fjgsgl.com/focus.swf " ,ENDITEM,
LAST);

web_url(
" show.asp " ,
" URL=http://www.fjgsgl.com/Foosun_Plus/Ads/show.asp?Location=5 " ,
" TargetFrame= " ,
" Resource=0 " ,
" RecContentType=text/html " ,
" Referer=http://www.fjgsgl.com/ " ,
" Mode=HTML " ,
LAST);

/* 页面显示完毕
*/

lr_think_time(
48 );
for (m = 1 ;m <= 10 ;m ++ )
{
lr_save_string( lr_eval_string(
" {name1} " ), " tmp " );
for (n = 1 ;n <= 10 ;n ++ )
{
web_reg_save_param(
" leon " , " LB=距离为 " , " RB=公里 " ,LAST);
lr_message(
" value:%s " ,lr_eval_string( " {leon} " ));
web_submit_data(
" zfbz.asp " ,
" Action=http://www.fjgsgg.com/zfbz.asp?zf=submit " ,
" Method=POST " ,
" TargetFrame= " ,
" RecContentType=text/html " ,
" Referer=http://www.fjgsgg.com/zfbz.asp " ,
" Snapshot=t4.inf " ,
" Mode=HTML " ,
ITEMDATA,
" Name=names1 " , " Value={tmp} " ,ENDITEM,
" Name=names2 " , " Value={name2} " ,ENDITEM,
" Name=B1 " , " Value=查询 " ,ENDITEM,LAST);
leon1
= ( int )fopen( " C:\\huoyanming.txt " , " at+ " );
fprintf(leon1,
" 从%s到%s距离为%s公里\n " ,lr_eval_string( " {name1} " ),lr_eval_string( " {name2} " ),lr_eval_string( " {leon} " ));
fclose();
}
}

/* 查询完毕
*/

return 0 ;
}

 

 

运行结果:

从2102到7103距离为20.886公里
从2103到7105距离为541.961公里
从2104到7107距离为566.832公里
从2301到7302距离为594.659公里
从2302到7305距离为628.579公里
从2303到7103距离为20.886公里
从2304到7105距离为541.961公里
从2501到7107距离为566.832公里
从2502到7302距离为594.659公里
从2304到7305距离为628.579公里
从2103到7103距离为99.301公里
从2104到7105距离为620.376公里
从2301到7107距离为645.247公里
从2302到7302距离为673.074公里
从2303到7305距离为706.994公里
从2304到7103距离为99.301公里
从2501到7105距离为620.376公里
从2502到7107距离为645.247公里
从2304到7302距离为673.074公里
从2102到7305距离为706.994公里
从2104到7103距离为92.388公里
从2301到7105距离为613.463公里
从2302到7107距离为638.334公里
从2303到7302距离为666.161公里
从2304到7305距离为700.081公里
从2501到7103距离为92.388公里
从2502到7105距离为613.463公里
从2304到7107距离为638.334公里
从2102到7302距离为666.161公里
从2103到7305距离为700.081公里
从2301到7103距离为75.593公里
从2302到7105距离为596.668公里
从2303到7107距离为621.539公里
从2304到7302距离为649.366公里
从2501到7305距离为683.286公里
从2502到7103距离为75.593公里
从2304到7105距离为596.668公里
从2102到7107距离为621.539公里
从2103到7302距离为649.366公里
从2104到7305距离为683.286公里
从2302到7103距离为59.825公里
从2303到7105距离为580.9公里
从2304到7107距离为605.771公里
从2501到7302距离为633.598公里
从2502到7305距离为667.518公里
从2304到7103距离为59.825公里
从2102到7105距离为580.9公里
从2103到7107距离为605.771公里
从2104到7302距离为633.598公里
从2301到7305距离为667.518公里
从2303到7103距离为47.778公里
从2304到7105距离为568.853公里
从2501到7107距离为593.724公里
从2502到7302距离为621.551公里
从2304到7305距离为655.471公里
从2102到7103距离为47.778公里
从2103到7105距离为568.853公里
从2104到7107距离为593.724公里
从2301到7302距离为621.551公里
从2302到7305距离为655.471公里
从2304到7103距离为36.35公里
从2501到7105距离为557.425公里
从2502到7107距离为582.296公里
从2304到7302距离为610.123公里
从2102到7305距离为644.043公里
从2103到7103距离为36.35公里
从2104到7105距离为557.425公里
从2301到7107距离为582.296公里
从2302到7302距离为610.123公里
从2303到7305距离为644.043公里
从2501到7103距离为20.886公里
从2502到7105距离为541.961公里
从2304到7107距离为566.832公里
从2102到7302距离为594.659公里
从2103到7305距离为628.579公里
从2104到7103距离为20.886公里
从2301到7105距离为541.961公里
从2302到7107距离为566.832公里
从2303到7302距离为594.659公里
从2304到7305距离为628.579公里
从2502到7103距离为38.38公里
从2304到7105距离为559.455公里
从2102到7107距离为584.326公里
从2103到7302距离为612.153公里
从2104到7305距离为646.073公里
从2301到7103距离为38.38公里
从2302到7105距离为559.455公里
从2303到7107距离为584.326公里
从2304到7302距离为612.153公里
从2501到7305距离为646.073公里
从2304到7103距离为24.22公里
从2102到7105距离为545.295公里
从2103到7107距离为570.166公里
从2104到7302距离为597.993公里
从2301到7305距离为631.913公里
从2302到7103距离为24.22公里
从2303到7105距离为545.295公里
从2304到7107距离为570.166公里
从2501到7302距离为597.993公里
从2502到7305距离为631.913公里

转载于:https://www.cnblogs.com/leon_2007/archive/2010/02/21/1670505.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值