Rayrun
← Back to videos

How To Wait For API Response | Playwright Tutorial - Part 44

Hello guys, in this video, we'll learn how to wait for the API response body and check the status of the API.

In this video, the content creator (Gaushik) demonstrates how to read data from an API response using Playwright. The video starts with an introduction and a brief explanation of the exercise that will be performed - typing a GitHub username in a search bar and retrieving user details and repositories using the GitHub public API.

Gaushik then proceeds to show how to capture the API response using the network tab in the browser's developer tools. He explains that the response includes information such as the user's name, location, bio, number of followers, and repositories.

Next, Gaushik begins coding the test using Playwright. He uses the page.waitForResponse() function to wait for the API response and applies a predicate to filter out the specific response he wants (in this case, a response with a status code of 200). He then demonstrates how to interact with the website's elements, filling in the username input field and clicking the search button.

After the interaction, Gaushik logs the response in JSON format to the console for verification purposes. He also explains how to further filter the response based on conditions or specific data within the response body.

The video concludes with a Q&A segment, where Gaushik answers a viewer's question about checking for a specific status (e.g., "in progress" or "completed") within the response body. Gaushik suggests using the includes() method on the response body or converting it to JSON using libraries like Lodash to perform further analysis.

Overall, the video provides a clear and concise tutorial on reading data from API responses using Playwright and offers additional insights for customizing response handling based on specific requirements.

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?
How to handle multiple tabs in Page Object Model | Playwright Tutorial - Part 87
How to handle multiple tabs in Page Object Model | Playwright Tutorial - Part 87
Playwright Installation - 2022
Playwright Installation - 2022
Playwright Allure Report | Playwright Tutorial - Part 38
Playwright Allure Report | Playwright Tutorial - Part 38
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 luc@ray.run.