[Postman] How Postman built-in variables can help you in Automating your work.

[Postman] How Postman built-in variables can help you in Automating your work.

Postman has a lot of built-in variables that helps you in your testing flow and makes the testing process easier and faster, In this article we will discuss some of them.

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}}

No alt text provided for this image

Postman has an autocomplete which helps you in searching for the variable that you might need in your testing process

No alt text provided for this image

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.


要查看或添加评论,请登录

Ahmed Ramzy的更多文章

社区洞察

其他会员也浏览了