[Postman] How Postman built-in variables can help you in Automating your work.
Ahmed Ramzy
Senior Software Testing Engineer | Bug Hunter | Security Testing | Dedicated to Ensuring Better Secure Websites Worldwide
Postman has a lot of built-in variables that helps you in your testing flow
But before we go through this, lets get an example on how these variables will help you in your testing.
Scenario #1: You have a form and you are testing it, the form API takes a lot of fields but you have a restriction that the email must be unique, so to test this API multiple time, you have to change the email manually every time.
Solution: You can use postman built-in email variable to automatically get a random email every time you send a request.
Clear ? Let's start.
Postman variables starts with $, and you have to put them inside curly brackets as this: {{$variable_name}}
Postman has an autocomplete which helps you in searching for the variable that you might need in your testing process
Here I'll explain some of Postman variables and where you might need them.
In Registration form as an example
领英推荐
{{$randomFirstName}}? // returns a random first name {{$randomLastName}} // returns a random last name {{$randomFullName}} // returns a random full name {{$randomEmail}}? ? // returns a {{$randomPassword}}? // returns a random password {{$randomPhoneNumber}} // returns a random phone number {{$randomAvatarImage}} // returns random avatar image {{$randomCountry}}? ? // returns random country {{$randomCity}}? ? ? // returns random City? {{$randomJobType}}? ? // returns random job type {{$randomJobTitle}}? ? //returns random job title {{$randomStreetAddress}} // returns random street address {{$randomDateFuture}} // returns a date in the future {{$randomDatePast}} // returns a past date
Banking APIs as an example:
{{$randomBankAccount}}? ? ? // returns numbe {{$randomBankAccountIban}}? // returns random bank acc. IBAN {{$randomBankAccountName}}? // returns a random bank account name {{$randomCreditCardMask}}? ?// returns random last 4 numbers in credit card {{$randomTransactionType}} // returns random transaction type??
Images APIs as an example:
{{$randomImageUrl}}? ? ? ? ? ?// returns random imag
{{$randomCatsImage}}? ? ? ? ? // returns random cat image? ? ??
{{$randomCityImage}}? ? ? ? ? // returns random city image
{{$randomFoodImage}}? ? ? ? ? // returns random food image
{{$randomAvatarImage}}? ? ? ? // returns random avatar image
{{$randomPeopleImage}}? ? ? ? // returns random people image
{{$randomSportsImage}}? ? ? ? // returns random sports image
{{$randomAnimalsImage}}? ? ? ?// returns random animal image
{{$randomFashionImage}}? ? ? ?// returns random fashion imagee
Generic APIs variables:
{{$randomFilePath}}? ? ? ? ?// returns a random file pat {{$randomIPV6}}? ? ? ? ? ? ?// returns a random IPV6? {{$randomUrl}}? ? ? ? ? ? ? // returns a random url {{$randomCommonFileExt}}? ? // returns a ? {{$randomMACAddress}}? ? ? ?// returns a random MAC address {{$randomLoremParagraph}}? ?// returns a random paragraph? {{$randomUUID}}? ? ? ? ? ? ?// returns a random UUIDh
That's IT.
I recommend trying this by yourself and I am sure that these are going to help you in finishing your work.
Thanks.