Postman內(nèi)建變量常用方法實例解析
更新時間:2020年07月28日 11:24:40 作者:安琪兒一直在
這篇文章主要介紹了Postman內(nèi)建變量常用方法實例解析,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下
一、Postman有以下內(nèi)建變量,適合一次性使用:
{{$guid}}//生成GUID
{{$timestamp}}//當(dāng)前時間戳
{{$randomInt}}//0-1000的隨機整數(shù)
二、內(nèi)建變量的應(yīng)用舉例,獲取當(dāng)前時間戳
// 隨機整數(shù) const randomInt = (min, max) => Math.floor(Math.random() * (max - min + 1)) + min; pm.globals.set("random_number", randomInt(300,1000)); //從多個選項中選擇實現(xiàn): const randomInt = (min, max) => Math.floor(Math.random() * (max - min + 1)) + min; const getRandomValue = list => list[randomInt(0, list.length - 1)]; const charsInName = ['王','李','張']; pm.globals.set("people_name", getRandomValue(charsInName)); //隨機生成手機號 const randomInt = (min, max) => Math.floor(Math.random() * (max - min + 1)) + min; var mobile_num= `18${randomInt(100000000, 999999999)}`; pm.globals.set("mobile_num", mobile_num); //等待 const sleep = (milliseconds) => { const start = Date.now(); while (Date.now() <= start + milliseconds) {} }; sleep(5000) //5秒
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
JavaScript之class繼承_動力節(jié)點Java學(xué)院整理
這篇文章主要介紹了JavaScript之class繼承,新的關(guān)鍵字class從ES6開始正式被引入到JavaScript中。class的目的就是讓定義類更簡單,有興趣的可以了解一下2017-07-07layui-table表復(fù)選框勾選的所有行數(shù)據(jù)獲取的例子
今天小編就為大家分享一篇layui-table表復(fù)選框勾選的所有行數(shù)據(jù)獲取的例子,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-09-09