1.网站信息 http://120.78.128.25:8765/ 用户名:13825161923 密码: lemon123
2. 使用web_reg_find与atoi做检查点,web_reg_save_param做关联
具体内容如下:
Action()
{
//添加检查点,查看是否登录成功
web_reg_find(
"Search=Body", //之前操作为区分大小写,回放一直不成功,需要区分大小写
"SaveCount=count",
"Text=登录成功",
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);
//当找到登录成功大于1次就是登录成功啦,否则失败
if(atoi(lr_eval_string("{count}"))>=1)
{
lr_end_transaction("login", LR_PASS);
}
else
{
lr_end_transaction("login", LR_FAIL);
}
//点击投标时会生成一个token,这边需要做关联
web_reg_save_param("token1",
"LB=data-token=\"",
"RB=\"",
LAST);
web_url("web_url",
"TargetFrame=",
"Resource=0",
"Referer=http://120.78.128.25:8765/Index/index",
"Mode=HTML",
LAST);
//添加检查点,根据返回码来看的,fiddler中TextView页面中
web_reg_find(
"Search=Body",
"SaveCount=count2",
"Text=\"state\":1",
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=13313", ENDITEM,//选择投标项目id为13313
"Name=val", "Value=900", ENDITEM,//投标金额为900元
"Name=token", "Value={token1}", ENDITEM,//token是动态值
"Name=remember_me", "Value=1", ENDITEM,
"Name=rewardValue", "Value=0", ENDITEM,
LAST);
//当能够找到返回码,count2大于1,表示投标成功,进入网站查看,发现系统多了一条投标为900的数据
if(atoi(lr_eval_string("{count2}"))>=1)
{
lr_end_transaction("投标", LR_PASS);
}
else
{
lr_end_transaction("投标", LR_FAIL);
}
return 0;
}