LoadRunner11-设置集合点及检查点_第1页
LoadRunner11-设置集合点及检查点_第2页
LoadRunner11-设置集合点及检查点_第3页
已阅读5页,还剩22页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、、设置集合点集合点可以控制各个 Vuser以便在同一时刻执行任务,借助集合点,可以在loadru nner中实现真正意义上的完合一样的并发。当使用集合点时,可以在系统上模拟较重的用户负载。当某个Vuser到达该集合点时,Controller会将其保留,直到参与该集合的全部Vuser都到达。当满足集合条件时,Controller 释放Vuser,这样可以产生非常密集的同一类用户操作或请求。Vuser从集合释放后,将执行脚本中的下一个任务。集合点一般会创建在用户事务的开始标志彰。只能在脚本的Action部分(而不是in it或end部分)添加集合点。Lr_ren dezvous( "集合

2、点名”)如何设置集合点-录制登录testlink脚本为例:1.从菜单中选择运行 Virtual User Generator ,在 New Virtual User 窗口选择 Web(HTTP/HTML )协议,点击“ Create ” 按钮。2.在弹出的窗口中输入要录制的url地址,并选择"Record into Action"3.点击工具条"暂停”按钮暂停录制,并选择"Record into Action ”为Action,在登录主页面输入用户名 XXX,密码XXX,点击“ login ”按钮进行登录,登录成功后点击工具条“停止”按钮结束录制,登录脚

3、本录制成功。務【笹乐IYour session has espiredI Please bg_n sgain.Login NrneMew User?Lost Password?TestLlnk project no neTestLink is licensed under the GMU GPL4.在脚本Action 部分右键选择"Insert f Start Transaction ”弹出一个对话框,输入一个 事务名字login,点击0K,“ Start Transaction ”插入完成后,还需要插入一个" EndTran saction ",用以标识事务结束

4、。LctionOeb-Subnit-dat a (""login php_2c,"Actlohttp: /192.1&8. 1. 251 /tes tlink/Logln. php', *Method=POST"PecCon t eutType=t ext /html""Kef erer=Kttp : /192.163 1 251/testLink/login p?ip?notrespiredJ J"SnapsKot=,t2 inf",'Mode=MTMLITEOATA, *Iaie=re(

5、iURI*j, Na>e=tl_logirL ffNane-tl_passv tfNaiie=l ogin_su. LAST);Start TransactionT ransaclion Name : |砧”7cb_ur 1 (" iaickp phj/ 'm=http;/ie:*Res ouxce=0*jRecCortt ent Type =T&yt7htmT "Rgf霑总丫 ,*Snaj)sh.ot=t3. inf*,OKCancel5.在开始事务前插入集合点,右键选择"Insert ”t" rendezvous ”弹出一个对话

6、框,输入 集合点名字为login,点击0K集合点设置完毕。tif vu$er_mit F Action虻 vuser_end-globals.hActionOlr_think_1: ime(47);lr_s七玄21?1:_1:173口吕0<:七:1011(" 1 o吕in')web_su"bnit_data ("login. php_2',ActlonFhttp: /192,168.1. 251/testlink/losin. p "lethodPOST,ecCont entType=t ext /html'",

7、""Referer=ht tp :/192, l&W* 1. 251 /t estlink/1 ogin, # Snaps hot =t 2. i nf" j "Mod 于 HTlH/j ITEMDATA, NanereqURI", "NanetlQgin Nanetlpassi Nanel ogin_sul LAST);Rende7VCLi5RendHVDUs Name: |loginlr_e nd_ t rans act!>eb_ ur 1 C index, php","URL=http:/19N

8、 168. 1. 251/testl ink/index. phpJ&一. fl-Action(Flr_thirik_tlne (17);11r_rendezvous("1ogi门";lr_start_transaetionCloginJf);v eb_Eub<ia ( 1 in. php_2",ActionFhttp168. L 251/testlink/login, phgpl"TethK)d=FOSTRecCcnt entType=teit/htJil <rReferer=http:/'/192 168. L 251/t

9、est link/login. php?not e=eKpire "Sn孔“hot二吃 infFode=HTMLAITEIDATA,tfNaMe=reqtTRl% ffValue= ENCTTEK, "Nane=tl_loginJ? 5小口尸刃汀,EHDITEI, /lIaiie=tl_passwc>rdJyJ yValu&= xxi END ITEM, aNa».e=login sutuni.tJ'Value=Loginff? ENBITENj LAST):"lr_end_trans a<?ti onogin"、

10、LR._AUTO)j*" iT二、手动设置检查点为了检查web服务器返回的网页结果是否正确,VuGen支持在脚本中插入 Test/lmag 检查点。检查点有两种图片和文字。可以用三个函数实现:web_fi nd()web_reg_fi nd()web_image_check()1. web_fi nd()函数函数作用:在HTML页面中查找相应的内容参数举例:web_fi nd("web_fi nd","RighOf=a","LeftOf=b","What=n ame",LAST);参数解释:"w

11、eb_find"定义该查找函数的名称;“ LeftOf ”和“ RighOf= ”用来定义查找字符的左右边界;“ What= ”定义查找内容。例如上述参数举例中的意思就是在页面中查找左边界为b ,右边界为a,内容为name的信息函数用法:该函数是在查找页面中的内容,所以要放在要查找的内容的后面。注意事项:1. 使用该函数时,要在 Vuser->Ru n-Tme Sett in gs中勾选 En able Image and text check ,系统默认是不勾选该选项的。2函数只能在基于 HTML模式录制的脚本中进行查找。查找用户是否登录testlink 成功信息1. 切换到

12、Tree view 视图,选择action中树形菜单需要插入检查点的一项,然后点击鼠标 右键,选择插入到该操作执行前In sert after,如图:韭日rt 肌"1 login - W亡b (HTTP/HTML)ActwnF 画回 lliaHTMLVilSHrrPWewGrid TreeT ree View IRecording SnapshotActi on O迄 Think Time - 11 (ate)軒- lan S tart Tr 9ik54)cti on - Lc ?in:xxdi test designerHome | Specification | Execute

13、| Test Cass ID: DsLifiwullPropeltInsert After, XJnsert Before,., fie let亡奖%CutCtrkXCopyCtrh-CPasteCtrkV_ |jo ta Sitep in Rep lay LogCtrkETest SpecrficatwnSilbnii t D ata: 1documentUrl i i nd sk:- pKpEzid! Tran sac ti o>:口 Edit Test口 Search T羽t Generate T&st Specification ciocuirient 口 As 5泄 n

14、 軾电2. 在弹出的对话框中选择“Test Check ”,点击"OK”出现Text Check Properties对话框,在"search for ” 中填入需要查找信息": XXX test designer”,点击"确视图,可以看到插入test文本检查点函数 web_find(),点击3.切换到 script view3.切换到script view 视图,可以看到插入test文本检查点函数 web_find(),点击回放”按钮进行搜索所要查询的文本,在replay Log 日志中可以看到 Actio n.c(38): "web.按钮进

15、行搜索所要查询的文本,在replay Log日志中可以看到 Actio n.c(38): "web_: XXX test designer" foundsuccessful. 1 : XXX test designer" found(RightOf="", LeftOf="")Msgld: MMSG-27196Msgld: MMSG-26392Action. c(38): web_fi nd was successful& vusecinit 寸 Action护 VU$er_encl joti als.h| 9 Re

16、play Log隔 Recording Log Correlation Results百1 G eneialion LogLAST),vreb_url index, phpURL=http:/192.16S. 1. 251 /testllrik/indei. php",* ResourceO'j'RecCont entTypet ext/hlml"Referer= ISnapshot=t3. inf*,*Mode=HOLEXTRARES,URL=ui/thenes/default/i mages /na.vbar, gifx, "R* URL=gu

17、i/theMes/default/i mages Ahi te-top-bottc;* URL=third parly/cxt-2. O/inages/dcfnLil t/panel/' LAST);cb_f indind'vWhat=TestLink 1.85 :xxx test desi gner", LAST);lr_end_transa.ci Lon Clogln LR_AUTO)Teturn 0;Act Lon. c (25 : action, c(25): pcti_on, c (38):Act 1 on, c (3S): c C42):Ending ac

18、ti onDownloading resource Jht tp: /192. 163. 1. 251/tEstl ink/gui丿theiii亡s/d巳f vesuri (. index, php") 呼也s success fulf 730565 body hytes 459S header bytes, "irub-find" successful. 1 occurrence(s) of TestLink 1_ 3. 5 : xkx test desigr veb_find vas successful Jtsgld: rimSG-26392Not ify:

19、 Transact iorx login ends d v i thi *Pass* st at us (Dura3. 539G Was!Act i on*Ending iterastion 1.Endine Vus er.Starting action vxiser_end. Ending act!on vuser end2、web_reg_find()函数函数作用:在缓存中查找相应的内容参数举例:web_reg_fi nd("Search=Body","SaveCou nt=ddd","Test=aaa",LAST);参数解释:2

20、.SaveCou nt定义查找计数变量名称,该参数可以记录在缓存中查找内容出现的次数,可以使用该值,来判断要查找的内容是否被找到3. Text用来定义查找内容4. Fail if指定在任何情况下报错,有"NotFound ”和"Found ”两种选择A. web_reg_fi nd("Text=testli nk", "Fail=NotFou nd",LAST);或者B. web_reg_find("Text=testlink", "Fail=Found",LAST);代码思路:1. “ tes

21、tli nk"为你要检查的文本;2. 若是A代码:脚本执行到此处,若没有找到check的字符串,脚本将 FAIL,并且停止执行下去。反之,则一直执行下去。3. 若是B代码:脚本执行到此处,若找到 check的字符串,脚本将 FAIL,并且停止执行 下去。反之,则一直执行下去。函数用法:该函数是在缓存中查找相应的内容,所以要放在查找内容之前。查找用户 XXX 是否登录 testlink 成功信息1.切换到Tree view 视图,选择action中树形菜单需要插入文本检查点的一项,然后点击2. 在弹出的对话框中选择“web_reg_find ”,点击"0K”出现Find Te

22、xt 对话框,在“searchfor specific text ” 中填入查找信息 “ : XXX test designer ”,在 “ search in ” 设置查询范围默认“ All”,定义Savecou nt计数变量为“ regcheck ”,Fail if选择"NotFou nd 点击“ OK ”完成添加test检查点。Step Typ&OKC-dncelwebregLfmdweb_i egLSve_paiam web_r 匕丄 聞 ve_pBi3nn_ 酬 web_i匕3_丸 怕-卩日gnnpdth w&b_i emove_aUtOLheader we

23、b_remo¥e_cookj(e web_r eporLda_F'Oint iweb_i everl_aiuto_lTeadei w&b_vB_header vueb_sei_certifict& web_se Lm li iu 妣q vjeb_set_ccnnect io nslirnit uiplh cet mw hlrril nAMm IpmFind Functicn: wiebLfegLti门d3. 切换到script view 视图,可以看到插入 test文本检查点函数 web reg find(),点击"回放"按钮进行搜索所要查

24、询的文本,在replay Log 日志中可以看到 Action.c(29): XXX test desig ner"(coun t=1)Msgld: MMSG-26364| Start Pm鸵 | login - W曲(HTTP/ HTML)< vuser_initL Aolion< vuse(_end gjcbab-hITEMDAT鵝WDITFW, "Valuexix", ENDITEI, xrName<=tl_pas5wcrdx,J F已, END ITEM,Najnlogin submit'旳lue=L卯in", ENDI

25、TEIrt, LAST);web_reg_find (FailotF ound气"SearchFAlV,"SaizeCounti'Echtdc''、 "TextsstLink L 3* 5 : ixx test designer, LAST),web_url C iniex, phpJ,*UKL=http: /192.168.1. 251/testlink/lndex. php*,Res ource-OjR tcCont ent Typ e= t e x t /ht jm 1 ,xrReferer=ir,Snapshot = t3, inf

26、 "Ikd尸HTM.LAEXTRARE3,URL=gul /1 he» es /def auL t /1 »a g es /na vb ar. gif J AReferer;URL=gui/ themes/defauLt/images/whi te-top-bottom” gif URL=thlrd_rar ty/et-2. O/imaes/def aul t/panel/whi te- LAST);arr鬧 Fiecoidirtg Logw CoriBlahon FtefiAs诗 Garra'ion LogAction. c(29):c(29):Acti

27、on, c (29):Action- c(29):Action, c(29):Action,c(29):Action, c(29): Action, c(43): Ending actionAction.Found resource ""http:/192.163.1,251/testlink/gui/themes/default/ima?es/syni_que=Found resource "htxp:/192.1G3.1. ZSl/tesLlink/gui/Themes/default/lmaBs/sllde_?rl Resource "http:7

28、/1 炙 16乩 1. 251/tes11 ink/gui/themes/default/images/fc:oir.pany_logo, prDovnloading resource J http:/192.168.1. 251 /tes11 irk/gui/thenes/default/images/naFound resource ""http;/192. 1GC. 1 251/tcstlink/gui/theme8/defnult/inkacs/ZnaRiiific Registered web_reg_find successful for rext=restLi

29、nk L 8* 5 : xxx test designer. web_vrl (Aindex. phpJ) vas successful 780565 body bytes, 4596 header tytesj 21 chi Noilfy: Transaction *loginv ended with PassJ status (CuratLon: 3. 5717 Wasted Tin AcilorrEnding检查点-打印验证 web_reg_find()函数: lr_start_tra nsacti on ("logi n");web_submit_data(&quo

30、t;log in. php_2","Acti on= nk/logi n. php",LAST);web_reg_fi nd("Fail=NotFou nd", "Search=AII", "SaveCou nt=regcheck".: XXX test designer", LAST);web_url("i ndex.php",LAST);/判断regcheck 是否大于1,如果大于1,检查结果正确,使用lr_output_message打印,可以供调试时查看/如果检查结果

31、错误,使用lr_error_ message 打印,可以在 control的errors中显示错误if(atoi(lr_eval_stri ng("regcheck")>0)lr_output_message(" 成功!");elselr_error_message(" 失败");lr_e nd_tra nsactio n("logi n", LR_AUTO);3. web_image_check() 函数函数作用:在页面中查找一个具体的图片。参数说明: web_image_check("web_i

32、mage_check","Alt=","Src='#"' /spa n>参数解释:“ Alt ”和“ Src”的值直接取该图片在网页源代码中相应参数的值。src表示该图片文件的路径,alt表示图片的替代显示文本(在需要检查的页面上右键查看源文件,找到该图片的 src和alt值)函数用法:该函数是在缓存中查找相应的内容,所以要放在查找内容之前。注意事项:使用该函数时,要在Vuser->Ru n-Tme Sett in gs中勾选En able Image and textcheck,具体操作请看web_find()中的

33、注意事项例如:查找用户使用testli nk 图标-compa ny_logo.p ng1. 切换到Tree view 视图,选择action中树形菜单需要插入文本检查点的一项,然后点击鼠标右键,选择插入到该操作执行前Insert before,女口图:File Edit View Insert Vuser Actions Toob Whdow Help:事”矣”亡 : < Start Racord £> .越丨毗惟劇危;3 Taiks O' Script Tis5t Pag电logiiD 河啟(HTTP/rnriijActiarS I冋迪 HTML View 鑰

34、 HTTP VewGrid Treeizl Acti OEL ()Sulim itVrlEnd Truii宜 Properties.Insert After.Recording SnapshotTest Link 1.8.5 : xxx test designerThink Tine - 11 (secJRerdeivons - login.Start Truiscti on 一Home | Spedficatbn | Execute | TwtCaseifclDsyunwi* 4 |B* In阵rt 班fursDeletItCutCtrl+XCopyPasteCtrl-KCikVcation

35、 documentGo to Stsp n Repay Log CtrliE>卄Ly ET res ViewThumbnals |Tert 5p«crficatk>n口 Edit Test Cases Search Test Cases Cenerate Test Specification decurrent As昴n K电2. 在弹出的对话框中选择"Image Check ”,点击"0K”出现Image Check Properties 对话框,在"ALT attr ”中填入图片的替代显示文本"Company logo” ,在&

36、quot;SRC att ”中填入图片的路径gui/themes/default/images/compa ny_logo.p ng点击“ OK”完成添rAdd StepB-71白“Q Web ChecksImage Che cl;Tert Check 由於XML i 口 Uil L Sfe Link畀 Image-5 ubnnit FomnSubmit Data. 画 Custom RequestILb S lari T 腐険cticua=i l J 匚pidT m片号Rrli円片StepFind Function: vjeb_ imag e_ch eckOKCancel加图片检查点。三、自

37、动检查点有时侯我们需要确保每个请求中都包含一个检查信息,然而手动添加检查点函数非常麻烦,可以使用自动检查点规则,通过建立一个新的规则,可以在回放时对所有的返回内容进行检查工作。例如:查找登录 testlink脚本每个页面是否包含images/company_logo.png这个图片。1. 打开"Run-time sett in gs/Co nten tCheck,点击"New Application”按钮来添加一个应用,然后在这个应用下添加对应的规则,单击" New rule ”按钮。在Search for text 中填写需要检查的内容"images/

38、company_logo.png ”,也可以在下面的 search by prefixand suffix中填写需要检查边界,大小写需要区分可以将Match case 选中,设置Fail if为Not Found,点击“ OK ”按钮。如图:Start PmcjE Io*油 一 (KTTP/H111L)0 Action 電 vuser_end giobels.hveb_image_check (,,yvreb_i ma ge_ check""Src=gui/themes/default/images/cojnpany_logo, pn "Alt-Conpan lo

39、go-、LAST);web_subiwit_data ( login php_2J jActi on=hltp: /Z192, 1 6& 1, 2J11 /1 es 11 ink/1 o®in. ph MethorcST",v R e cC ent entT ype- text/ htm 1'', "Referer=http: /19Z. 163. 1 251/tesi:! lnls/logln, p '"Snap s heinf J%du=HTMLjITEMDATA.Nane=reqURI *Value=",

40、EUDITEK, !iane=l:l_login "Value=xx ENDITE叫KjTT.f=T r:.? .vW vd ,n Y:1' if=xx z " b ETTECTET,'Nam c=lQgin subni t' f /Vali-ic=LQgin'<rj END ITEM j LAST);veb_url'indux* php ?*URL=ht tp : y/iy. 16a. 1. zbl/les tlink/indei. php*jRecContentType=test/html , "ReT 已 丁61

41、"="扌"SnapshQt=t3. inf",rfMode=HTML*ffT'lJFT'irfc A n TTX-1尼 R七play Log巧 Recording LugComcldDn ResultsG eneiliun LogStarting l_teration 1.Starting action Act 1 on-paction, c(1 j): action. c(24): action. c(24): ketlon- c(24):Action. c(2:4): act J. on_ c(24):_ _ _135 body by

42、tes3 377 header Inon-resource "htt口:"19£ 16S, 1.251/test 1 ink/lib/genera 1/navEar. rhi non-resource http:/152.16S. 1.251/test 1 ink/lib/general/jnalnPage. i ht tp:/192. 168.1- 251/t estllnk/gui./javascript/test llnk_llhr ary- Js" "http:/192. 168.1. 251/testlink/gui/Javagcri

43、ptZtest_autona11on. js" lit tp: /1 92. 168. 1. 251/test llnk/gui/javas rlpt/ooxttable. J s# is In 耳 d jrj Vk * 侶./ /1 m 1 iC o 1 _o>k i c a / 円.工 $ w 4一"nract ion. c(b) : Veb_iirLase_ceck" succeeded (1 occurrence (s) found. Ait= 'Com口ary logo*, Src= Action. 亡(G) : wcb_ ,LJiagE_

44、c;.heQk was Sdc-ceSb £ulJIsgId: MMSG-2635211a f C A、A R *1veb_eubnLil_data ( login. php_2 ) was successfulj Det ected Detected R_esotirce Resource R-ecui'ce时,就能看到运行脚本时,如果有页面返回的代码中没有包含images/company_logo.png以下错误:Actio n.c(10): Error -26370: Co nten tCheck Rule "Rule_1" in Applicati

45、on "discuz" triggered. Text "images/compa ny_logo.p ng" not matched MsgId:MERR-26370Actio n.c(10): web_submit_data("log in .php_2") highest severity level was "ERROR",135 body bytes, 377 header bytesMsgId: MMSG-26388如果返回的代码中包含mages/compa ny_logo.p ng则不会有任何提示出现

46、。通过自动化检查点,可以轻松地对页面中固定出现的内容进行校验工作。四、Replay Log常见信息说明1. web_find() 和 web_image_check()函数的日志信息(这两个日志信息是上一样的,只是输出的函数名和参数不同)1) 信息1Warning -27077: The “ vuser_ in it ” secti on contains web function(s) whe n the“ Simulate a new user on each iterati on” Run-Time Sett ing is ON. This mayproduce un predictable results with multiple iterati onsMsgId: MWAR-27077出现该信息: 说明不能勾选simulate a new user on each iterati onAction. c(5): Verificati on checks not en abled. web_fi nd is skipped. See the 'Run-time setti n

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论