日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

性能测试学习05_lr(根据接口文档写脚本+参数化)

發布時間:2025/3/15 24 豆豆
生活随笔 收集整理的這篇文章主要介紹了 性能测试学习05_lr(根据接口文档写脚本+参数化) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

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;}

?

轉載于:https://www.cnblogs.com/user-moxiaohao/p/10687730.html

總結

以上是生活随笔為你收集整理的性能测试学习05_lr(根据接口文档写脚本+参数化)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。