How to use Rest Assured framework to automate the APIs
Posted By : Nargis Khan | 23-Apr-2018
In API we get the data in different format. API helps us to communicate between 2 different application.
Like How Makemytrip.com communication with AirAsia or IndiGo or SpiceJet. So how these applications are working. These applications are working or communication with/through API. Like we are talked/Communication with the English Language in the same way two application talked through API"s.
Now MakeMyTrip is Communicating with AirAsia/IndiGo they are sending some request and we are getting details and these details are getting displayed om UI is the form of HTML or some form. So these data actually coming from the API and only it's coming as a UI. Now make my trip is communicated with so many vendors through API's.
As we know there is two kind of API's Rest and Soap.Here we are discussing Rest API.Rest API's are widely used by the company's or we can say 95% company's use the Rest API to communicate with other Applications.
Why REst API's Used by most of the companies:
i)Rest has so much flexibility we get the data in a different format and it's language independent like XML, HTML.
ii)REst stands for Representational state transfer and it's an architectural style. it's not a protocol.
To Automate REst-API's we are going to Use Rest-Assured:
1)Rest-assured is an open-source java Domain-specific language.
2) Using Rest Assured we can eliminate the large amount of code to test complex API response and output.
3) It supports 2 types of format->XML and JSON.
Let create a project: Here I am using sprint suite tool for creating a maven project.

ii) Open the pom.xml file to add the dependency. which is added to the screenshot.

iii) Go to "restassured.io" website and download the Link which is marked.

Extract it and add jar file from the java build Path.
vi) Now you take an API and automate by the Selenium. Here I am using a weather API which is taken from "https://openweathermap.org/current" url. You can also login free and get an API for automation testing. Here I am Writing the small code for getting the responce of API.

v) Check the Response of API. To Generate the Result I am using a TestNG framework.

Thanks, Hope You like it.
Cookies are important to the proper functioning of a site. To improve your experience, we use cookies to remember log-in details and provide secure log-in, collect statistics to optimize site functionality, and deliver content tailored to your interests. Click Agree and Proceed to accept cookies and go directly to the site or click on View Cookie Settings to see detailed descriptions of the types of cookies and choose whether to accept certain cookies while on the site.
About Author
Nargis Khan
Nargis is certified in Manual Testing , she has done B.Tech in computer science. Her Hobbies are reading books & listening music.