In this video, the creator provides a detailed walkthrough on how to perform GET calls for API testing using both Postman for manual testing and Playwright for automation testing.
-
Introduction to GET Calls:
- The video begins with an introduction to API testing, emphasizing its importance for ensuring the smooth functioning and overall quality of web applications. The host recommends watching a previous video on the basic concepts of APIs for better understanding.
-
Manual Testing with Postman:
- The host demonstrates how to use the Postman tool to perform GET calls. Key steps include:
- Installing and setting up Postman.
- Creating a new HTTP request using the GET method.
- Adding the base URL and resource.
- Optionally adding query parameters, headers, and authorization.
- Viewing the response, including the response body, headers, and status codes.
- Saving requests for future use.
-
Practical Examples with Postman:
- An example GET call to the 'restful-booker' API to retrieve booking IDs is shown.
- Demonstrates working with path parameters by fetching specific booking details using a booking ID.
- Illustrates the use of query parameters to filter requests.
-
Automation Testing with Playwright:
- The host transitions to automating the GET calls using Playwright with TypeScript.
- Explains various ways to set the base URL for HTTP requests:
- Directly in the HTTP method.
- Using a request context within a test.
- Using a
beforeAll
hook for a test suite.
- Setting a global base URL in the Playwright config file.
- Shows how to send a GET request using Playwright and retrieve the response.
-
Setting Headers:
- Similar to the base URL, headers can be set in multiple ways:
- Directly in the HTTP method.
- Using a request context within a test.
- Using a
beforeAll
hook.
- Setting global headers in the Playwright config file.
-
Assertions:
- Discusses the importance of assertions in validating API responses.
- Provides examples of different types of assertions like status code checks, response body validations, and specific field validations.
-
Validating API with UI:
- Shows an example where API responses are validated against the UI using Playwright's page fixture.
- Fetches data via an API call and verifies it against the UI elements to ensure they match.
-
Summary:
- The video concludes with a recap of the different aspects of API testing covered, including manual testing with Postman, automated testing with Playwright, setting base URLs and headers, various assertion techniques, and API-UI validation.
Throughout the video, the host provides detailed explanations and practical demonstrations, making it accessible for both beginners and experienced testers looking to deepen their understanding of API testing using these tools.