Introduction
- API – Application Programming Interface
- An API is a software-to-software interface that enables communication and data exchange between two separate software system. In APIs, applications talk to each other without any user knowledge.
- This testing is completely different from GUI testing. API testing won’t consider the look and feel of an application.
- Instead of using standard user inputs and output, in API testing, we’re using software to send calls to an API and get an output (System Response). While testing an API, we need to,
- Use API Testing Tool to drive the API
- Write your own script to test the API
Commonly used HTTP Methods:
- GET: Used to extract the information from the given server. It provides read-only access to the resource.
- POST: This request used to create a new record/entity.
- PUT: Used to update an existing resource or creating new resource
- DELETE: Used to remove a resource.
HTTP Status Response Code:
API Process Flow:
FRAMEWORK DETAILS:
Framework: POM with TestNG
Language: JAVA
API: Rest Assured
Read Test Data From: JSON, Property File
Report: Extent 2
API Methods: POST and GET
Authorization: Outh2.
Post Functionality: Manual Execution
Step 1: Add postman extension in chrome.
Step 2: Now, open the postman and then navigate into “Authorization” tab
Step 3: Now, generate new “Access Token” using type as “OAuth 2”:
Note: Without using access token, we can’t send response to API. To create access key referred this link: Refer to generate access token
Step 4: Click the “Get Access Token” button and then provide valid information. Now, click “Request Token”.
Step 5: After generating the Access Token, click the “Use Token” button. The generated access token will be used for performing http methods like post, get, delete and so on.
Step 6: Now, select POST method and then provide valid URL, JSON content in BODY (The Testdata/metadata vary depending on the object in Salesforce).
Step 7: Click the “Send” button and then verify the response message with status code
API Automation Process:
Step 1: Generate Access Token using OAuth2.0
Step 2: Perform Post Method using multipart: (Send Request to API for creating a record is salesforce)
Step 3: Get Method (Receiving Response)