What is API? An Introduction to UI and API Testing
What is an API?
A software application developed using a three-tier architecture has
· Application Layer, also the middle layer is developed in programming languages like Java, Python, Ruby, etc. uses API.
· Database layer, acts as the end layer is used for storing data and uses software like Oracle, MongoDB, SQL Server for database management.
Application Programming Interface also called as API is a software which enables the communication between two applications and helps them in exchanging data.
Data flows between the three layers as described above
When a client enters data in a webpage (user interface) in a browser, a HTTP request is sent to the application layer which is developed in one of the programming languages like Java, Python, Ruby, etc.
For example, if the application layer is developed using Java, then Java receives the HTTP request and processes the HTTP request and uses API to fetch data from the database layer.
Once the requested data is fetched from the database layer in the form of JSON/XML through API calls, application layer parses the JSON/XML data and then sends the response back to the User interface used by the client via HTTP response.
The above scenario works well when a company doesn’t have the need to rely on third party data.
Let’s discuss the scenario when the data has to be fetched from a third-party application by the application layer (developed in Java). Let’s take an example website “hotelbooking.com” which compares the prices from all other hotel booking websites. This website needs data from all other hotel booking websites to compare the prices and give the best prices to the client for a particular day.
When a client requests a hotel availability for a particular day in the browser in the user interface of hotelbooking.com, the HTTP request is sent to the java application of hotelbooking.com.
Java application of hotelbooking.com then processes the HTTP request and sends multiple API calls to different hotel booking websites. The application layer of multiple websites processes the API calls and fetches data from their respective databases and gives back to the application layer of hotelbooking.com in the form of JSON/XML.
JSON/XML data received by Java application of hotelbooking.com is parsed and pushed to the user interface of hotelbooking.com via HTTP response.
UI Testing and API Testing
UI Testing is all about how a user interface appears to an end user without comprising the functionality of web elements. It concentrates on testing graphical user elements of the user interface like edit Box, Link, Buttons, Image link, Text area, Checkbox, Radio button and Dropdown list. Selenium Framework helps in testing the user interface of browsers like Chrome, Safari, Firefox, Edge, etc. using Selenium Web driver interface designed for those browsers.
API testing is about testing the business logic of the application layer. It involves testing the functionality, security and performance of the APIs. API testing is important because the data pushed to the user interface is the data fetched by the API. Also, when we the access the APIs of third-party websites, the need for Security testing comes here and API testing gets its significance. Soap UI, Postman, Test Mace, HP QTP are some of the API testing tools in the market.