API Automation
Post Man (1/3)
Advantages :
- Can create a flow API that fulfils the jobs that are repetitive and run the flow to create the data for testing.
- Can be very useful in the regression phase to test the Server-Side API with necessary test cases in the test panel and reduce the unnecessary hiccups.
- Will Helpful in maintaining the API in the Flow and can test the API With a Single Click.
- Can Create Monitors and keep the track on the health of the API.
Pre Requisites :
- Knowledge of Http Requests and the status code.
- The Standard input and output of the server-side API for creating the test cases.
- The Basic understanding to run the API in Postman.
- Knowledge of JSON objects.
MY_VALUE is the Value from the response or value of your choice.
Variables :
Variables are important while a flow is being executed. It plays an important role in sending dynamic data for requests, correlating the output of an API to another API, to create the test scenarios in test panel based on the output of a request.
Setting a Variable :
Global
pm.globals.set(“myVariable”, MY_VALUE);
Environment
pm.environment.set(“myVar”, MY_VAL);
Data variables
Can only be set from a CSV or a JSON file from runner dataset.
Get Test Automation Solutions’s stories in your inbox
Join Medium for free to get updates from this writer.
Getting a Variable :
in scripts (pre-request, tests)
Global
pm.globals.get(“myVariable”);
Environment
pm.environment.get(“myVariable”);
Any Variable :
pm.iterationData.get(“myVariable”);
Usage in the request builder:
Syntax: {{myVariable}}
Request URL: http://{{domain}}/users/{{userId}}
Headers (key, value): X-{{myHeaderName}}
Body: { “id”: “{{userId}}”, “name”: “John Doe”}
REMOVING:
Global
pm.globals.unset(“myVariable”);
pm.globals.clear();
Environment
pm.environment.unset(“myVariable”);
pm.environment.clear();
In the Next Blog will be continuing on the test scripts and schema compare of the response.
Thanks




