web_reg_find(转载)
上一篇 /
下一篇 2012-10-26 11:11:22
/ 个人分类:LR
在
LoadRunner中常会遇到的问题就是验证是否成功,验证的方法就是要在返回的页面或响应中查找是否有对应的数据。
用web_reg_find可以查找html页面中的text(Registers a search for a text string on an HTML page.)
因为是查找下一行返回的页面。所以要插在执行操作的前面。
intweb_reg_find(const char *attribute_list, LAST);
Text:查找的内容
TextPfx:左边界
TextSfx:右边界
Search:查找的位置。The default value isBODY.
SaveCount:和目的内容匹配的数目
eg:
web_reg_find("Text=Welcome",
LAST);
web_reg_find("Text=Welcome",
"SaveCount=Welcome_Count",
LAST);
Web_reg_save_param将一些动态变化的数据保存成一个变量以供调用(Saves dynamic data information to a parameter. ) 此方法查找的为服务器端返回的内容(Server Response).可用来做手动关联 ,该方法也是要插入在执行操作前面的
intweb_reg_save_param(const char *ParamName, <List of Attributes>, LAST);
LB: 左边界
RB: 右边界
Search: 查找的位置
eg: web_reg_save_param("WCSParam_Text1",
"LB=alert('",
"RB=.",
"Ord=1",
"RelFrameId=1",
"Search=Body",
"IgnoreRedirections=Yes",
LAST);
还有个简单的方法来添加查找,在【Tree】视图下,在右侧栏中选中要查找的文字,单击右键,选择"Add a Text Check"就是插入了web_reg_find方法,在【Server Response】-【Body】中选中文字,单击右键,选择"Create Parameter",就插入了web_reg_save_param方法。
要将参数打印出来查看,可用
lr_output_message("the text is : %s",lr_eval_string("{WCSParam_Text1}"));
收藏
举报
TAG: