๐ Script to generate random global variable to use in request params, headers, body, etc
- create a request
- go to pre-request script
- put following script (refer example)
- run the request, so it will initial the value of your global variable
- go to the body tab of the request that you want to use global variable
- value put {{$yourGlobalVariable}}
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" |