loginapi()
{
web_url("rest",
"URL=http://192.168.117.154/router/rest",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t1.inf",
"Mode=HTML",
LAST);
web_url("favicon.ico",
"URL=http://192.168.117.154/favicon.ico",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t2.inf",
"Mode=HTML",
LAST);
lr_rendezvous("loginapi");
lr_start_transaction("loginapi");
lr_set_debug_message(LR_MSG_CLASS_EXTENDED_LOG | LR_MSG_CLASS_RESULT_DATA, LR_SWITCH_ON );
web_reg_find("Text=操作成功",
LAST);
web_submit_data("testpost",
"Action=http://192.168.117.154/router/rest",
"Method=POST",
"RecContentType=text/html",
"Mode=HTML",
ITEMDATA,
"Name=method","Value=test.user.UserService.userInfoByTicket",ENDITEM,
"Name=v","Value=1.0",ENDITEM,
"Name=app_key","Value=120",ENDITEM,
"Name=ticket","Value=1111111111111111111111111111111",ENDITEM,
"Name=sign","Value=22222222222222222222222222222222",ENDITEM,
LAST);
lr_set_debug_message(LR_MSG_CLASS_EXTENDED_LOG | LR_MSG_CLASS_RESULT_DATA, LR_SWITCH_OFF);
lr_end_transaction("loginapi", LR_AUTO);
return 0;
}
模拟APP发送请求给Cloud,
一般都是用户登录后。cloud会返回登录成功的消息并且返回一个cookie给app,
app下次要做一些例如设置名称之类的工作,在请求消息里面会携带返回的cookie,而且cloud也会校验这个cookie
1、第一次请求登录,获取cookie,
2、使用第一次请求获取的cookie进行第二次请求
Action()
{
web_reg_save_param("par1",
"LB=auth_key\":\"",
"RB=\"",
LAST);
web_reg_save_param("par3",
"LB=Set-Cookie: ",
"RB=;",
"ORD=2",
LAST);
web_reg_save_param("par4",
"LB=Set-Cookie: ",
"RB=;",
"ORD=3",
LAST);
web_custom_request("login",
"URL=
http://192.168.1.102/api/user/login",
"Method=POST",
"Resource=0",
"Referer=",
"mode=HTTP",
"Body=email=t993@163.com&password=8c2b2f9cd3431be8a7bf64a33e81b371",
LAST);
lr_message ("par1:%s", lr_eval_string("{par1}"));
lr_message ("par3:%s", lr_eval_string("{par3}"));
lr_message ("par4:%s", lr_eval_string("{par4}"));
return 0;
}
Action2()
{
web_cleanup_cookies();
web_add_header("cookie",
"{par3};{par4};{par1}");
web_custom_request("info",
"URL=
http://192.168.1.102/api/app/set/device",
"Method=POST",
"Resource=0",
"Referer=",
"mode=HTTP",
"Body=camid=4026aabz&auth_key={par1}",
LAST);
return 0;
}
传json数据时引号前加转义字符\
"Name=input","Value={\"mobile\":\"15280288286\",\"password\":\"6f96c57e306923c7\"}",ENDITEM,
posted on 2014-03-23 18:20
zouhui 阅读(9986)
评论(0) 编辑 收藏 所属分类:
2.软件测试 性能自动化