Loadrunner 技巧已经整理3篇了,你个一定疑问,这些知识点,网上随处可见。确实,由于长时间没有使用这个工具,造成我的一些概念开始在大脑中模糊,我只是用这种方式来温习。

  ----------------------

  在loadrunner的虚拟用户中,术语concurrent(并发)和simultaneous(同时)存在一些区别,concurrent 是指虚拟场景中参于运行的虚拟用户。而simultaneous与集合点(rendzvous point)关系更密切,是指在同一时刻一起执行某个任务的虚拟用户。

  我们来想象一个场景,10名运动员参加长跑比赛,出发点同时起跑,他们是并排奔跑的;跑了N圈之后,因为有体能更强的,有体能稍弱的,他们的队形并排变成了前后。几乎一个跑道可以供应他们的奔跑(运行),那么其余的9条跑道是空闲的。

  为了充分的利用跑道,可以将跑道的起点设置一个集合点,当所有运动员跑完一圈后在起跑点集合,然后再同时起跑。

  运动员可以看作是虚拟用户,跑道可以看作是系统资源。设置集合点可以模式更加真实的并发请求,从而增加对系统的负载。

  下面录制一个登录触摸屏版139邮箱的脚本。录制步骤:

  1、打开登录页面

  2、插入集合点

  3、输入用户名密码,点击登录按钮

  4、登录页面加载完成,录制结束

  脚本添加集合点

  当我们在不熟悉脚本的情况下,可以通过世录制操作面板来添加集合点。

  如果你非常熟悉每一段脚本代码的作用,可以在脚本中添加:lr_rendezvous 集合点函数。

  录制代码如下:

Action()
{

    web_url("wapmail.10086.cn",
        "URL=http://wapmail.10086.cn/",
        "Resource=0",
        "RecContentType=text/html",
        "Referer=",
        "Snapshot=t19.inf",
        "Mode=HTML",
        EXTRARES,
        "Url=http://wapmail.10086.cn:8000/img/p/logo.jpg", ENDITEM,
        "Url=/favicon.ico", "Referer=", ENDITEM,
        LAST);

    web_custom_request("urs.asmx",
        "URL=https://urs.microsoft.com/urs.asmx?MSURS-Client-Key=FcIacsb4XHR0aOJzGG/quQ%3d%3d&MSURS-Patented-Lock=NGkcbdtnuEs%3d",
        "Method=POST",
        "Resource=0",
        "RecContentType=text/xml",
        "Referer=",
        "Snapshot=t20.inf",
        "Mode=HTML",
        "EncType=text/xml; charset=utf-8",
        "Body=<RepLookup v="3"><G>ED8654D5-B9F0-4DD9-B3E8-F8F560086FDF</G><O>F03F2D77-79E1-4DEC-BBF8-81A5C0790160</O><D>9.0.8110.0</D><C>9.00.8112.16421</C><OS>6.1.7601.1.0</OS><I>9.0.8112.16421</I><L>zh-CN</L><R><Rq><URL>aHR0cDovL3dhcG1haWwuMTAwODYuY24v</URL><O>POST</O><T>TOP</T><HIP>218.204.255.90</HIP></Rq><Rq><URL>aHR0cDovL3dhcG1haWwuMTAwODYuY24vaW5kZXguaHRt</URL><O>POST</O><T>ACTION</T><HIP>218.204.255.90</HIP></Rq></R></RepLookup>",
        LAST);

    web_custom_request("urs.asmx_2",
        "URL=https://urs.microsoft.com/urs.asmx?MSURS-Client-Key=C84C0w6qif5yiuTi%2bfaoMg%3d%3d&MSURS-Patented-Lock=EQjsDl4IFSQ%3d",
        "Method=POST",
        "Resource=0",
        "RecContentType=text/xml",
        "Referer=",
        "Snapshot=t21.inf",
        "Mode=HTML",
        "EncType=text/xml; charset=utf-8",
        "Body=<RepLookup v="3"><G>ED8654D5-B9F0-4DD9-B3E8-F8F560086FDF</G><O>F03F2D77-79E1-4DEC-BBF8-81A5C0790160</O><D>9.0.8110.0</D><C>9.00.8112.16421</C><OS>6.1.7601.1.0</OS><I>9.0.8112.16421</I><L>zh-CN</L><R><Rq><URL>aHR0cDovL3dhcG1haWwuMTAwODYuY24v</URL><O>PRE</O><T>TOP</T><HIP>218.204.255.90</HIP></Rq></R></RepLookup>",
        LAST);

    lr_start_transaction("登陆");  //添加事务

    lr_rendezvous("集合点");   //添加集合点

    web_submit_data("index.htm",
        "Action=http://wapmail.10086.cn/index.htm",
        "Method=POST",
        "Referer=http://wapmail.10086.cn/",
        "Mode=HTML",
        ITEMDATA,
        "Name=ur", "Value=fnngj", ENDITEM,
        "Name=pw", "Value=heng198876", ENDITEM,
        "Name=apc", "Value=0", ENDITEM,
        "Name=_swv", "Value=5", ENDITEM,
        "Name=a", "Value=3,5 ", ENDITEM,
        "Name=_fv", "Value=3", ENDITEM,
        "Name=clt", "Value=5", ENDITEM,
        LAST);

    web_submit_data("index.htm_2",
        "Action=http://wapmail.10086.cn/index.htm",
        "Method=POST",
        "RecContentType=text/html",
        "Referer=http://wapmail.10086.cn/",
        "Snapshot=t22.inf",
        "Mode=HTML",
        ITEMDATA,
        "Name=ur", "Value=XXXXX", ENDITEM,   //登陆用户名
        "Name=pw", "Value=ooooo", ENDITEM, //登陆密码
        "Name=apc", "Value=0", ENDITEM,
        "Name=_swv", "Value=5", ENDITEM,
        "Name=a", "Value=3,5 ", ENDITEM,
        "Name=_fv", "Value=3", ENDITEM,
        "Name=clt", "Value=5", ENDITEM,
        LAST);

    web_custom_request("handler",
        "URL=http://m.mail.10086.cn/wp1/w3/handler",
        "Method=POST",
        "Resource=0",
        "RecContentType=text/html",
        "Referer=http://m.mail.10086.cn/bv1/home.html?mo=U0j5GuvVaLG3Xz0qMibbQok8g34_OABo&vn=288&logintype=0&cv=3&swv=5&cli=5",
        "Snapshot=t23.inf",
        "Mode=HTML",
        "EncType=application/x-www-form-urlencoded;charset=UTF-8",
        "Body=&mo=U0j5GuvVaLG3Xz0qMibbQok8g34_OABo&vn=288&vid=&__randomNumber=1362403651558",
        EXTRARES,
        "Url=/bv1/css/public.css?vn=288", "Referer=http://m.mail.10086.cn/bv1/home.html?mo=U0j5GuvVaLG3Xz0qMibbQok8g34_OABo&vn=288&logintype=0&cv=3&swv=5&cli=5", ENDITEM,
        "Url=/bv1/js/home.js?vn=288", "Referer=http://m.mail.10086.cn/bv1/home.html?mo=U0j5GuvVaLG3Xz0qMibbQok8g34_OABo&vn=288&logintype=0&cv=3&swv=5&cli=5", ENDITEM,
        LAST);


    web_custom_request("costanalysis",
        "URL=http://m.mail.10086.cn/wp1/w3/costanalysis",
        "Method=POST",
        "Resource=0",
        "RecContentType=text/html",
        "Referer=http://m.mail.10086.cn/bv1/home.html?mo=U0j5GuvVaLG3Xz0qMibbQok8g34_OABo&vn=288&logintype=0&cv=3&swv=5&cli=5",
        "Snapshot=t24.inf",
        "Mode=HTML",
        "EncType=application/x-www-form-urlencoded;charset=UTF-8",
        "Body=&mo=U0j5GuvVaLG3Xz0qMibbQok8g34_OABo&vn=288&vid=&cmd=999&d=478&b=1&t=710&body=2&r=5&ajaxInitTime=419&ajaxCostTime=285&ajaxBeginTime=0&downBeginTime=156&initBeginTime=704&logintime=5100&homejstime=2&homeutiljstime=2&ajaxSendTime=1362403651558&redirectTime=-1&__randomNumber=1362403652268",
        EXTRARES,
        "Url=/bv1/img/global_24.png", "Referer=http://m.mail.10086.cn/bv1/home.html?mo=U0j5GuvVaLG3Xz0qMibbQok8g34_OABo&vn=288&logintype=0&cv=3&swv=5&cli=5", ENDITEM,
        "Url=/favicon.ico", "Referer=", ENDITEM,
        LAST);

    web_custom_request("urs.asmx_3",
        "URL=https://urs.microsoft.com/urs.asmx?MSURS-Client-Key=maVKmMoyQiei4%2bdFLSDDAA%3d%3d&MSURS-Patented-Lock=HitWNt%2b1Bns%3d",
        "Method=POST",
        "Resource=0",
        "RecContentType=text/xml",
        "Referer=",
        "Snapshot=t25.inf",
        "Mode=HTML",
        "EncType=text/xml; charset=utf-8",
        "Body=<RepLookup v="3"><G>ED8654D5-B9F0-4DD9-B3E8-F8F560086FDF</G><O>F03F2D77-79E1-4DEC-BBF8-81A5C0790160</O><D>9.0.8110.0</D><C>9.00.8112.16421</C><OS>6.1.7601.1.0</OS><I>9.0.8112.16421</I><L>zh-CN</L><R><Rq><URL>aHR0cDovL20ubWFpbC4xMDA4Ni5jbi9idjEvaG9tZS5odG1sP21vPVUwajVHdXZWYUxHM1h6MHFNaWJiUW9rOGczNF9PQUJvJnZuPTI4OCZsb2dpbnR5cGU9MCZjdj0zJnN3dj01JmNsaT01</URL><O>PRE</O><T>TOP</T><HIP>113.108.212.38</HIP></Rq></R></RepLookup>",
        LAST);

    web_custom_request("urs.asmx_4",
        "URL=https://urs.microsoft.com/urs.asmx?MSURS-Client-Key=r/4pztMEzQOon4ZLeymWxw%3d%3d&MSURS-Patented-Lock=a7q4TZRzKXk%3d",
        "Method=POST",
        "Resource=0",
        "RecContentType=text/xml",
        "Referer=",
        "Snapshot=t26.inf",
        "Mode=HTML",
        "EncType=text/xml; charset=utf-8",
        "Body=<RepLookup v="3"><G>ED8654D5-B9F0-4DD9-B3E8-F8F560086FDF</G><O>F03F2D77-79E1-4DEC-BBF8-81A5C0790160</O><D>9.0.8110.0</D><C>9.00.8112.16421</C><OS>6.1.7601.1.0</OS><I>9.0.8112.16421</I><L>zh-CN</L><R><Rq><URL>aHR0cDovL20ubWFpbC4xMDA4Ni5jbi9idjEvaG9tZS5odG1sP21vPVUwajVHdXZWYUxHM1h6MHFNaWJiUW9rOGczNF9PQUJvJnZuPTI4OCZsb2dpbnR5cGU9MCZjdj0zJnN3dj01JmNsaT01</URL><O>POST</O><T>TOP</T><HIP>113.108.212.38</HIP></Rq></R></RepLookup>",
        LAST);

    lr_end_transaction("登陆",LR_AUTO);  //登录事物结束

    return 0;
}