Rayrun
← Back to videos

Playwright Tutorial | Get Call for API Testing with Playwright | Pass BaseURL and Headers

Get Call covering different ways to pass Base URL and Header,

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.

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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.
  6. 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.
  7. 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.
  8. 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.

Related Videos

#16 - ARIA and how Playwright is making use of it to identify UI controls?
#16 - ARIA and how Playwright is making use of it to identify UI controls?
Playwright with UI Mode is awesome
Playwright with UI Mode is awesome
Getting Started with Playwright and VS Code
Getting Started with Playwright and VS Code
Playwright Version 1.14 | Playwright Tutorial - Part 45
Playwright Version 1.14 | Playwright Tutorial - Part 45
TwitterGitHubLinkedIn
AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email [email protected].