【学习-SOFT】

动态变量 / 随机参数

2022-01-27 11:02:56 更新   浏览量: 271
上一章:环境变量 / 全局变量 / 临时变量 下一章:Socket 接口快速上手

动态变量 / 随机参数

动态变量是在接口运行中按指定规则生成的变量,100% 兼容 Postman 动态变量。

参数中使用动态变量的方式为{{变量名}},如{{$timestamp}}表示当前时间戳。

注意

  • 前置脚本和后置脚本需要通过 pm.variables.replaceIn()使用动态变量,如:

    var timestamp = pm.variables.replaceIn('{{$timestamp}}');
    
  • 当前实现的动态变量仅为了完全兼容 Postman,不支持中文;后续会考虑用 mock.js 的方式来实现动态变量,到时候会支持中文。

常用

变量名说明结果示例
$guiduuid-v4 格式的 guid"611c2e81-2ccb-42d8-9ddc-2d0bfa65c1b4"
"3a721b7f-7dc9-4c45-9777-516942b98e0d"
"22eca807-006b-47df-9511-e92e37f5071a"
$timestamp以秒为单位的当前 UNIX 时间戳156275710715627571081562757109
$isoTimestampISO 格式(zero UTC)当前时间戳2019-10-21T06:05:50.000Z
2019-07-29T18:29:00.000Z
$randomUUID随机 36 字符的 UUID"6929bb52-3ab2-448a-9796-d6480ecad36b"
"53151b27-034f-45a0-9f0a-d7b6075b67d0"
"727131a2-2717-44ad-ab02-006587e947dc"

文本、数字、颜色

变量名说明结果示例
$randomAlphaNumeric单个随机字母/数字字符6"y""z"
$randomBoolean随机布尔值 (true/false)truefalsefalsetrue
$randomInt1 到 1000 之间的随机整数802494200
$randomColor随机颜色名"red""fuchsia""grey"
$randomHexColor随机 hex 格式颜色值"#47594a""#431e48""#106f21"
$randomAbbreviation一个随机的英文缩写SQLPCIJSON

网络相关

变量名说明结果示例
$randomIP随机 IPv4 地址241.102.234.100216.7.27.38
$randomIPV6随机 IPv6 地址dbe2:7ae6:119b:c161:1560:6dda:3a9b:90a9
c482:23a4:ce4c:a668:7736:6cc5:b0b6:cc37
c791:18d1:fbba:87d8:d929:22aa:5a0a:ac3d
$randomMACAddress随机 MAC 地址33:d4:68:5f:b4:c71f:6e:db:3d:ed:fa
$randomPassword随机 15 位字母/数字字符组成的密码t9iXe7COoDKv8k3QAzNFQtvR9cg2rq
$randomLocale随机 2 字符语言编码 (ISO 639-1)"ny""sr""si"
$randomUserAgent随机浏览器 user agentMozilla/5.0 (Macintosh; U; Intel Mac OS X 10.9.8; rv:15.6) Gecko/20100101 Firefox/15.6.6
Opera/10.27 (Windows NT 5.3; U; AB Presto/2.9.177 Version/10.00)
Mozilla/5.0 (Windows NT 6.2; rv:13.5) Gecko/20100101 Firefox/13.5.6
$randomProtocol随机网络协议名"http""https"
$randomSemver随机版本号 (semantic version 格式)7.0.52.5.86.4.9

姓名

变量名说明结果示例
$randomFirstName随机英文 first nameEthanChandlerMegane
$randomLastName随机英文 last nameSchadenSchneiderWillms
$randomFullName随机英文 first and last nameConnie RunolfsdottirSylvan FayJonathon Kunze
$randomNamePrefix随机英文 name 前缀Dr.Ms.Mr.
$randomNameSuffix随机英文 name 后缀IMDDDS

职业

变量名说明结果示例
$randomJobArea随机英文职位领域MobilityIntranetConfiguration
$randomJobDescriptor随机英文职位描述ForwardCorporateSenior
$randomJobTitle随机英文职位名称International Creative Liaison,
Product Factors Officer,
Future Interactions Executive
$randomJobType随机英文类型SupervisorManagerCoordinator

手机号,地址

变量名说明结果示例
$randomPhoneNumber随机 10 位电话号码(国外)700-008-5275494-261-3424662-302-7817
$randomPhoneNumberExt随机 12 位电话号码(国外)27-199-983-386499-841-448-2775
$randomCity随机城市名(国外)SpinkahavenKorbinburghLefflerport
$randomStreetName随机街道名(国外)Kuhic IslandGeneral StreetKendrick Springs
$randomStreetAddress随机住址(国外)5742 Harvey Streets47906 Wilmer Orchard
$randomCountry随机国家名称(英文)Lao People's Democratic RepublicKazakhstanAustria
$randomCountryCode随机 2 字母的国家编码 (ISO 3166-1 alpha-2)CVMDTD
$randomLatitude随机纬度55.209927.3644-84.7514
$randomLongitude随机经度40.6609171.7139-159.9757

图片

变量名说明结果示例
$randomImage随机图片http://lorempixel.com/640/480/technics
http://lorempixel.com/640/480/food
http://lorempixel.com/640/480/business
$randomAvatarImage随机头像https://s3.amazonaws.com/uifaces/faces/twitter/johnsmithagency/128.jpg
https://s3.amazonaws.com/uifaces/faces/twitter/xadhix/128.jpg
https://s3.amazonaws.com/uifaces/faces/twitter/martip07/128.jpg
$randomImageUrl随机图片地址http://lorempixel.com/640/480
$randomAbstractImage随机抽象图片http://lorempixel.com/640/480/abstract
$randomAnimalsImage随机动物图http://lorempixel.com/640/480/animals
$randomBusinessImage随机商务图http://lorempixel.com/640/480/business
$randomCatsImage随机猫的图http://lorempixel.com/640/480/cats
$randomCityImage随机城市图http://lorempixel.com/640/480/city
$randomFoodImage随机食物图http://lorempixel.com/640/480/food
$randomNightlifeImage随机夜生活图http://lorempixel.com/640/480/nightlife
$randomFashionImage随机时尚图http://lorempixel.com/640/480/fashion
$randomPeopleImage随机人物图http://lorempixel.com/640/480/people
$randomNatureImage随机自然风景图http://lorempixel.com/640/480/nature
$randomSportsImage随机运动图http://lorempixel.com/640/480/sports
$randomTechnicsImage随机科技图http://lorempixel.com/640/480/technics
$randomTransportImage随机交通图http://lorempixel.com/640/480/transport
$randomImageDataUri随机图片data URIdata:image/svg+xml;charset=UTF-8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20version%3D%221.1%22%20baseProfile%3D%22full%22%20width%3D%22undefined%22%20height%3D%22undefined%22%3E%20%3Crect%20width%3D%22100%25%22%20height%3D%22100%25%22%20fill%3D%22grey%22%2F%3E%20%20%3Ctext%20x%3D%220%22%20y%3D%2220%22%20font-size%3D%2220%22%20text-anchor%3D%22start%22%20fill%3D%22white%22%3Eundefinedxundefined%3C%2Ftext%3E%20%3C%2Fsvg%3E

Finance

变量名说明结果示例
$randomBankAccountA random 8-digit bank account number094540736565344075728757
$randomBankAccountNameA random bank account name (e.g. savings account, checking account)Home Loan AccountChecking AccountAuto Loan Account
$randomCreditCardMaskA random masked credit card number362258156257
$randomBankAccountBicA random BIC (Bank Identifier Code)EZIAUGJ1KXCUTVJ1DIVIPLL1
$randomBankAccountIbanA random 15-31 character IBAN (International Bank Account Number)MU20ZPUN3039684000618086155TKZ
BR7580569810060080800805730W2
XK241602002200395017
$randomTransactionTypeA random transaction type (e.g. invoice, payment, deposit)invoicepaymentdeposit
$randomCurrencyCodeA random 3-letter currency code (ISO-4217)CDFZMKGNF
$randomCurrencyNameA random currency nameCFP FrancCordoba OroPound Sterling
$randomCurrencySymbolA random currency symbol$£
$randomBitcoinA random bitcoin address3VB8JGT7Y4Z63U68KGGKDXMLLH5
1GY5TL5NEX3D1EA0TCWPLGVPQF5EAF
14IIEXV2AKZAHSCY2KNYP213VRLD

Business

变量名说明结果示例
$randomCompanyNameA random company nameJohns - KassulkeGrady LLC
$randomCompanySuffixA random company suffix (e.g. Inc, LLC, Group)IncLLCGroup
$randomBsA random phrase of business speakkiller leverage schemas,
bricks-and-clicks deploy markets,
world-class unleash platforms
$randomBsAdjectiveA random business speak adjectiveviral24/724/365
$randomBsBuzzA random business speak buzzwordrepurposeharnesstransition
$randomBsNounA random business speak noune-servicesmarketsinterfaces

Catchphrases

变量名说明结果示例
$randomCatchPhraseA random catchphraseFuture-proofed heuristic open architecture,
Quality-focused executive toolset,
Grass-roots real-time definition
$randomCatchPhraseAdjectiveA random catchphrase adjectiveSelf-enablingBusiness-focusedDown-sized
$randomCatchPhraseDescriptorA random catchphrase descriptorbandwidth-monitoredneeds-basedhomogeneous
$randomCatchPhraseNounRandomly generates a catchphrase nounsecured linesuperstructure,installation

#Databases

变量名说明结果示例
$randomDatabaseColumnA random database column nameupdatedAttokengroup
$randomDatabaseTypeA random database typetinyinttext
$randomDatabaseCollationA random database collationcp1250_binutf8_general_cicp1250_general_ci
$randomDatabaseEngineA random database engineMyISAMInnoDBMemory

Dates

变量名说明结果示例
$randomDateFutureA random future datetimeTue Mar 17 2020 13:11:50 GMT+0530 (India Standard Time),
Fri Sep 20 2019 23:51:18 GMT+0530 (India Standard Time),
Thu Nov 07 2019 19:20:06 GMT+0530 (India Standard Time)
$randomDatePastA random past datetimeSat Mar 02 2019 09:09:26 GMT+0530 (India Standard Time),
Sat Feb 02 2019 00:12:17 GMT+0530 (India Standard Time),
Thu Jun 13 2019 03:08:43 GMT+0530 (India Standard Time)
$randomDateRecentA random recent datetimeTue Jul 09 2019 23:12:37 GMT+0530 (India Standard Time),
Wed Jul 10 2019 15:27:11 GMT+0530 (India Standard Time),
Wed Jul 10 2019 01:28:31 GMT+0530 (India Standard Time)
$randomWeekdayA random weekdayThursdayFridayMonday
$randomMonthA random monthFebruaryMayJanuary

Domains, Emails and Usernames

变量名说明结果示例
$randomDomainNameA random domain namegracie.bizarmando.biztrevor.info
$randomDomainSuffixA random domain suffixorgnetcom
$randomDomainWordA random unqualified domain namegwenjadendonnell
$randomEmailA random email addressPablo62@gmail.comRuthe42@hotmail.comIva.Kovacek61@hotmail.com
$randomExampleEmailA random email address from an “example” domainTalon28@example.comQuinten_Kerluke45@example.netCasey81@example.net
$randomUserNameA random usernameJarrell.GutkowskiLottie.Smitham24Alia99
$randomUrlA random URLhttps://anais.nethttps://tristin.nethttp://jakob.name

Files and Directories

变量名说明结果示例
$randomFileNameA random file name (includes uncommon extensions)neural_sri_lanka_rupee_gloves.gdoc,
plastic_awesome_garden.tif,
incredible_ivory_agent.lzh
$randomFileTypeA random file type (includes uncommon file types)modelapplicationvideo
$randomFileExtA random file extension (includes uncommon extensions)warbookfsc
$randomCommonFileNameA random file namewell_modulated.mpg4,
rustic_plastic_tuna.gif,
checking_account_end_to_end_robust.wav
$randomCommonFileTypeA random, common file typeapplicationaudio
$randomCommonFileExtA random, common file extensionm2vwavpng
$randomFilePathA random file path/home/programming_chicken.cpio,
/usr/obj/fresh_bandwidth_monitored_beauty.onetoc,
/dev/css_rustic.pm
$randomDirectoryPathA random directory path/usr/bin/root/usr/local/bin
$randomMimeTypeA random MIME typeaudio/vnd.vmx.cvsd,
application/vnd.groove-identity-message,
application/vnd.oasis.opendocument.graphics-template

Stores

变量名说明结果示例
$randomPriceA random price between 100.00 and 999.00531.55488.76511.56
$randomProductA random productTowelsPizzaPants
$randomProductAdjectiveA random product adjectiveUnbrandedIncredibleTasty
$randomProductMaterialA random product materialSteelPlasticFrozen
$randomProductNameA random product nameHandmade Concrete TunaRefined Rubber Hat
$randomDepartmentA random commerce categoryToolsMoviesElectronics

Grammar

变量名说明结果示例
$randomNounA random nounmatrixbusbandwidth
$randomVerbA random verbparsequantifynavigate
$randomIngverbA random verb ending in "-ing"synthesizingnavigatingbacking up
$randomAdjectiveA random adjectiveauxiliarymulti-byteback-end
$randomWordA random wordwithdrawalinfrastructuresIB
$randomWordsSome random wordsSamoa Synergistic sticky copying Grocery,
Corporate Springs,
Christmas Island Ghana Quality
$randomPhraseA random phraseYou can't program the monitor without navigating the mobile XML program!,
overriding the capacitor won't do anything, we need to compress the optical SMS transmitter!,
I'll generate the virtual AI program, that should microchip the RAM monitor!

Lorem Ipsum

变量名说明结果示例
$randomLoremWordA random word of lorem ipsum textest
$randomLoremWordsSome random words of lorem ipsum textvel repellat nobis
$randomLoremSentenceA random sentence of lorem ipsum textMolestias consequuntur nisi non quod.
$randomLoremSentencesA random 2-6 sentences of lorem ipsum textEt sint voluptas similique iure amet perspiciatis vero sequi atque.
 Ut porro sit et hic. Neque aspernatur vitae fugiat ut dolore et veritatis.
Ab iusto ex delectus animi. Voluptates nisi iusto. Impedit quod quae voluptate qui.
$randomLoremParagraphA random paragraph of lorem ipsum textAb aliquid odio iste quo voluptas voluptatem dignissimos velit.
Recusandae facilis qui commodi ea magnam enim nostrum quia quis.
Nihil est suscipit assumenda ut voluptatem sed. Esse ab voluptas
odit qui molestiae. Rem est nesciunt est quis ipsam expedita consequuntur.
$randomLoremParagraphs3 random paragraphs of lorem ipsum textVoluptatem rem magnam aliquam ab id aut quaerat.
Placeat provident possimus voluptatibus dicta velit non aut quasi.
 Mollitia et aliquam expedita sunt dolores nam consequuntur.
Nam dolorum delectus ipsam repudiandae et ipsam ut voluptatum totam.
Nobis labore labore recusandae ipsam quo.
Voluptatem occaecati omnis debitis eum libero. Veniam et cum unde.
 Nisi facere repudiandae error aperiam expedita optio quae consequatur qui.
Vel ut sit aliquid omnis. Est placeat ducimus.
Libero voluptatem eius occaecati ad sint voluptatibus laborum provident iure.
Autem est sequi ut tenetur omnis enim. Fuga nisi dolor expedita.
Ea dolore ut et a nostrum quae ut reprehenderit iste.
Numquam optio magnam omnis architecto non. Est cumque laboriosam
quibusdam eos voluptatibus velit omnis.
Voluptatem officiis nulla omnis ratione excepturi.
$randomLoremTextA random amount of lorem ipsum textQuisquam asperiores exercitationem ut ipsum.
Aut eius nesciunt. Et reiciendis aut alias eaque.
 Nihil amet laboriosam pariatur eligendi. Sunt ullam ut sint natus ducimus.
 Voluptas harum aspernatur soluta rem nam.
$randomLoremSlugA random lorem ipsum URL slugeos-aperiam-accusamusbeatae-id-molestiaequi-est-repellat
$randomLoremLines1-5 random lines of lorem ipsumDucimus in ut mollitia.\nA itaque non.\nHarum temporibus
nihil voluptas.\nIste in sed et nesciunt in quaerat sed.
扫二微码
上一章:环境变量 / 全局变量 / 临时变量 下一章:Socket 接口快速上手

最近更新 免责声明 关于我们

Copyright © 2004-2021 前端教程 qianduan.cn All Rights Reserved   陕ICP备2021014585号-1 陕公网安备 61012402000223号 前端教程

友情链接:  前端工具 前端插件