1.网站信息 http://120.78.128.25:8765/ 用户名:13825161923 密码: lemon123
2. 使用web_reg_save_param_ex与atoi做检查点与关联
具体内容如下:
Action()
{
//使用该方法做检查点,查找到返回内容“登陆成功”
web_reg_save_param_ex(
"ParamName=login_Tommy",
"LB=class=\"success\">",
"RB=</p>",
"Ordinal=1",
SEARCH_FILTERS,
LAST);
//登陆事务添加
lr_start_transaction("login");
web_submit_data("web_submit_data",
"Method=POST",
"EncType=application/x-www-form-urlencoded; charset=UTF-8",
"TargetFrame=",
"Referer=http://120.78.128.25:8765/Index/login.html",
"Mode=HTML",
ITEMDATA,
"Name=phone", "Value=13825161923", ENDITEM,
"Name=password", "Value=lemon123", ENDITEM,
"Name=vcode", "Value=", ENDITEM,
"Name=remember_me", "Value=1", ENDITEM,
"Name=notify_url", "Value=", ENDITEM,
LAST);
//关联显示通过上面关联得到的值
lr_error_message("用户登录情况:%s",lr_eval_string("{login_Tommy}"));
//将关联得到的状态值与预期结果“登陆成功”做匹配,如果成功显示为pass,否则显示fail
if(strcmp(lr_eval_string("{login_Tommy}"),"登录成功")==0)
{
lr_end_transaction("login", LR_PASS);
}
else
{
lr_end_transaction("login", LR_FAIL);
}
//查找桌面元素,可能得到多个值,这边取第一个
web_reg_save_param_ex(
"ParamName=login_ID",
"LB=<a href=\"/loan/loan_detail/Id/",
"RB=.html",
"Ordinal=1", //取得到的第一个值
SEARCH_FILTERS,
LAST);
//首页get请求内容
web_url("web_url",
"TargetFrame=",
"Resource=0",
"Referer=http://120.78.128.25:8765/Index/login.html",
"Mode=HTML",
LAST);
//添加token关联
web_reg_save_param_ex(
"ParamName=test_token",
"LB=data-token=\"",
"RB=\"",
"Ordinal=1",
SEARCH_FILTERS,
LAST);
//点击第一个ID进行投标
web_url("web_url",
"URL=http://120.78.128.25:8765/loan/loan_detail/Id/{login_ID}.html ",
"TargetFrame=",
"Resource=0",
"Referer=http://120.78.128.25:8765/Index/index",
"Mode=HTML",
LAST);
//投标后获取对应的返回码
web_reg_save_param_ex(
"ParamName=Last",
"LB=state\":",
"RB=,",
"Ordinal=1",
SEARCH_FILTERS,
LAST);
//投标事务
lr_start_transaction("投标");
web_submit_data("web_submit_data",
"Action=http://120.78.128.25:8765/Invest/invest",
"Method=POST",
"EncType=application/x-www-form-urlencoded; charset=UTF-8",
"TargetFrame=",
"Mode=HTML",
ITEMDATA,
"Name=id", "Value={login_ID}", ENDITEM,
"Name=val", "Value=100", ENDITEM,
"Name=token", "Value={test_token}", ENDITEM,
"Name=remember_me", "Value=1", ENDITEM,
"Name=rewardValue", "Value=0", ENDITEM,
LAST);
//如果返回的值是1,则判断为投标成功,否则投标失败
if(strcmp(lr_eval_string("{Last}"),"1")==0)
{
lr_end_transaction("投标", LR_PASS);
}
else
{
lr_end_transaction("投标", LR_FAIL);
}
return 0;
}