Skip to content

๐Ÿ›  Script to generate random global variable to use in request params, headers, body, etc

License

Notifications You must be signed in to change notification settings

wilzokch/useful-postman-random-function-for-tests

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

18 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ›  Useful postman random function for tests

๐Ÿ›  Script to generate random global variable to use in request params, headers, body, etc

Postman screenshot

Step to generate random global variable for postman test

  1. create a request
  2. go to pre-request script
  3. put following script (refer example)
  4. run the request, so it will initial the value of your global variable
  5. go to the body tab of the request that you want to use global variable
  6. value put {{$yourGlobalVariable}}

Function list

Function Usage Example Params Data Range
randNumber(length) generate random number by length length = 1 from 0 to 9
randFixNumber(length) generate random number with leading zero by length length = 2 from 00 to 99
randNumberByRange(min, max) generate random number by range min = 2, max=5 from 2 to 5
randFixNumberByRange(min, max) generate random number with leading zero by range min = 9, max = 15 from 09 to 15
randChoice(text) generate random text from options, use / for separator text = "M/F" "M" or "F"

About

๐Ÿ›  Script to generate random global variable to use in request params, headers, body, etc

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published