API
API
Easy Integration with GUI: I can Sign up using API Testing and I can Login using GUI
Application
SOAP REST
HTTP Methods:
GET-----to retrieve the resource from server
POST---create recourse on database
PUT-----update the resource on database
PATCH—partially update the resource on database
DELETE—delete the existing resource on database
POSTMAN
It’s an API Testing tool for Manual.
DDT should be run using Runner in Postman tool by mentioning no. of iterations and delay
time.
Variables:
Variables will be used for script reusability means suppose I have multiple requests and if there
is any change in URL I don’t need to go and change all requests URL just create one variable like
URL (either global/local) = http://localhost:3000 then provide this URL to every request
Example {{URL }}Students/1
Environment variable will be used to executes our resources on multiple environments like QA,
DEV and BETA or Production
Note: It will accessible only when we switch our environment to particular environment
(QA_Environent or DEV_Environemt etc.)
Local Variables will be created under Inside Pre-request Script and its applicable to particular
request only.
pm.variables.get (“url_local”,” http://localhost:3000/”)
11) What is meant by the term Environment with respect to Postman?
An Environment in Postman is a set of Key-value pairs.
They are two types of environment Global, Local these defines the scope of the variable to use
in the request
12) Can we have two global scope variables with the same name in Postman?
Since Global variables are global without any environment, they cannot have duplicate names
as it creates confusion for the software but Local variables can have same name but in different
environments.
13)Which one has the higher priority in Postman? A global variable or a Local variable?
In Postman, if two variables have same name one being local and one being global
then the higher priority is of the local variable. It will override the global variable.
Example:
Request1-Output
Input-Request2
Authentication:
15.What is the difference between Authentication and Authorization?
Types of authentication:
Basic Authentication (need to provide username and password uses non encrypted
base64 encoding)
OAuth1(Whenever request is made server sends auth token first then we need to use
that auth token to get access token from the server by using this access token we do
further testing)
17. What is the difference between Postman Monitors and Postman Collection Runner?
The Postman Monitor is an automated way of running collections. Collections are triggered
automatically as per specified parameters whereas Postman collections require some manual
effort to start and monitor the execution.
A Postman monitor will run your collection at regular user defined intervals till the time you
have specified your collection will be run even if your system has shut down as it is continued
through postman cloud.
A postman collection runner runs the collection for the iteration you want to.
It will be stopped when you stop the software and is not automated.
To find proper json for id, email go through the JsonPathFinder (google it).
Handling/Validating responses that don’t parse:
header validation
pm.test ("header value”, function ())
{
pm. expect (pm.responce.headers.get("content-Type")).to.eql ("application/json;charset=utf-
8");
}
response time
pm.test("response time less than 20 ms”, function())
{
pm.expect (pm.response.responceTime).to.be.below(20)
};
RestAssured:
Representational state transfer
Rest Assured
JSON Path----used to handle and validate the headers, response body
JSON Schema validator
hamcrest---for equals method in body validations
TestNG
Json
Gson
Scribejava-apis
XML Schema validator
Along with these following Static imports need to be pasted in classes
import static io.restassured.RestAssured. *;
import static io.restassured.matcher.RestAssuredMatchers.*;
import static org.hamcrest.Matchers.*;
18.What are all we can validate in APIs?
In the API We can validate Headers, Status Codes, body and Response etc.
Headers/Cookies: Means We are sending additional details to API to process our request.
Example: Authentication details (username and password)
26.Why is API Testing considered as the most suitable form for automation testing?
Because
It provides the most stable interface
It is easier to maintain and provides fast feedback
30.What are the exceptions (status codes) that you got when you work with your project?
401-------------Unauthorized (If we trying to access with wrong credentials like wrong username
and password or wrong access key)
404-------------Not found (if particular data is not present in the server but we are trying to
access that)
405-------------Method not allowed (if we use get method in place of post method)
E.g.:
SessionFilter session = new SessionFilter ();
use this Filter(session) in other requests for Authentication.
32.STATUS CODES:
200-------------SUCCESS
-----------------------
200-------------Success
201-------------When we creating new recourse
200-------------When you update new recourse
204-------------When you delete some content successfully.
400-------------CLIENT ERRORS
-----------------------------
400-------------Bad Request (like sending with wrong URL or wrong payload, pathpara, querypara
etc.)
401-------------Unauthorized (If we trying to access with wrong credentials like wrong username
and password or wrong access key)
403-------------Forbidden (client logged in but don’t have proper authorization to access that
particular content)
404-------------Not found (if particular data is not present in the server but we are trying to
access that)
405-------------Method not allowed (if we use get method in place of post method)
500--------------SERVER ERRORS
------------------------------
500--------------Internal server error
501--------------Not implemented (The server either does not recognize the request method, or it
cannot fulfill the request)
502--------------Bad gateways (any network related issues)
503--------------Service unavailable (means when server is down)
504--------------Gateway timeout (means many users hitting the server at the same then server
delays giving response)