LR检查点用法小结

来源:互联网 发布:麦迪逊影城 淘宝电影 编辑:程序博客网 时间:2024/06/22 23:00


[font="Times]LR[/font]中检查点有两种:图片和文字。这两种检查点可用以下三个函数实现:[font="Times]web_find()[/font]、[font="Times]web_reg_find()[/font]和[font="Times]web_image_check()[/font]
下面分别介绍三种函数的用法
[size=5][font="Times]1.web_find()[/font][/size]函数
函数作用:在页面中查找相应的内容
参数举例:[font="Times]web_find("web_find","RighOf=a","LeftOf=b","What=name",LAST);[/font]
参数解释:[font="Times]"web_find"[/font]定义该查找函数的名称;“[font="Times]LeftOf[/font]”和“[font="Times]RighOf=[/font]”用来定义查找字符的左右边界;“[font="Times]What=[/font]”定义查找内容。
例如上述参数举例中的意思就是在页面中查找左边界为[font="Times]b[/font],右边界为[font="Times]a[/font],内容为[font="Times]name[/font]的信息
函数用法:该函数是在查找页面中的内容,所以要放在要查找的内容的后面。
[b]注意事项:使用该函数时,要在Vuser->Run-Tme Settings中勾选Enable Image and text check[/b][b]
[color=#000000][size=2]系统默认是不勾选该选项的。[/size][/color]
关于该函数的[url=javascript.:;][u][b]其他[/b][/u][/url]说明:该函数只能在基于HTML模式录制的脚本中进行查找。
[size=5][color=#000000]1.web_reg_find()函数[/size][/color]
[color=#000000][size=2]函数作用:在缓存中查找相应的内容[/size][/color]
[size=2][color=#000000]参数举例:web_reg_find("Search=Body","SaveCount=ddd","Test=aaa",LAST);[/size][/color]
[size=2][color=#000000]参数解释:Search用来定义查找范围,SaveCount定义查找计数变量名称,该参数可以记录在缓存中查找内容出现的次数,可以使用该值,来判断要查找的内容是否被找到[/size][/color]
[size=2][color=#000000]例如上述参数举例中的意思就是Body中查找内容为aaa的信息,并将出现次数记录在变量ddd中。[/size][/color]
[color=#000000][size=2]函数用法:该函数是在缓存中查找相应的内容,所以要放在查找内容之前。[/size][/color]
注:在录制过程中添加的检查点,用到的函数是web_reg_find(),且参数只有“Text=”
[size=5][color=#000000]2.web_image_check()函数[/size][/color]
[color=#000000][size=2]函数作用:在页面中查找一个具体的图片。[/size][/color]
[size=2][color=#000000]参数说明:web_image_check("web_image_check","Alt=","Src=",LAST);;[/size][/color]
[size=2][color=#000000]参数解释:“Alt”和“Src”的值直接取该图片在网页[url=javascript:;][u][b]源代码[/b][/u][/url]中相应参数的值。[/size][/color]
[color=#000000][size=2]函数用法:该函数是在缓存中查找相应的内容,所以要放在查找内容之前。[/size][/color]
注意事项:使用该函数时,要在Vuser->Run-Tme Settings中勾选Enable Image and text check,具体操作请看web_find()中的注意事项。
经过[url=javascript.:;][u][b][u][b]测试[/b][/u][/url][/b][/u],该函数用到查找内容前面或后面,都不影响查找结果。
[color=#000000][size=5]举例说明(脚本)[/size][/color]
[size=2][color=#000000]该脚本记录的是登陆系统后退出的操作,在脚本中用到atoi()函数和lr_eval_string(”{SaveCount定义的变量}”)两个函数结合使用,判断查找内容出现的次数是否大于0,若大于0,则输入登录成功的信息。[/size][/color]
[color=#000000][size=2]vuser_init()[/size][/color]
[color=#000000][size=2]{[/size][/color]
[color=#000000][size=2] [/size][/color]
[color=#000000][size=2]web_url("xjcost",[/size][/color]
[size=2][color=#000000]          "URL=http://gczj-server8:9205/xjcost/",[/size][/color]
[size=2][color=#000000]          "Resource=0",[/size][/color]
[size=2][color=#000000]          "RecContentType=text/html",[/size][/color]
[size=2][color=#000000]          "Referer=",[/size][/color]
[size=2][color=#000000]          "Snapshot=t1.inf",[/size][/color]
[size=2][color=#000000]          "Mode=HTML",[/size][/color]
[size=2][color=#000000]          EXTRARES,[/size][/color]
[size=2][color=#000000]          "Url=jsp/images/index/index.swf", ENDITEM,[/size][/color]
[size=2][color=#000000]          "Url=jsp/images/index/xxfb2.gif", ENDITEM,[/size][/color]
[size=2][color=#000000]          "Url=jsp/images/index/ywpt2.gif", ENDITEM,[/size][/color]
[size=2][color=#000000]          LAST);[/size][/color]
[color=#000000][size=2] [/size][/color]
[color=#000000][size=2]web_url("userAction.struts",[/size][/color]
[size=2][color=#000000]          "URL=http://gczj-server8:9205/xjcost/userAction.struts?actionType=reLogin",[/size][/color]
[size=2][color=#000000]          "Resource=0",[/size][/color]
[size=2][color=#000000]          "RecContentType=text/html",[/size][/color]
[size=2][color=#000000]          "Referer=",[/size][/color]
[size=2][color=#000000]          "Snapshot=t2.inf",[/size][/color]
[size=2][color=#000000]          "Mode=HTML",[/size][/color]
[size=2][color=#000000]          LAST);[/size][/color]
[color=#000000][size=2] [/size][/color]
[color=#000000][size=2]return 0;[/size][/color]
[color=#000000][size=2]}[/size][/color]
[color=#000000][size=2] [/size][/color]
[color=#000000][size=2]Action()[/size][/color]
[color=#000000][size=2]{[/size][/color]
[color=#000000][size=2] [/size][/color]
[color=#000000][size=2]lr_start_transaction("Log_on");[/size][/color]
[color=#000000][size=2]lr_rendezvous("Log_on");[/size][/color]
[color=#000000][size=2]web_add_cookie("userAccount=admin; DOMAIN=gczj-server8");[/size][/color]
[color=#000000][size=2] [/size][/color]
[size=2]web_reg_find("Text=欢迎您",[/size]
[size=2]          "SaveCount=欢迎您_Count",[/size]
[size=2]          LAST);[/size]
[size=2] [/size]
[size=2]web_image_check("web_image_check",[/size]
[size=2]          "Src=/xjcost/jsp/images/index1/edit_01.gif",[/size]
[size=2]          LAST);[/size]
[color=#000000][size=2] [/size][/color]
[color=#000000][size=2]web_submit_data("userLogin.struts",[/size][/color]
[size=2][color=#000000]          "Action=http://gczj-server8:9205/xjcost/userLogin.struts?actionType=userLogin",[/size][/color]
[size=2][color=#000000]          "Method=POST",[/size][/color]
[size=2][color=#000000]          "RecContentType=text/html",[/size][/color]
[size=2][color=#000000]          "Referer=http://gczj-server8:9205/xjcost/userAction.struts?actionType=reLogin",[/size][/color]
[size=2][color=#000000]          "Snapshot=t3.inf",[/size][/color]
[size=2][color=#000000]          "Mode=HTML",[/size][/color]
[size=2][color=#000000]          ITEMDATA,[/size][/color]
[size=2][color=#000000]          "Name=userAccount", "Value=admin", ENDITEM,[/size][/color]
[size=2][color=#000000]          "Name=pwd", "Value=1111", ENDITEM,[/size][/color]
[size=2][color=#000000]          EXTRARES,[/size][/color]
[size=2][color=#000000]          "Url=jsp/images/index1/edit_01a.gif", "Referer=http://gczj-server8:9205/xjcost/userLogin.struts?actionType=userLogin", ENDITEM,[/size][/color]
[size=2][color=#000000]          LAST);[/size][/color]
[color=#000000][size=2] [/size][/color]
[size=2]web_find("web_find",[/size]
[size=2]          "What=欢迎您",[/size]
[size=2]          LAST);[/size]
[color=#000000][size=2]lr_end_transaction("Log_on",LR_AUTO);[/size][/color]
[color=#000000][size=2] [/size][/color]
[size=2]//检查是否登录成功[/size]
[size=2]//如果“欢迎您”这个字符出现次数大于0,输出“Log on successfully!”[/size]
[size=2]if(atoi(lr_eval_string("{欢迎您[/size][size=2]_Count}"))>0) [/size]
[size=2]          lr_output_message("Log on successfully!");[/size]
[size=2]else[/size]
[size=2]          lr_error_message("Log on failed!");[/size]
[size=2]  [/size]
[size=2]return 0;[/size]
[size=2] [/size]
[size=2]return 0;[/size]
[size=2]}[/size]
[size=2] [/size]
[size=2]//atoi()函数的作用是将一个ASCII字符串转换为整型[/size]
[size=2]//lr_eval_string()函数作用是取得参数值,将字符串变量中的参数值替换为当前的参数值并将这个字符串返回[/size]
[size=2] [/size]
[color=#000000][size=2]vuser_end()[/size][/color]
[color=#000000][size=2]{[/size][/color]
[color=#000000][size=2] [/size][/color]
[color=#000000][size=2]lr_think_time(4);[/size][/color]
[color=#000000][size=2] [/size][/color]
[color=#000000][size=2]web_url("userAction.struts_2",[/size][/color]
[size=2][color=#000000]          "URL=http://gczj-server8:9205/xjcost/userAction.struts?actionType=reLogin",[/size][/color]
[size=2][color=#000000]          "Resource=0",[/size][/color]
[size=2][color=#000000]          "RecContentType=text/html",[/size][/color]
[size=2][color=#000000]          "Referer=",[/size][/color]
[size=2][color=#000000]          "Snapshot=t4.inf",[/size][/color]
[size=2][color=#000000]          "Mode=HTML",[/size][/color]
[size=2][color=#000000]          LAST);[/size][/color]
[color=#000000][size=2] [/size][/color]
[color=#000000][size=2]return 0;[/size][/color]
[color=#000000][size=2]}[/size][/color]
[color=#000000][size=2] [/size][/color]
[size=2][color=#000000]Global.h:[/size][/color]
[color=#000000][size=2]#ifndef _GLOBALS_H[/size][/color]
[color=#000000][size=2]#define _GLOBALS_H[/size][/color]
[color=#000000][size=2] [/size][/color]
[color=#000000][size=2]//--------------------------------------------------------------------[/size][/color]
[color=#000000][size=2]// Include Files[/size][/color]
[color=#000000][size=2]#include "lrun.h"[/size][/color]
[color=#000000][size=2]#include "web_api.h"[/size][/color]
[size=2][color=#000000]#include "lrw_custom_body.h"                                      [/size][/color]
[color=#000000][size=2] [/size][/color]
[color=#000000][size=2]//--------------------------------------------------------------------[/size][/color]
[color=#000000][size=2]// Global Variables[/size][/color]
[color=#000000][size=2] [/size][/color]
[color=#000000][size=2]#endif // _GLOBALS_H[/size][/color]
[size=5][color=#000000][font=Cambria]Replay Log[/font][/size][/color]常见信息说明
[color=#000000][size=5]1.[/size][/color]    [size=5]web_find()[/size][size=5]和[/size][size=5]web_image_check()[/size][size=5]函数的[url=javascript.:;][u][b]日志[/b][/u][/url]信息[/size]
[color=#000000][size=2](这两个日志信息是上一样的,只是输出的函数名和参数不同)[/size][/color]
1)   信息1
[color=#000000][size=2]Action.c(22): Verification checks not enabled. web_image_check is skipped. See the 'Run-time settings/Preferences/Checks'        [MsgId: MMSG-27197][/size][/color]
[color=#000000][size=2]Action.c(22): web_image_check was successful      [MsgId: MMSG-26392][/size][/color]
出现该信息,说明没有勾选Enable Image and text check
2)   信息2
[color=#000000][size=2]Action.c(22): "web_image_check" succeeded (1 occurrence(s) found. Alt="", Src="/xjcost/jsp/images/index1/edit_01.gif")          [MsgId: MMSG-27192][/size][/color]
[color=#000000][size=2]Action.c(22): web_image_check was successful     [MsgId: MMSG-26392][/size][/color]
出现该信息,说明检查点设置成功,且已经查找到信息
3)   信息3
[color=#000000][size=2]Action.c(22): Error -27191: "web_image_check" failed (0 occurrence(s) found. Alt="", Src="/xjcost/jsp/images/index1/edit_1.gif")      [MsgId: MERR-27191][/size][/color]
[color=#000000][size=2]Action.c(22): web_image_check highest severity level was "ERROR"        [MsgId: MMSG-26391][/size][/color]
出现该信息,说明要查找的内容没有找到。这时依次尝试以下操作:
1)检查参数的信息是否写错;
2)如果是web_find(),检查函数的位置是否在要查找内容的后面;
3)如果是web_image_check(),查看该图片的源代码,看其是否是这个页面上的图片,很可能是图片选择错误,即所选图片不属于该页面。
[size=5][color=#000000]2. web_reg_find()函数的日志信息[/size][/color]
[size=3][color=#993300]1)信息1[/size][/color]
[color=#000000][size=2]Action.c(15): Registering web_reg_find was successful        [MsgId: MMSG-26390][/size][/color]
出现该信息,说明内容已查找到
[size=3][color=#993300]2)信息2[/size][/color]
[size=2]Action.c(27): Error -26366: "Text=ABC" not found for web_reg_find        [MsgId: MERR-26366][/size]
[size=2]Action.c(27): web_submit_data("userLogin.struts") highest severity level was "ERROR", 18364 body bytes, 918 header bytes, 13 chunking overhead bytes      [MsgId: MMSG-26387][/size]
[color=#000000]该信息在replay log页面是红色显示的,说明没有找到内容,出现此情况尝试以下两个操作:[/color]
[color=#000000][b]1)[/b][b]参数的信息是否正确;[/b][b][/b][/color]
[color=#000000][b]2)[/b][b]查看该函数是否在查找内容的前面[/b][/color][/b]

转自:http://space.itpub.net/22498559/viewspace-614259

原创粉丝点击