在脚本上加上一些逻辑,更好判断结果是否成功
Action() { web_reg_save_param( "usersession", "LB=userSession value=", "RB=>", LAST ); web_url("webtours", "URL=http://127.0.0.1:1080/webtours/", "Resource=0", "RecContentType=text/html", "Referer=", "Snapshot=t1.inf", "Mode=HTML", LAST); lr_think_time(7); web_reg_find("Text=jojo", "SaveCount=jojo_count",//保存检查到的次数*** LAST); web_submit_data("login.pl", "Action=http://127.0.0.1:1080/webtours/login.pl", "Method=POST", "RecContentType=text/html", "Referer=http://127.0.0.1:1080/webtours/nav.pl?in=home", "Snapshot=t2.inf", "Mode=HTML", ITEMDATA, "Name=userSession", "Value={usersession}", ENDITEM, "Name=username", "Value=jojo", ENDITEM, "Name=password", "Value=bean", ENDITEM, "Name=JSFormSubmit", "Value=on", ENDITEM, "Name=login.x", "Value=81", ENDITEM, "Name=login.y", "Value=10", ENDITEM, LAST); //增加判断,如果检查到用户名出现的次数大于0,认为登录成功,否则失败*** if (atoi (lr_eval_string("{jojo_count}")) >0) { lr_output_message(" 登录成功"); }else lr_output_message(" 登录失败"); web_image("SignOff Button", "Alt=SignOff Button", "Snapshot=t3.inf", LAST); return 0; }
-----------------------------------------------------------
重点函数
web_reg_find("Text=jojo",
"SaveCount=jojo_count",//保存检查到的次数***
LAST);
//增加判断,如果检查到用户名出现的次数大于0,认为登录成功,否则失败***
if (atoi (lr_eval_string("{jojo_count}")) >0) {
lr_output_message(" 登录成功");
}else
lr_output_message(" 登录失败");
常用函数
lr_eval_string
lr_eval_string("{当前想要获取的参数名}"); 获取指定的当前参数值
strcmp函数
strcmp(字符串1,字符串2); 比较字符串1与字符串2的大小
strcpy函数
strcpy(目标字符串,原字符串); 将原字符串拼接到目标字符串后