日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

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

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

1、根據(jù)接口文檔寫腳本,函數(shù)(web_custom_request),完成get,post請(qǐng)求(注冊(cè),登錄)

代碼:

Action() {lr_save_string("請(qǐng)?zhí)顚懩愕腎P", "IP");//注冊(cè)/*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);*///設(shè)置token關(guān)聯(lián) 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("手機(jī)號(hào):%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、用登錄接口進(jìn)行參數(shù)化的九種方式取值,自己總結(jié)   

  舉例說明:通過num:1、2、3、4、5,迭代6次對(duì)九種方式的運(yùn)行結(jié)果及代碼如下:

Action() {lr_error_message("本次數(shù)字是:%s",lr_eval_string("{num}"));return 0; }

3、數(shù)據(jù)庫參數(shù)化(詳細(xì)步驟)

  第一步安裝

  

?  第二步

  

  第三步

  

  第四步點(diǎn)擊【create】→【機(jī)器數(shù)據(jù)源】→【新建】→數(shù)據(jù)源類型選擇【用戶數(shù)據(jù)源】

  

  第五步,點(diǎn)擊下一步,點(diǎn)擊完成

  第六步,填寫數(shù)據(jù)庫連接信息,點(diǎn)擊【OK】,一路確定

  第七步,填寫數(shù)據(jù)庫查詢語句,舉例:SELECT mobile FROM cb_account WHERE `password` = 'e10adc3949ba59abbe56e057f20f883e'

  第八步,導(dǎo)入完成

  

4、設(shè)置迭代次數(shù)

?

以上接口信息都在給的虛擬機(jī)里面,安裝配置文件里面的命令啟動(dòng)Tomcat,連上數(shù)據(jù)庫

預(yù)習(xí)(C語言基本知識(shí)),完成易捷的(登錄,下訂單,支付訂單)的腳本(已完成

Action(){lr_save_string("請(qǐng)?zhí)顚懩愕腎P", "IP");//注冊(cè)/*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);*///設(shè)置token關(guān)聯(lián) 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);//設(shè)置padId關(guān)聯(lián) 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;}

?

轉(zhuǎn)載于:https://www.cnblogs.com/user-moxiaohao/p/10687730.html

總結(jié)

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

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。