业务:根据url获取图片
用web_url()函数访问数据;
请求方式:HTTP GET 请求;
Action()
{
web_url("imageproxytest",
"URL=http://ip:port/imageproxytest?source=http://s1.mimg.ifeng.com/upload/day_130319/201303191807211748.jpg&quality=30&s=1",
"Resource=1", //设置为0,未取到图片,报error;设置为1,未取到图片,报warn
"RecContentType=image/jpeg",
"Referer=",
"Snapshot=t1.inf",
LAST);
return 0;
}
业务:将终端信息提交到服务端进行保存;
用web_custom_request()函数提交数据:
HTTP POST 请求,请求参数为json格式;
Action()
{
//web_add_header("mobile","13505718899"); //当请求头中需带特殊参数时,用该函数加上。
//或 web_add_auto_header("Content-Type","application/json");
web_custom_request("web_custom_request",
"URL=http://ip:port/statisticstest",
"Method=POST",
"Resource=0",
"RecContentType=application/json",
"Referer=",
"Mode=HTTP",
"EncType=application/json",
"Body={\"tag\":\"testbrowser\",\"optype\":\"webstatistics\",\"terminalInfo\":\"{terminfo}\",\"recordList\":[{\"eventType\":1002,\"eventTime\":0,\"sourceData\":\"abc%25B0%25D9%25B6%25C8%25CB%25E6%25C9%25F9%25CC%25FD\",\"sourceType\":0,\"sourceCount\":0}],\"recordCount\":\"1\"}",
LAST);
//判断页面返回正确与否
//if(web_get_int_property(HTTP_INFO_RETURN_CODE)==200)
//lr_output_message("OK!!");
//else
//lr_error_message("Fail!!");
return 0;
}
业务:使用用户名和密码进行登录
用web_submit_data()函数提交表单数据:
HTTP POST 请求,最常见的参数形式;
Action()
{
web_submit_data("login",
"Action=http://ip:port/login",
"Method=POST",
"TargetFrame=",
"RecContentType=text/html",
"Mode=HTML",
ITEMDATA,
"Name=username", "Value=root", ENDITEM,
"Name=password", "Value=2012", ENDITEM,
"Name=remember", "Value=<OFF>", ENDITEM,
LAST);
return 0;
}
业务:使用用户名和密码进行登录(使用录制的方式,脚本一般如下)
用web_submit_form函数提交表单数据:
HTTP POST 请求,最常见的参数形式;
Action()
{
web_url("login",
"URL=http://172.16.4.23:9000/login",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t1.inf",
"Mode=HTML",
LAST);
web_submit_form("authenticate",
"Snapshot=t2.inf",
ITEMDATA,
"Name=username", "Value=root", ENDITEM,
"Name=password", "Value=2012", ENDITEM,
"Name=remember", "Value=<OFF>", ENDITEM,
LAST);
return 0;
}
web_url、web_custom_request、web_submit_data、web_submit_form的使用实例
分类: LoadRunner 2013-03-20 17:21 2812人阅读 评论(0) 收藏 举报