1、根据接口文档写脚本,函数(web_custom_request),完成get,post请求(注册,登录)
代码:
Action() { lr_save_string("请填写你的IP", "IP"); //注册 /*web_custom_request("register", "URL=http://{IP}/mobile/api/user/register", "Method=POST", "TargetFrame=", "Resource=1", "Referer=", "Mode=HTTP", "EncType=application/json;charset=utf-8", "Body={"mobile":"{mobile_mysql}","password":"123456","code":"3367","platform":"windows"}", LAST);*/ //设置token关联 web_reg_save_param_ex( "ParamName=token", "LB=token":"", "RB=",", //"DFEs=test", //"NotFound=warning", "Ordinal=1", //"SaveOffset=2", //"SaveLen=3", SEARCH_FILTERS, "Scope=ALL", //"RelFrameID=1", //"RequestUrl=testURL", //"ContentType=text/html", LAST ); //lr_output_message("token:%s",lr_eval_string("{token}")); //登录 web_custom_request("login", "URL=http://{IP}/mobile/api/user/login ", "Method=POST", "TargetFrame=", "Resource=1", "Referer=", "Mode=HTTP", "EncType=application/json ", "Body={"mobile":"{mobile_mysql}","password":"123456"}", LAST); lr_error_message("手机号:%s",lr_eval_string("{mobile_mysql}")); //获取商品列表 web_custom_request("getorders", "URL=http://{IP}/mobile/api/goods/gettypes ", "Method=GET", "TargetFrame=", "Resource=1", "Referer=", "Mode=HTTP", "EncType=application/json ", "Body={"type":1}", LAST); return 0; }
2、用登录接口进行参数化的九种方式取值,自己总结
举例说明:通过num:1、2、3、4、5,迭代6次对九种方式的运行结果及代码如下:
Action() { lr_error_message("本次数字是:%s",lr_eval_string("{num}")); return 0; }
3、数据库参数化(详细步骤)
第一步安装
第二步
第三步
第四步点击【create】→【机器数据源】→【新建】→数据源类型选择【用户数据源】
第五步,点击下一步,点击完成
第六步,填写数据库连接信息,点击【OK】,一路确定
第七步,填写数据库查询语句,举例:SELECT mobile FROM cb_account WHERE `password` = 'e10adc3949ba59abbe56e057f20f883e'
第八步,导入完成
4、设置迭代次数
以上接口信息都在给的虚拟机里面,安装配置文件里面的命令启动Tomcat,连上数据库
预习(C语言基本知识),完成易捷的(登录,下订单,支付订单)的脚本(已完成
Action() { lr_save_string("请填写你的IP", "IP"); //注册 /*web_custom_request("register", "URL=http://{IP}/mobile/api/user/register", "Method=POST", "TargetFrame=", "Resource=1", "Referer=", "Mode=HTTP", "EncType=application/json;charset=utf-8", "Body={"mobile":"{mobile_mysql}","password":"123456","code":"3367","platform":"windows"}", LAST);*/ //设置token关联 web_reg_save_param_ex( "ParamName=token", "LB=token":"", "RB=",", //"DFEs=test", //"NotFound=warning", "Ordinal=1", //"SaveOffset=2", //"SaveLen=3", SEARCH_FILTERS, "Scope=ALL", //"RelFrameID=1", //"RequestUrl=testURL", //"ContentType=text/html", LAST ); //登录 web_custom_request("login", "URL=http://{IP}/mobile/api/user/login ", "Method=POST", "TargetFrame=", "Resource=1", "Referer=", "Mode=HTTP", "EncType=application/json ", "Body={"mobile":"{mobile_mysql}","password":"123456"}", LAST); //重置支付密码 web_custom_request("resetpaywd", "URL=http://{IP}/mobile/api/user/resetpaypwd", "Method=POST", "TargetFrame=", "Resource=1", "Referer=", "Mode=HTTP", "EncType=application/json ", "Body={"token":"{token}","password":"123456"}", LAST); //lr_output_message("token:%s",lr_eval_string("{token}")); //获取商品列表 web_custom_request("gettypes", "URL=http://{IP}/mobile/api/goods/gettypes", "Method=GET", "TargetFrame=", "Resource=1", "Referer=", "Mode=HTTP", "EncType=application/json ", "Body={"type":1}", LAST); //设置padId关联 web_reg_save_param_ex( "ParamName=payId", "LB="payId":"", "RB=","", //"DFEs=test", //"NotFound=warning", "Ordinal=1", //"SaveOffset=2", //"SaveLen=3", SEARCH_FILTERS, "Scope=ALL", //"RelFrameID=1", //"RequestUrl=testURL", //"ContentType=text/html", LAST ); //lr_output_message("payId:%s",lr_eval_string("{payId}")); //下订单 web_custom_request("addorder", "URL=http://{IP}/mobile/api/order/addorder", "Method=POST", "TargetFrame=", "Resource=1", "Referer=", "Mode=HTTP", "EncType=application/json ", "Body={"token":"{token}","getAddrId":1,"getCarId":23,"payType":2,"remark":"123","price":12,"orders":[{"getTime":1450921104000,"goodss":[{"goodsId":93,"count":1},{"goodsId":96,"count":1}]}],"invoiceTitle":"fapiao"}", LAST); //支付订单 web_custom_request("pay", "URL=http://{IP}/mobile/api/pay/pay", "Method=POST", "TargetFrame=", "Resource=1", "Referer=", "Mode=HTTP", "EncType=application/json ", "Body={"token":"{token}","payId":"{payId}","payPwd":"123456","platform":3}", LAST); return 0; }