postman delivered the current timestamp

1 requests a dynamic parameter (e.g., time stamp)

Sometimes when we request interface, you need to bring the current time stamp this dynamic parameters, then the postman can not automatically fill it.

We can use pre-request script postman's

First, we use in this manner to fill in the requested parameter value Parameter value {{var}}

 

 

Then add the pre-request script js code as follows. Var the same name which is defined in the previous step, you can modify according to their needs.

pm.environment.set('var',Math.round(new Date()/1000)+10);

 

After adding the following FIG.

 

View background timestamp request log, when the parameter value changes in units of seconds

 

 

 2 requests the respective test

If the data returned by the request to be processed, can be used to test verification test script, click postman Bootcamp below, the FIG. Menu, there is provided a better tutorials, including pre-request script described above.

 

 

 

Click Automated testing, click on the secondary menu Working on learning test scripts, and follow the tutorial step by step you can.

 

 

 

 

Guess you like

Origin www.cnblogs.com/kala00k/p/11517941.html