API Testing Class Day 1
API Testing Class Day 1
Pramod Dutta
Lead SDET. Web Fundamentals for API Testers
TheTestingAcademy
Agenda of Session
● HTTP Basics, URL Basics
● Cookie, Headers
● JSON Basics & XML Basics
● Install Tools for API Testing
● Chrome Dev Tools, Import Requests
● HTML Forms for API Testing
TheTestingAcademy
API Tester ROADMAP
TheTestingAcademy
API Tester ROADMAP
https://miro.com/app/board/uXjVOttFRjM=/?share_link_id=284599875783
TheTestingAcademy
Know Your Instructor -Pramod Dutta
● I have nearly 9+ year of Experience in the
Software Testing.Worked on different
domain Mobile App, Web API, Website ,
Performance testing etc.
● Taught 10K+ Students
● 8600 Students in FB, 55k Youtube Subs.
● Helping People to Become Better
Automation Tester.
● [email protected]
TheTestingAcademy
Before We Start…..
Join Private Telegram
https://sdet.live/apibatch
TheTestingAcademy
Do you know What is HTTP?
Yes
No
In Comments
TheTestingAcademy
Overview of HTTP
● HTTP is a protocol for fetching resources such as HTML documents.
● It is the foundation of any data exchange on the Web and it is a client-server protocol.
● HTTP is stateless: there is no link between two requests being successively carried out on the same
connection
●
https://developer.mozilla.org/en-US/docs/Web/HTTP
TheTestingAcademy
Overview of HTTP
TheTestingAcademy
HTTP Authentication
TheTestingAcademy
TheTestingAcademy
TheTestingAcademy
TheTestingAcademy
HTTP Cookies
An HTTP cookie (web cookie, browser cookie) is a small piece of data that a server sends to a user's web
browser.
The browser may store the cookie and send it back to the same server with later requests
Session management
Logins, shopping carts, game scores, or anything else the server should remember
Personalization
User preferences, themes, and other settings
Tracking
Recording and analyzing user behavior
TheTestingAcademy
HTTP Cookies
https://app.vwo.com/#/dashboard
TheTestingAcademy
Headers
TheTestingAcademy
Headers
HTTP headers let the client and the server pass additional information with an HTTP request or response.
Caching https://developer.mozilla.org/en-US/
docs/Web/HTTP/Headers
User agent client hints Conditionals
TheTestingAcademy
Headers
The Content-Type representation header is used to indicate the original media type of the resource
(prior to any content encoding applied for sending).
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type
TheTestingAcademy
Tools for Cookie, Headers View
https://chrome.google.com/webstore/detail/editthiscookie/fngmhnnpilhplaeedif
hccceomclgfbg?hl=en
TheTestingAcademy
URL Basics
TheTestingAcademy
URL BASICS
Uniform Resource Locators
TheTestingAcademy
URL BASICS
TheTestingAcademy
URL BASICS
TheTestingAcademy
Quiz
https://abc.com/xyz/?q=1#anchhr=09
TheTestingAcademy
Absolute URLs?
TheTestingAcademy
What are Relative URLs?
TheTestingAcademy
TheTestingAcademy
Data URLs
URLs prefixed with the data: scheme,
A few examples: allow content creators to embed small
files inline in documents.
data:,Hello%2C%20World%21
The text/plain data Hello, World!. Note how the comma is percent-encoded as
%2C, and the space character as %20.
data:text/plain;base64,SGVsbG8sIFdvcmxkIQ==
base64-encoded version of the above
data:text/html,%3Ch1%3EHello%2C%20World%21%3C%2Fh1%3E
An HTML document with <h1>Hello, World!</h1>
data:text/html,<script>alert('hi');</script>
An HTML document that executes a JavaScript alert. Note that the closing script
tag is required.
TheTestingAcademy
MIME types
A media type (also known as a Multipurpose Internet Mail Extensions or MIME
type) indicates the nature and format of a document, file, or assortment of bytes.
application/pdf
application/json
https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types
https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types#multi
partform-data
TheTestingAcademy
MIME types
TheTestingAcademy
HTTP request methods
https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods
TheTestingAcademy
HTTP request methods
https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods
TheTestingAcademy
PUT VS POST
TheTestingAcademy
Quiz
Can we use POST request to do all Request?
TheTestingAcademy
HTTP response status codes
HTTP response status codes indicate whether a specific HTTP
request has been successfully completed. Responses are grouped in
five classes:
https://developer.mozilla.org/en-US/docs/Web/HTTP/Status
TheTestingAcademy
User agent
A user agent is a computer program representing a person, for
example, a browser in a Web context.
The user agent string can be accessed with JavaScript on the client side using the NavigatorID.userAgent
property.
A typical user agent string looks like this: "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:35.0) Gecko/20100101
Firefox/35.0".
https://developer.mozilla.org/en-US/docs/Web/HTTP/Status
TheTestingAcademy
HTML Elements
TheTestingAcademy
HTML Forms
Web forms — Working with user data
<form action="/my-handling-form-page"
method="post">
<ul>
<li>
<label for="name">Name:</label>
<input type="text" id="name" name="user_name">
</li>
<li>
<label for="mail">E-mail:</label>
<input type="email" id="mail" name="user_email">
</li>
<li>
<label for="msg">Message:</label>
<textarea id="msg"
name="user_message"></textarea>
</li>
</ul>
</form>
TheTestingAcademy
JSON Basics
Both JSON and XML can be used to receive data from a web server.
TheTestingAcademy
JSON Basics
{
JSON Objects "employee":{"name":"John",
"age":30, "city":"New York"}
}
Objects as values in JSON must follow the JSON syntax.
JSON Arrays {
"employees":["John", "Anna",
"Peter"]
}
TheTestingAcademy
JSON Path https://www.jsonschema2pojo.org/
https://jsonutils.com/
https://jsonpath.com/
TheTestingAcademy
XML Basics
XML stands for eXtensible Markup
Language.
TheTestingAcademy
XML Basics
XML Example 2
<?xml version="1.0" encoding="UTF-8"?>
<breakfast_menu>
<food>
<name>Belgian Waffles</name>
<price>$5.95</price>
<description>
Two of our famous Belgian Waffles with plenty
of real maple syrup
</description>
<calories>650</calories>
</food>
https://www.w3schools.com/xml/tryi
t.asp?filename=tryajax_first
TheTestingAcademy
XML Basics
For AJAX applications, JSON is faster
and easier than XML:
Using XML
Using JSON
TheTestingAcademy
Install Tools for API Testing
TheTestingAcademy
Download Postman
https://www.postman.com/downloads/
TheTestingAcademy
TheTestingAcademy
They are enough,
TheTestingAcademy
Chrome Dev Tools
TheTestingAcademy
Quiz
Type different HTTP Methods
TheTestingAcademy
Import Requests
TheTestingAcademy
Quiz
What is 404?
TheTestingAcademy
Quiz
Pick the status code class used for server error
1xx
2xxx
3xx
4xx
TheTestingAcademy
API Testing Tools
TheTestingAcademy
Quiz
What are the common protocols that are testing in API testing ?
HTTP
JMS
REST
SOAP
UDDI
TheTestingAcademy
How do You verify the GET
ALL BOOKINGS
1. Status Code
2. Headers
3. Response Data
4. JSON Schema Validation
5. Data Types
6. Pattern, Regex
7. Invalid Auths/ Permission mismatch
8. Many others….
TheTestingAcademy
Thanks, for attending Class
TheTestingAcademy
Fin.
TheTestingAcademy