LR自带例子WebTours回放时的参数关联问题
我用范例录了一个登录脚本,使用的是HTML-based,其它基本上都是默认设置。
使用自己注册的用户名/密码进入例子中后进行了一个最基本的登录操作然后退出,录制完毕后,然后回放,系统提示要求对userSession进行关联,手动关联好之后,回放,然后再设置runtime setting,将number of iteration改为5,再次回放时出现错误:
Action.c(61): Error -27987: Requested image
not found [MsgId: MERR-27987]
Action.c(61):
web_image("SignOff Button") highest severity level was "ERROR", 0 body bytes, 0
header bytes [MsgId: MMSG-26388]
刚开始一直怀疑是关联的问题,后来的解决方法如下:
1, 打开recording options,在internet
protocol下的recording中选择recording level为HTML-based script,点击HTML Advanced,选择script
type为A script containing explicit.即可。
2, 选择使用URL_based script录制。
事例程序如下:
Action() { web_set_max_html_param_len("100000"); //添加关联 web_reg_save_param("userSessionValue", "LB=userSession value=", "RB=>", "Ord=1", "Search=Body", LAST); //添加检查点 web_reg_find("Search=Body", "SaveCount=sscount", "Text=Welcome", LAST); web_url("WebTours", "URL=http://127.0.0.1:1080/WebTours/", "TargetFrame=", "Resource=0", "RecContentType=text/html", "Referer=", "Snapshot=t7.inf", "Mode=HTML", LAST); web_url("WebTours_2", "URL=http://127.0.0.1:1080/WebTours/", "TargetFrame=", "Resource=0", "RecContentType=text/html", "Referer=", "Snapshot=t8.inf", "Mode=HTML", EXTRARES, "URL=../favicon.ico", ENDITEM, LAST); web_submit_data("login.pl", "Action=http://127.0.0.1:1080/WebTours/login.pl", "Method=POST", "TargetFrame=", "Referer=http://127.0.0.1:1080/WebTours/nav.pl?in=home", "Mode=HTML", ITEMDATA, "Name=userSession", "Value={userSessionValue}", ENDITEM, "Name=username", "Value=xia", ENDITEM, "Name=password", "Value=111111", ENDITEM, "Name=JSFormSubmit", "Value=on", ENDITEM, LAST); lr_think_time(5); web_submit_data("login.pl_2", "Action=http://127.0.0.1:1080/WebTours/login.pl", "Method=POST", "TargetFrame=", "RecContentType=text/html", "Referer=http://127.0.0.1:1080/WebTours/nav.pl?in=home", "Snapshot=t9.inf", "Mode=HTML", ITEMDATA, "Name=userSession", "Value={userSessionValue}", ENDITEM, "Name=username", "Value={Username}", ENDITEM, "Name=password", "Value={Password}", ENDITEM, "Name=JSFormSubmit", "Value=on", ENDITEM, "Name=login.x", "Value=48", ENDITEM, "Name=login.y", "Value=9", ENDITEM, LAST); web_submit_data("login.pl_3", "Action=http://127.0.0.1:1080/WebTours/login.pl", "Method=POST", "TargetFrame=", "RecContentType=text/html", "Referer=http://127.0.0.1:1080/WebTours/nav.pl?in=home", "Snapshot=t10.inf", "Mode=HTML", ITEMDATA, "Name=userSession", "Value={userSessionValue}", ENDITEM, "Name=username", "Value={Username}", ENDITEM, "Name=password", "Value={Password}", ENDITEM, "Name=JSFormSubmit", "Value=on", ENDITEM, "Name=login.x", "Value=48", ENDITEM, "Name=login.y", "Value=9", ENDITEM, LAST); //输出Session值 lr_output_message("userSessionValue值是:%s", lr_eval_string("{userSessionValue}")); web_url("SignOff Button", "URL=http://127.0.0.1:1080/WebTours/welcome.pl?signOff=1", "TargetFrame=body", "Resource=0", "RecContentType=text/html", "Referer=http://127.0.0.1:1080/WebTours/nav.pl?page=menu&in=home", "Snapshot=t11.inf", "Mode=HTML", LAST); web_url("SignOff Button_2", "URL=http://127.0.0.1:1080/WebTours/welcome.pl?signOff=1", "TargetFrame=body", "Resource=0", "RecContentType=text/html", "Referer=http://127.0.0.1:1080/WebTours/nav.pl?page=menu&in=home", "Snapshot=t12.inf", "Mode=HTML", LAST); //输出检查点出现的次数 if(atoi(lr_eval_string("{sscount}"))>0) { lr_output_message("Welcome出现的次数是:%s", lr_eval_string("{sscount}")); } else { lr_output_message("未发现检查点,登录失败"); } return 0; }
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。