loadrunner中web_reg_find使用使用方法
Posted memory&记忆
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了loadrunner中web_reg_find使用使用方法相关的知识,希望对你有一定的参考价值。
Java语法:int object.reg_find( String text, String[] argumentList ); (例子:略)
C语法:int web_reg_find( const char *attribute_list, LAST );
Example 1搜索文本字符串“world”,如果没有搜索到,则函数搜索失败,脚本停止执行:
web_url("My97DatePicker.html_2",
"URL=http://www.****/thirdparty/My97DatePicker/My97DatePicker.html",
"Resource=0",
"RecContentType=text/html",
"Referer=http://www.****/jjh/dacms/login.do;jsessionid=F3678EE7651A87BE80DE3E7DE449913C",
"Snapshot=t5.inf",
"Mode=HTML",
EXTRARES,
"Url=lang/zh-cn.js", ENDITEM,
"Url=skin/whyGreen/datepicker.css", ENDITEM,
"Url=skin/default/datepicker.css", ENDITEM,
"Url=skin/default/img.gif", ENDITEM,
LAST);
web_reg_find("Text=world",
LAST );
web_submit_data("login.do",
"Action=http://www.****/jjh/dacms/login.do",
"Method=POST",
"RecContentType=text/html",
"Referer=http://www.****/jjh/dacms/login.do;jsessionid=F3678EE7651A87BE80DE3E7DE449913C",
"Snapshot=t6.inf",
"Mode=HTML",
ITEMDATA,
"Name=username", "Value=****", ENDITEM,
"Name=password", "Value=****", ENDITEM,
"Name=submit.x", "Value=32", ENDITEM,
"Name=submit.y", "Value=16", ENDITEM,
LAST);
失败提示信息为:
Action.c(69): Error -26366: "Text=world" not found for web_reg_find [MsgId: MERR-26366]
Action.c(69): web_submit_data("login.do") highest severity level was "ERROR", 4261 body bytes, 315 header bytes, 13 chunking overhead bytes [MsgId: MMSG-26387]
Example 2
例2与例1相同,但由于使用了SaveCount,所以在失败时不会停止脚本执行。相反,错误在代码中处理。
web_url("My97DatePicker.html_2",
"URL=http://www.****/thirdparty/My97DatePicker/My97DatePicker.html",
"Resource=0",
"RecContentType=text/html",
"Referer=http://www.****/jjh/dacms/login.do;jsessionid=F3678EE7651A87BE80DE3E7DE449913C",
"Snapshot=t5.inf",
"Mode=HTML",
EXTRARES,
"Url=lang/zh-cn.js", ENDITEM,
"Url=skin/whyGreen/datepicker.css", ENDITEM,
"Url=skin/default/datepicker.css", ENDITEM,
"Url=skin/default/img.gif", ENDITEM,
LAST);
web_reg_find("Text=world",
"SaveCount=world_Count",
LAST );
if (atoi(lr_eval_string("{world_Count}")) > 0){
lr_output_message("Log on successful.");
}
else{
lr_output_message("output:Log on failed");
lr_error_message("Log on failed");
return(0);
}
web_submit_data("login.do",
"Action=http://www.****/jjh/dacms/login.do",
"Method=POST",
"RecContentType=text/html",
"Referer=http://www.****/jjh/dacms/login.do;jsessionid=F3678EE7651A87BE80DE3E7DE449913C",
"Snapshot=t6.inf",
"Mode=HTML",
ITEMDATA,
"Name=username", "Value=****", ENDITEM,
"Name=password", "Value=****", ENDITEM,
"Name=submit.x", "Value=32", ENDITEM,
"Name=submit.y", "Value=16", ENDITEM,
LAST);
提示结果信息为:
Action.c(80): output:Log on failed
Action.c(81): Error: Log on failed
Ending action Action.
Error -27257: Pending web_reg_save_param/reg_find/create_html_param[_ex] request(s) detected and reset at the end of iteration number 1 [MsgId: MERR-27257]
Example 3
搜索文本字符串中“error”,If the string is found, it fails and the script execution stops.
web_reg_find("Text/IC=Error", "Fail=Found", LAST );
web_url("Step", "URL=...", LAST );
Example 4
搜索字符串“world”,如果文本字符串未被搜索到,则脚本执行Action spider;如果文本字符串被搜索到1次或多次,则脚本执行Action honeybee。
web_reg_find("Text=world", "SaveCount=world_count", LAST );
web_url("Step", "URL=...", LAST );
if (strcmp(lr_eval_string("{world_count}"), "0") == 0)
Action spider
else
Action honeybee
以上是关于loadrunner中web_reg_find使用使用方法的主要内容,如果未能解决你的问题,请参考以下文章
Loadrunner--web_find和web_reg_find的用法和区别