1.var result = json.parse(requestBody);
//把值作為全局變量;
pm.globals.set("assess_token",result.assess_token);
第二個接口:
{{assesss_token}}}
2.使用正則表達式來進行;
new RegExp(' "access_token":"(.*?)" ')
postman的內(nèi)置參數(shù):
{{randomInt}} 生成0到1000之前的隨機數(shù)
{{$guid}} 生成guid字符串
自定義的動態(tài)參數(shù)是在
pre-request script中進行配置的。
//手動獲取時間戳
var definedTime = Date.now()
//設(shè)置全局變量
pm.globals.set("times",times);
//使用時
{{times}}
postman中的斷言:
pm.response.to.have.status(200)
在斷言中獲得自定義的參數(shù):
pm.globals.get("times")
globals["times"]
globals.times
pm.expect(pm.response.text()).to.include("mashang"+globals["times"])