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.
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@example.com.