You are on page 1of 36

-----------------------------------------------------------------------------------

-----------------
Section 1: REST API Basics and Terminology 0 / 6|55min
-----------------------------------------------------------------------------------
-----------------
1. Course FAQ's/Syllabus (** Must Watch****) 12min

-----------------------------------------------------------------------------------
---------
2. Introduction to REST API and where it is used in Project Architecture 10min
-----------------------------------------------------------------------------------
---------
2. Introduction to REST API and where it is used in Project Architecture 10min
what problems in designing?

Ex:

All the ui elements—call as client 


Once book hotel – data stored in server side(in DB)

It gets data from front end, server side create reservation() gets executed and
checks with given data any rooms are there or not ..if there is availability..then
it creates reservation…and pass id .

From hotel appl. ,collect all hotel info across the world and display in their
website
Ex? Make mytrip

How hotel app can talk to Mariot app code?


Both are designed by diff companies…
Mariot will not give code to other companies..

Ex> mariot developed by java lang in earlier,


Update for new technologies—angular js

Back end – java


Angular js cannot call java method code---
These are some problems—in designing…
Now API comes into picture—how it will solve the problem…
*************ends here
Revision: Done
some problems in designing:
one comapny code wont be given to other company
- one tech cannot call other tehcnology oode..

-----------------------------------------------------------------------------------
-----------------------

3. Real time Usage of API's in industry with Examples 9min


-----------------------------------------------------------------------------------
-----------------------
3. Real time Usage of API's in industry with Examples 9min

Now we will look into solution for this problem, when we have diff stack in botth
front end and backend
ual
Now we r bringing new feature called API..which actually acts interaction b/w
client and server..
Middle tier layer

Http – independent of lang

Develper designs API in such a way that it takes data from front end and sends data
to server….
It gives reponse to api
Api uses xml or json to send back the response to front end…
Front end angularjs lang parse the json and extract value s and displays in the
front end..
Api used to send data from front end and receive reps front back end

Exposing an API..
Wikie pedia def:

API- interface or communication protocol b/w client and server..


************************ends here
Revision: Done
Ex:
diff technology appl - cannot communictae with other techn appl
So API came in the picture..
Def API

-----------------------------------------------------------------------------------
-----------------------
4. Understanding GET, POST, PUT DELETE Http Crud operations of API 12min
-----------------------------------------------------------------------------------
-----------------------
4. Understanding GET, POST, PUT DELETE Http Crud operations of API 12min
When we say an API, there r diff ways to create APIS a nd also we need to follow
set of rules to follow..
The most common API-REST
We have SOAP webservice..
Some times Webservice and API r terms are interchangeable t
There will subtle difff..
SOAP are legacy from long time we are using over years.
From ages
-many cond and restrictions and that provides tight autherisation and
authentication as well to communicate APIS
-REST also does the same .. but it is light wt protocaol..
Majority apps – now uses REST aPI..
Only legacy appl’s still using SOAP services ..
Ex: google, Facebook.. uses REST API..

Testing REST—has good market now..


Before going to REST, understand reminology

End point:

Httpmethods:
Get,post,put-, delete methos of http
When we want to talk to REST API, we use http get(), post()…etc
Get()

Ex: getting reservation of existing one bay id..


When we wanto get data from server..-
Rule- we have to use.. each method has specific purpose..
Post:


Boking new reservation
Put:

Updating phone no for reveration


Wee will see in postman tool’

*********************ends here
Revision:
what are http methods ?
get
post
put-
Delete -

what is endpoint/Base URI?

URI --?

Diff SOAP and REST?

------------------------------------------------------------------------
5. What are Path,Query Parameters & Headers in Rest API 11min
------------------------------------------------------------------------
5. What are Path,Query Parameters & Headers in Rest API 11min
Resource: any funcaiotnality name --

google.com/maps
google.com/search
google.com/images

Param:

Images/1202 id no

Ex:
loper

Query param= uses ?


When we get reposnse from server, then front edn develop reads the response from
json and exract the data from repso and displays data in html format.. and in gui..

End pointconstrunction:
BaseURI/Resourcename

Header / cookies:
Additional data details to API..
What contetnt – type – xml/jsoon fomat..
*********** ends here
Revisions :
types of parameters?
path
query -- > ?boookname="alchmist"

------------------------------------------------------------------------
6. Notes Download 1min
------------------------------------------------------------------------
Notes Download

End point: Address where API is hosted on the Server.

HTTP methods which are commonly used to communicate with Rest API’s are

GET, POST, PUT, and DELETE

GET- The GET method is used to extract information from the given server using a
given URI. While using GET request, it should only extract data and should have no
other effect on the data. No Payload/Body required

How to send input data in GET?


Ans: Using Query Parameters

POST- A POST request is used to send data to the server, for example, customer
information, file upload, etc. using HTML forms.

How to send input data in POST?


Ans: Using Form Parameters /Body Payload

PUT- Replaces all current representations of the target resource with the uploaded
content.

DELETE- Removes all current representations of the target resource given by a URI.

Resources:
Resources represent API/Collection which can be accessed from the Server

Google.com/maps
google.com/search
google.com/images

Path Parameters:
Path parameters are variable parts of a URL path. They are typically used to point
to a specific resource within a collection, such as a user identified by ID

https://www.google.com/Images/1123343
https://www.google.com/docs/1123343
https://amazon.com/orders/112

https://www.google.com/search?
q=newyork&oq=newyork&aqs=chrome..69i57j0l7.2501j0j7&sourceid=chrome&ie=UTF-8
Query Parameters:
Query Parameter is used to sort/filter the resources.

Query Parameters are identified with?””

https://amazon.com/orders?sort_by=2/20/2020

Headers/Cookies:

Headers represent the meta-data associated with the API request and response. In
layman terms, we were sending Additional details to API to process our request.
Example : Authorization details

End Point Request URL can be constructed as below


Base URL/resource/(Query/Path)Parameters

-----------------------------------------------------------------------------------
-----------------
Section 2: 5 hours of Java Tutorials for Basics brushup 0 / 1|1min
-----------------------------------------------------------------------------------
-----------------
7. brush up on Java concepts 1min

-----------------------------------------------------------------------------------
-----------------
Section 3: Getting started with REST API Testing 0 / 6|36min
-----------------------------------------------------------------------------------
-----------------
8. Video Player Setting tips for Best Experience in viewing course 3min
-----------------------------------------------------------------------------------
-----------------

-----------------------------------------------------------------------------------
-----------------
9. Introduction to POSTMAN and Google Maps API's 8min
-----------------------------------------------------------------------------------
-----------------
Click 3 dot icons from crated collection.


Clk add req


Req name=

Save ..

Req stored in collection. Or proj


Dbl clik on request - Add place in collection

Here fill the required details and clk send to submit request..


Entered endurl
Get reurce name :

Add resource name to endpoint


Query param:

Notes;
Google Maps Add API (POST):
This API Will add new place into Server

Complete URL :https://rahulshettyacademy.com/maps/api/place/add/json?key=qaclick123

Base URL:https://rahulshettyacademy.com
Resource:/maps/api/place/add/json
Query Parameters: key =qaclick123
Http Method:POST
Sample Body :
{
"location": {
"lat": -38.383494,
"lng": 33.427362
},
"accuracy": 50,
"name": "Frontline house",
"phone_number": "(+91) 983 893 3937",
"address": "29, side layout, cohen 09",
"types": [
"shoe park",
"shop"
],
"website": "http://google.com",
"language": "French-IN"
}

Sample Response

{
"status": "OK",
"place_id": "928b51f64aed18713b0d164d9be8d67f",
"scope": "APP",
"reference":
"736f3c9bec384af62a184a1936d42bb0736f3c9bec384af62a184a1936d42bb0",
"id": "736f3c9bec384af62a184a1936d42bb0"
}
Google Maps Delete API (POST):
This API Will delete existing place from Server

Complete URL: https://rahulshettyacademy.com/maps/api/place/delete/json?


key=qaclick123

Base URL: https://rahulshettyacademy.com


Resource: /maps/api/place/delete/json
Query Parameters:key
Http request : DELETE

Sample Body :
{
"place_id":"928b51f64aed18713b0d164d9be8d67f"
}
Sample Response
{
"status": "OK"
}

Google Maps get Place API (GET):


This API Will get existing place details from Server

Complete URL :http://rahulshettyacademy.com/maps/api/place/get/json?


place_id=xxxx&key=qaclick123

Base URL:https://rahulshettyacademy.com
Resource: /maps/api/place/get/json
Query Parameters: key, place_id //( place_id value comes from Add place
response)
Http request: GET
Note: Key value is hardcoded and it is always qaclick123
Sample Response for the Provided Place_Id
{

"location":{

"lat" : -38.383494,

"lng" : 33.427362

},

"accuracy":50,

"name":"Frontline house",

"phone_number":"(+91) 983 893 3937",

"address" : "29, side layout, cohen 09",

"types": ["shoe park","shop"],

"website" : "http://google.com",
"language" : "French-IN"

Google Maps Put Place API (PUT):


This API Will update existing place in Server with new values

Complete URL :http://rahulshettyacademy.com/maps/api/place/get/json?


place_id=xxxx&key=qaclick123

Base URL:https://rahulshettyacademy.com
Resource: /maps/api/place/update/json
Query Parameters: key
Http Method:PUT -
Note: Key value is hardcoded and it is always qaclick123

Sample Request:
{
"place_id":"8d2573bdf6ceec0e474c5f388fa917fb",
"address":"70 Summer walk, USA",
"key":"qaclick123"
}

Sample Response for the Provided Place_Id


{

"location":{

"lat" : -38.383494,

"lng" : 33.427362

},

"accuracy":50,

"name":"Frontline house",

"phone_number":"(+91) 983 893 3937",

"address" : "29, side layout, cohen 09",

"types": ["shoe park","shop"],

"website" : "http://google.com",

"language" : "French-IN"

}
*************ends here
Revision: Done

how to create proj in postman ?


collection

Add Requestto collection ?

Send request --
-----------------------------------------------------------------------------------
-----------------
10. Understand Add Place API and execute it through Postman 7min
-----------------------------------------------------------------------------------
-----------------
10. Understand Add Place API and execute it through Postman 7min
Query param can be given as ?

Or
We can given in key /value pair in ‘params tab

Enter in query prams

It concatenates in endpoint url also

What method: post

By default get () is sleected in postman,,change to Post


For posting, we need to send some body..

For postind. Need to add some details what place.. latitude.longitude

Copy json body


Paste – where we have paste – body tab


99% in Rest api, body type – is json fomat only..
Clk raq, sleect json


Paste json body


Modify the data..

Check – headers section- it addes automatically ctenttype= json

Lcick send to submit request


While sending req, it goes api server, goes to specific resourcse and it reads
data from body. And gives reponse
Sample reso fomat:

Clk send


Verify response

*************ends here

Reviison: Done
how to add aplce api?
baseuril/resourcename/?Querypram=....
send body in specific fomatr if we have - json
wheere can we add query prams?
http operations?

send the request..

Verify repsonse :
we need to have API contract..

-----------------------------------------------------------------------------------
-----------------
11. Understand Get & Delete Place API using GET,Delete HTTp Methods using …11min
-----------------------------------------------------------------------------------
-----------------
11. Understand Get & Delete Place API using GET,Delete HTTp Methods using …11min
Get place:

Id- unique

Note:
Get()—body will come .

Add new request


Add anme


Save

Placeid- get from prev


Clk send


We got resp
Ex: delete place

Body- josn;

Get id


Give id


Clk send


Verif it dleted or not
Get

*********************ends here
Revision :
get place api
delete place api -- id

-----------------------------------------------------------------------------------
-----------------
12. Update Place API using PUT http method using Postman 6min
-----------------------------------------------------------------------------------
-----------------
12. Update Place API using PUT http method using Postman 6min
Add new req:


D new place
Can use put or post also..
Here it updated ony address..
Add new palce:


Body or pay load:


Add id—
Modify address
Send

Validate:


Send

Address updatd..
So far we have done manual testing…We will see in automation..

****************ends here
Revision:

update -- existing resourcse place


need body .. -json
vlaidate

-----------------------------------------------------------------------------------
----------------------
13. Google Maps POSTMAN Code Download 1min

-----------------------------------------------------------------------------------
-----------------
Section 4: Rest Assured setup for API Automation 2 / 3|34min
-----------------------------------------------------------------------------------
-----------------

14. Introduction on Test API's 9min

15. Setting up Test Project with RestAssured API's 9min

16. Build Rest API Automation Test to Add Place and


validate Status codes 17min

-----------------------------------------------------------------------------------
-----------------
Section 5: Validating the Rest API Responses 0 / 6|44min
-----------------------------------------------------------------------------------
-----------------

17. Code Download 1min

18. Assertions on Json Response Body and Headers through


Automated code 10min

19. Parsing the Json Response body using JsonPath class 9min

20. Integrating the Multiple API's with common Json response


values 7min

21. Building End to End Automation using GET, POST and PUT Http
Methods 11min

22. Importance of Junit/TestNG Assertions in validating the


responses 6min
-----------------------------------------------------------------------------------
-----------------
Section 6: Diving in Depth-Automating REST API's 0 / 7|49min
-----------------------------------------------------------------------------------
-----------------
23. Understanding Structure of Complex Nested Json and its
array notations 9min

24. Json used in this Section with Queries to solve 1min

25. Retrieving the Json Array Size and its elements using
JsonPath 8min

26. Iterating over every element of Json Array and


accessing elements in it 10min

27. Retrieving Json Nodes on Condition logic using JsonPath


8min

28. Real Time example to solve Business logic through Json


response 14min

29. Code Download 1min

-----------------------------------------------------------------------------------
-----------------
Section 7: Handling Dynamic Json Payloads with Parameterization 0 / 9|59min
-----------------------------------------------------------------------------------
-----------------
30. Why Dynamic Json payloads are important to understand 5min

31. Introduction to Library API 6min


-----------------------------------------------------------------------------------
-----------------
31. Introduction to Library API 6min


Libraay API:


These diff resources
Add book

egt book:

exX: get book by id no

Ex: delete book

----------------------------
Library API :
BaseURI :http://216.10.245.166

1. Resource : Library/Addbook.php Method : POST


Input Payload : Json:
{

"name":"Learn Appium Automation with Java",


"isbn":"bcd",
"aisle":"227",
"author":"John foe"
}

Output Json
{
"Msg": "successfully added",
"ID": "bcd227"
}

1. Resource :/Library/GetBook.php?AuthorName=somenameMethod : GET

Output Json :
Output the array of Json object books with all below details

Name : “bookname” ( String)


Isbn : “A2fdsf” (String)
Aisle : 32 (Integer)

1. Resource :Library/GetBook.php?ID=3389 - Method : GET

Output Json :
{
"book_name": "Selenium automation using Java",
"isbn": "a23hd738",
"aisle": "1223"
}

1. Resource :/Library/DeleteBook.php Method : POST

Input Payload : Json:


{

"ID" : "a23h345122332"

}
Output Response :
{

msg : book is successfully deleted”

--------------------
*********** ends here
Revision:
Explained Libarraty API
Get book
Get booj by id
Add book
Delete book

-----------------------------------------------------------------------------------
-----------------
32. Rest Assured Test for Library API Add Book http method 7min
-----------------------------------------------------------------------------------
-----------------
32. Rest Assured Test for Library API Add Book http method 7min
Add book:

Create class – DynamicJson

Define body in pay load classs:

package files;

public class payload {

public static String Addbook()


{
String body= "{\r\n" +
"\r\n" +
"\"name\":\"T5Learn Appium Automation with
Java\",\r\n" +
"\"isbn\":\"T5bcd\",\r\n" +
"\"aisle\":\"105\",\r\n" +
"\"author\":\"T5 Author\"\r\n" +
"}\r\n" +
"";
return body;

Clk send

Get id


Run

Revission:
Add book and get id
Add book:
package files;

import static io.restassured.RestAssured.given;

import org.testng.annotations.Test;

import io.restassured.RestAssured;
import io.restassured.path.json.JsonPath;

public class DynamicJson {

@Test
public void addBook()
{
RestAssured.baseURI="http://216.10.245.166";
String response= given().log().all().header("Content-
type","application/json").
body(payload.Addbook()).
when().
post("Library/Addbook.php").
then().log().all().assertThat().statusCode(200).
extract().response().asString();

JsonPath jsonobj= new JsonPath(response);


String id= jsonobj.get("ID");
System.out.println("get id="+id);

System.out.println("get msg="+jsonobj.get("Msg"));
//get id=T7bcd107
//get msg=successfully added

}
}
Body:
package files;

public class payload {

public static String Addbook()


{
String body= "{\r\n" +
"\r\n" +
"\"name\":\"T7Learn Appium Automation with
Java\",\r\n" +
"\"isbn\":\"T7bcd\",\r\n" +
"\"aisle\":\"107\",\r\n" +
"\"author\":\"T7 Author\"\r\n" +
"}\r\n" +
"";
return body;

}
********************

-----------------------------------------------------------------------------------
-----------------
33. Sending parameters to payload from Test 12min
-----------------------------------------------------------------------------------
-----------------
33. Sending parameters to payload from Test 12min

Run
Fail—as same code- or book already added..
Add data in run time for adding book

Add param

Do param


Change args isbn, aisle

package files;

import static io.restassured.RestAssured.given;

import org.testng.annotations.Test;

import io.restassured.RestAssured;
import io.restassured.path.json.JsonPath;

public class DynamicJson {

@Test
public void addBook()
{
RestAssured.baseURI="http://216.10.245.166";
String response= given().log().all().header("Content-
type","application/json").
body(payload.Addbook("ISBN101","ai101")).
when().
post("Library/Addbook.php").
then().log().all().assertThat().statusCode(200).
extract().response().asString();

JsonPath jsonobj= new JsonPath(response);


String id= jsonobj.get("ID");
System.out.println("get id="+id);

System.out.println("get msg="+jsonobj.get("Msg"));
//get id=T7bcd107
//get msg=successfully added

}
}
Run test

Ex: how can we add 100 books, DDT- Dataprovider


Revision:
Send ing param to ttest== Addbook(isle, isbn)..
Add book:
package files;

import static io.restassured.RestAssured.given;

import org.testng.annotations.Test;

import io.restassured.RestAssured;
import io.restassured.path.json.JsonPath;

public class DynamicJson {

@Test
public void addBook()
{
RestAssured.baseURI="http://216.10.245.166";
String response= given().log().all().header("Content-
type","application/json").
body(payload.Addbook("ISBN101","ai101")).
when().
post("Library/Addbook.php").
then().log().all().assertThat().statusCode(200).
extract().response().asString();

JsonPath jsonobj= new JsonPath(response);


String id= jsonobj.get("ID");
System.out.println("get id="+id);

System.out.println("get msg="+jsonobj.get("Msg"));
//get id=T7bcd107
//get msg=successfully added

}
}
Body:
package files;

public class payload {

public static String Addbook(String isbn,String aisle)


{
String body= "{\r\n" +
"\r\n" +
"\"name\":\"T7Learn Appium Automation with
Java\",\r\n" +
"\"isbn\":\"" +isbn+"\",\r\n" +
"\"aisle\":\""+aisle+"\",\r\n" +
"\"author\":\"T7 Author\"\r\n" +
"}\r\n" +
"";
return body;

}
****************ends here

-----------------------------------------------------------------------------------
-----------------
34. Understanding TestNg Data provider for parameterization 11min
-----------------------------------------------------------------------------------
-----------------

34. Understanding TestNg Data provider for parameterization 11min

@Dataprovider

Revisions:
How to use testNG Dataprovider and get into test
Code:
package files;

import static io.restassured.RestAssured.given;

import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;

import io.restassured.RestAssured;
import io.restassured.path.json.JsonPath;

public class DynamicJson {

@Test(dataProvider="BooksData")
public void addBook()
{
RestAssured.baseURI="http://216.10.245.166";
String response= given().log().all().header("Content-
type","application/json").
body(payload.Addbook("ISBN101","ai101")).
when().
post("Library/Addbook.php").
then().log().all().assertThat().statusCode(200).
extract().response().asString();

JsonPath jsonobj= new JsonPath(response);


String id= jsonobj.get("ID");
System.out.println("get id="+id);

System.out.println("get msg="+jsonobj.get("Msg"));
//get id=T7bcd107
//get msg=successfully added

@DataProvider(name="BooksData")
public Object[][] getData()
{
return new Object[][] {{"ISBN102","AI102"}, {"ISBN103","AI103"},
{"ISBN104","AI105"}};
}

}
**********ends here

Revision:
use @Dataprovider

-----------------------------------------------------------------------------------
-----------------
35. Example on Parameterization of API Tests with multiple data sets 7min
-----------------------------------------------------------------------------------
-----------------
35. Example on Parameterization of API Tests with multiple data sets 7min
Add args to test

Run

HW: to dleet data ,ultiple sets of data


Code:
package files;

import static io.restassured.RestAssured.given;

import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;

import io.restassured.RestAssured;
import io.restassured.path.json.JsonPath;

public class DynamicJson {

@Test(dataProvider="BooksData")
public void addBook(String isbn, String aisle)
{
RestAssured.baseURI="http://216.10.245.166";
String response= given().log().all().header("Content-
type","application/json").
body(payload.Addbook("ISBN101","ai101")).
when().
post("Library/Addbook.php").
then().log().all().assertThat().statusCode(200).
extract().response().asString();

JsonPath jsonobj= new JsonPath(response);


String id= jsonobj.get("ID");
System.out.println("get id="+id);

System.out.println("get msg="+jsonobj.get("Msg"));
//get id=T7bcd107
//get msg=successfully added

@DataProvider(name="BooksData")
public Object[][] getData()
{
return new Object[][] {{"ISBN102","AI102"}, {"ISBN103","AI103"},
{"ISBN104","AI105"}};
}

}
o/p:
Request method: POST
Request URI: http://216.10.245.166/Library/Addbook.php
Proxy: <none>
Request params: <none>
Query params: <none>
Form params: <none>
Path params: <none>
Headers: Accept=*/*
Content-Type=application/json; charset=UTF-8
Cookies: <none>
Multiparts: <none>
Body:
{
"name": "T7Learn Appium Automation with Java",
"isbn": "ISBN101",
"aisle": "ai101",
"author": "T7 Author"
}
HTTP/1.1 200 OK
Date: Tue, 12 May 2020 18:37:57 GMT
Server: Apache
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST
Access-Control-Max-Age: 3600
Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers,
Authorization, X-Requested-With
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: application/json;charset=UTF-8

{
"Msg": "successfully added",
"ID": "ISBN101ai101"
}
get id=ISBN101ai101
get msg=successfully added
Request method: POST
Request URI: http://216.10.245.166/Library/Addbook.php
Proxy: <none>
Request params: <none>
Query params: <none>
Form params: <none>
Path params: <none>
Headers: Accept=*/*
Content-Type=application/json; charset=UTF-8
Cookies: <none>
Multiparts: <none>
Body:
{
"name": "T7Learn Appium Automation with Java",
"isbn": "ISBN101",
"aisle": "ai101",
"author": "T7 Author"
}
HTTP/1.1 200 OK
Date: Tue, 12 May 2020 18:37:59 GMT
Server: Apache
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST
Access-Control-Max-Age: 3600
Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers,
Authorization, X-Requested-With
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: application/json;charset=UTF-8

{
"Msg": "successfully added",
"ID": "ISBN101ai101"
}
get id=ISBN101ai101
get msg=successfully added
Request method: POST
Request URI: http://216.10.245.166/Library/Addbook.php
Proxy: <none>
Request params: <none>
Query params: <none>
Form params: <none>
Path params: <none>
Headers: Accept=*/*
Content-Type=application/json; charset=UTF-8
Cookies: <none>
Multiparts: <none>
Body:
{
"name": "T7Learn Appium Automation with Java",
"isbn": "ISBN101",
"aisle": "ai101",
"author": "T7 Author"
}
HTTP/1.1 200 OK
Date: Tue, 12 May 2020 18:37:59 GMT
Server: Apache
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST
Access-Control-Max-Age: 3600
Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers,
Authorization, X-Requested-With
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: application/json;charset=UTF-8

{
"Msg": "successfully added",
"ID": "ISBN101ai101"
}
get id=ISBN101ai101
get msg=successfully added
PASSED: addBook("ISBN102", "AI102")
PASSED: addBook("ISBN103", "AI103")
PASSED: addBook("ISBN104", "AI105")

===============================================
Default test
Tests run: 3, Failures: 0, Skips: 0
===============================================

===============================================
Default suite
Total tests run: 3, Failures: 0, Skips: 0
===============================================

***************ends here

-----------------------------------------------------------------------------------
-----------------
36. code download 1min
-----------------------------------------------------------------------------------
-----------------
code download

import org.testng.annotations.DataProvider;

import org.testng.annotations.Test;

import static io.restassured.RestAssured.given;

import java.io.IOException;

import java.nio.file.Files;

import java.nio.file.Paths;

import io.restassured.RestAssured;
import io.restassured.path.json.JsonPath;

import io.restassured.response.Response;

import files.ReusableMethods;

import files.payLoad;

public class DynamicJson {

@Test(dataProvider="BooksData")

public void addBook(String isbn,String aisle)

RestAssured.baseURI="http://216.10.245.166";

Response resp=given().

header("Content-Type","application/json").

body(payLoad.Addbook(isbn,aisle)).

when().

post("/Library/Addbook.php").

then().assertThat().statusCode(200).

extract().response();

JsonPath js= ReusableMethods.rawToJson(resp);

String id=js.get("ID");

System.out.println(id);

//deleteBOok

@DataProvider(name="BooksData")

public Object[][] getData()

{
//array=collection of elements

//multidimensional array= collection of arrays

return new Object[][] {{"ojfwty","9363"},{"cwetee","4253"}, {"okmfet","533"} };

-----------------------------------------------------------------------------------
-----------------
37. How to handle with static json payloads 10min
-----------------------------------------------------------------------------------
-----------------
37. How to handle with static json payloads 10min

Copy json body

Save as
If we want to esape \

Freeformatter- json escape

Clk escape
As
U will get json body with \
Save as .json

We create json file with body given


Add this code:

Paste

Crate class –staticjosn

Cpy

Paste

Remove dataprovider

Call this method


Change the dats in json and run
Run
His
This is static jsson – body—if we want to change data, we need to open static josn
file and modify and save.

Pojo classes- later


HW???????? Not working …….
Code:
package files;

import static io.restassured.RestAssured.given;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;

import org.testng.annotations.Test;

import io.restassured.RestAssured;
import io.restassured.path.json.JsonPath;

public class StaticJson {

@Test
public void addBook() throws IOException
{
RestAssured.baseURI="http://216.10.245.166";
String response= given().log().all().header("Content-
type","application/json").
body(GenerateStringFromResource("D:\\qtp
practise\\Addbookdetails.json")).
when().
post("Library/Addbook.php").
then().log().all().assertThat().statusCode(200).
extract().response().asString();

JsonPath jsonobj= new JsonPath(response);


String id= jsonobj.get("ID");
System.out.println("get id="+id);

System.out.println("get msg="+jsonobj.get("Msg"));
//get id=T7bcd107
//get msg=successfully added

public static String GenerateStringFromResource(String path) throws


IOException {
return new String(Files.readAllBytes(Paths.get(path)));
}

}
????Recheck later
**************************Ends here
Revisio:
add static josn file externally and call from code
-----------------------------------------------------------------------------------
-----------------
38. code download 1min
-----------------------------------------------------------------------------------
-----------------
code download

import static io.restassured.RestAssured.given;

import java.io.IOException;

import java.nio.file.Files;

import java.nio.file.Paths;

import org.testng.annotations.Test;

import files.ReusableMethods;

import files.payLoad;

import io.restassured.RestAssured;

import io.restassured.path.json.JsonPath;

import io.restassured.response.Response;

public class StaticJson {

@Test

public void addBook() throws IOException

RestAssured.baseURI="http://216.10.245.166";

Response resp=given().

header("Content-Type","application/json").

body(GenerateStringFromResource("C:\\Users\\rahul\\Documents\\Addbookdetails.json")
).

when().

post("/Library/Addbook.php").

then().assertThat().statusCode(200).

extract().response();
JsonPath js= ReusableMethods.rawToJson(resp);

String id=js.get("ID");

System.out.println(id);

//deleteBOok

public static String GenerateStringFromResource(String path) throws IOException {

return new String(Files.readAllBytes(Paths.get(path)));

-----------------------------------------------------------------------------------
-----------------
Section 8: Real world Example-Automating Jira API's 0 / 13|1hr 43min
-----------------------------------------------------------------------------------
-----------------
39. Please note 1min

-----------------------------------------------------------------------------------
-----------------
40. How Jira API Works? 11min
-----------------------------------------------------------------------------------
-----------------
40. How Jira API Works 11min
One more REST API- JIRA

JIRA installed..

Clk proj

Drag and drop to Inprogress.


Move to Done ….once validation over..
We r using jira REST API as they exposed it..

Sample issue

Here we can create proj and issue..


They exposed JIRA as functional TC’s Failed.. it should send req to create new
issue.. in JIRA..
Active sprint:

Download JIRA

Lot of API’s..

Run .exe
Next…
Don’t change any settings..

t
create user name and pwd –
always use windows user credentials ---

Search jira rest api

Scroll down

**********
40. How Jira API Works 11min
One more REST API- JIRA

JIRA installed..

Clk proj

Drag and drop to Inprogress.


Move to Done ….once validation over..
We r using jira REST API as they exposed it..

Sample issue

Here we can create proj and issue..


They exposed JIRA as functional TC’s Failed.. it should send req to create new
issue.. in JIRA..
Active sprint:


Download JIRA

Lot of API’s..

Run .exe
Next…
Don’t change any settings..

t
create user name and pwd –
always use windows user credentials ---

Search jira rest api

Scroll down

Revision:
JIRA REST Api
Down load JIRa s/w

Sections:

To do taks
In progress
Done

*************ends here

Revision:
JIRA REST Api
Down load JIRa s/w

Sections:

To do taks
In progress
Done

*************ends here

-----------------------------------------------------------------------------------
-----------------
41. Important Note 1min
-----------------------------------------------------------------------------------
-----------------
Important Note

In the Next lecture, I will show cookie based Authentication for Jira Server API.

Use below official Jira link for reference to know more about this topic

https://developer.atlassian.com/server/jira/platform/cookie-based-authentication/

https://docs.atlassian.com/software/jira/docs/api/REST/7.6.1/

-----------------------------------------------------------------------------------
-----------------
42. Cookie Authentication API for Jira requests 16min
-----------------------------------------------------------------------------------
-----------------

-----------------------------------------------------------------------------------
-----------------
43. Jira GET,POST API Scripting for creating bugs 14min
-----------------------------------------------------------------------------------
-----------------

-----------------------------------------------------------------------------------
-----------------
44. Defining Path Parameters in Rest Assured code using Add Comment API 13min
-----------------------------------------------------------------------------------
-----------------

-----------------------------------------------------------------------------------
-----------------
45. Importance of Session Filter cookie in Rest Assured Code 10min
-----------------------------------------------------------------------------------
-----------------

-----------------------------------------------------------------------------------
-----------------
46. Important Note 1min
-----------------------------------------------------------------------------------
-----------------

-----------------------------------------------------------------------------------
-----------------
47. Sending Attachments to Rest API using MultiPart method in Rest Assured 12min
-----------------------------------------------------------------------------------
-----------------

-----------------------------------------------------------------------------------
-----------------
48. Integrating Query Params and Path Params in single test to restrict results
7min
-----------------------------------------------------------------------------------
-----------------

-----------------------------------------------------------------------------------
-----------------
49. Parsing Complex Jira Json response to retrieve the added Comment with code …
14min
-----------------------------------------------------------------------------------
-----------------

-----------------------------------------------------------------------------------
-----------------
50. Importance of Assertions and Https Validations on Rest API's 5min
-----------------------------------------------------------------------------------
-----------------

-----------------------------------------------------------------------------------
-----------------
51. Code Download 1min
-----------------------------------------------------------------------------------
-----------------
Section 9: Handling Google/Facebook oauth 2.0 Autho… 0 / 5|1hr 8min
-----------------------------------------------------------------------------------
-----------------

52. Introduction to OAuth 2.0 and different Grant types 12min

53. Understand Grant Type Authorization flow with real time example 20min

54. Flow procedure in achieving OAuth 2.0 Authentication mechanism 25min

55. Details on Practise OAuth 2.0 project to retrieve Courses list 10min

56. Postman Projects Download 1min


-----------------------------------------------------------------------------------
-----------------
Section 10: Rest Assured Automation for OAuth 2.0 Authorization code 0 / 5|50min
-----------------------------------------------------------------------------------
-----------------
57. Building up Rest Assured Automation Test for the OAuth Project 15min

58. Integration Web UI Automation to generate Authorization code 7min

59. Formatting URL String to retrieve code using java methods 15min

60. Code download 1min

61. How to deal with Client Credentials Grant type for OAuth flow 13min
-----------------------------------------------------------------------------------
-----------------
Section 11: Deserialization using POJO classes with Rest Assured 0 / 9|1hr 45min
-----------------------------------------------------------------------------------
-----------------
62. What is Serialization and Deserialization in Rest Assured 15min

63. Libraries needed to support Serialization in Rest Assured 12min

64. Strategies in Parsing Complex nested Json using POJO classes 19min

65. Creating POJO classes for the real time Nested Array Json 17min

66. End to end Automation examples using POJO Deserialization 13min

67. Solving Complex Queries from Json with simple POJO methods -Part 1 13min

68. Solving Complex Queries from Json with simple POJO methods-Part 2 16min

69. How to showcase API Testing experience to recruiters? 1min

70. Code download 1min


-----------------------------------------------------------------------------------
-----------------
Section 12: Serialization of Input Payload using Google Maps API Ex… 0 / 4|34min
-----------------------------------------------------------------------------------
-----------------
71. Google Maps Add Place Json to implement Serialization 10min

72. Build POJO classes for constructing Json Payload to API Rec 12-19-19 2 11min

73. Complete End to end Test case with Serialization Implementation Rec 12-19…
13min

74. Where to download Code 1min


-----------------------------------------------------------------------------------
-----------------
Section 13: Understand Request and Response Spec Builders in Rest Ass… 0 / 3|25min
-----------------------------------------------------------------------------------
-----------------
75. Significance of Spec Builders in Rest Assured Rec 12-19-19 5(builderDoc) 12min

76. Practical Example in implementing Spec Builders and optimize code Rec 1… 13min

77. Code Download 1min

-----------------------------------------------------------------------------------
-----------------
Section 14: REST API Framework Learning Plan***Must WATCH **** 0 / 1|7min
-----------------------------------------------------------------------------------
-----------------
78. Learning Plan 7min

-----------------------------------------------------------------------------------
-----------------
Section 15: Maven and Cucumber Basics (SKIP IF YOU ALREADY KNO… 0 / 17|3hr 17min
-----------------------------------------------------------------------------------
-----------------
79. Importance of Maven in Framework development 11min

80. Installing and configuring Maven 11min

81. Understanding Terminologies of Maven 16min

82. Creating Maven Project and importing into eclipse 11min

83. CheckPoint 1min

84. Introduction to Cucumber 11min

85. What is Gherkin syntax and how it works 17min

86. Understand the Cucumber Scenarios Usage 16min

87. Feature files and StepDefination Importance in Cucumber 4min

88. cucumber project creation template 12min

89. Understanding cucumber dependencies 12min

90. Understand the Terminologies of Automation 15min

91. Mapping step defination to feature file 11min

92. Tidygherkin plugin to generate step definations. 9min

93. Running the Tests with testRunner. 14min

94. importance of regular expressions in feature files 13min

95. How to reuse functions with different data 14min


-----------------------------------------------------------------------------------
-----------------
Section 16: Cucumber BDD API Framework Development from Scr… 0 / 21|3hr 48min
-----------------------------------------------------------------------------------
-----------------
96. CheckPoint before starting Framework lectures 1min

97. Creating Maven project with Cucumber Rest Assured Dependencies 10min

98. Building Cucumber Feature file for Rest Assured API Tests 10min

99. Building Test Runner and Step Definition files for Add Place API Featur… 14min

100. Implementing Real code in Step Definition files with reusable components 14min

101. Running the Test in Cucumber Standards with necessary Configuration… 15min

102. Building Utility Files and Implement Logging feature in Framework 12min

103. Implement Mechanism to drive Global property values from Properties … 12min

104. Data Driven Testing Mechanism for API Tests using Cucumber example feat… 14min

105. Parameterize API Test with multiple Data sets using Cucumber Framework f…
10min

106. What are Enum classes? How Framework can utilize the Enum concepts 20min

107. Removing Hardcoded resource details with Enum class Methods 12min

108. Build End to End Testcase with Add and Delete Place in Framework Standar…
17min

109. Build End to End Testcase in Framework Standards -2 9min

110. Creating Additional Scenarios in Framework to reuse existing Step Defini…


17min

111. Importance of Cucumber Hooks in setting up Preconditions for API Tests -5


13min

112. Optimizing the Framework Tests with all necessary validations -6 6min

113. Running the Complete Framework using Maven commands 23/1 8min

114. code download 1min

115. Generate Excellent Cucumber HTML reporting with additional Plugins -23/2 17min

116. Framework Code download 1min

-----------------------------------------------------------------------------------
-----------------
Section 17: Cucumber BDD API Framework Development from Scr… 0 / 4|19min
-----------------------------------------------------------------------------------
-----------------
117. Important Note 1min
118. Introduction to Jenkins CI tool 4min

119. Integrating the API Framework into Jenkins and triggering with New job set…
6min

120. Setting up Parameterized Jenkin Job for API Framework with multiple Tags 2…
9min
-----------------------------------------------------------------------------------
-----------------
Section 18: Understanding Version Control System GIT 0 / 10|1hr 45min
-----------------------------------------------------------------------------------
-----------------
121. Introduction to GIT 9min

122. Importance of Github and its uses 9min

123. Creating Git config and repositories 9min

124. How to push code to remote repository 2min

125. Understanding Staging and commit in git 12min

126. Add remote repository and push the committed code 9min

127. End to end working example on Git commands -1 16min

128. End to end working example on Git commands -2 2min

129. Importance of Branching in GIT 25min

130. How to resolve Merge conflicts with GIT 14min


-----------------------------------------------------------------------------------
-----------------
Section 19: Excel Integration with Rest Assured Test 0 / 14|2hr 11min
-----------------------------------------------------------------------------------
-----------------
131. what is Apace POI API & Download Instructions 10min

132. Strategy to Access Excel Data 15min

133. Getting rows and its cells from Sheet 15min

134. Retrieving Data from Excel based on condition 9min

135. Practise Exercise- Excel Driven testing -1 12min

136. Practise Exercise- Excel Driven testing -2 11min

137. Practise Exercise- Excel Driven testing -3 10min

138. Code download 1min

139. Please note 1min

140. Introducion to Library API 8min

141. Library APi Postman and Rest Assured examples 11min

142. Conversion of HashMap into Json 14min


143. Excel Integration with Rest Assured Test 15min

144. Code download 1min


-----------------------------------------------------------------------------------
-----------------
Section 20: Core Java basics 0 / 11|2hr 5min
-----------------------------------------------------------------------------------
-----------------
145. Java program principles 9min

146. Classes,objects in Java 18min

147. Strings in Java 16min

148. String Practise exercises 9min

149. What is Interface? 11min

150. How Java classes can take advantage of Interface? 10min

151. Usage of Inheritance in Java 11min

152. Understanding google place Search API for scripting 12min

153. Practical examples on types of inheritances 7min

154. Introduction to Arrays 9min

155. Single dimensional and Multidimensional arrays usage 13min


-----------------------------------------------------------------------------------
-----------------
Section 21: BONUS- Student Special 0 / 1|1min
-----------------------------------------------------------------------------------
-----------------
156. Bonus Lecture- Discount Coupons for other Test Automation courses 1min

Motwani : Refer video for IRI


https://en.wikipedia.org/wiki/API_tes...
http://openweathermap.org/
http://restcountries.eu/rest/v1/name/...
http://parabank.parasoft.com/parabank...
http://freegeoip.net/json/yahoo.com
https://github.com/rest-assured/rest-...
http://www.hascode.com/2011/10/testin...
https://knowledgetester.org/2014/10/2...

You might also like