From the course: Playwright Python and Pytest for Web Automation Testing: Master Modern Web Testing with Playwright and Pytest in Python

Unlock this course with a free trial

Join today to access over 25,200 courses taught by industry experts.

Making an API call

Making an API call

In this section, we'll learn how to make an API call and get the data to test the same. For this section, we'll use the dummyjson.com's APIs for testing and getting started. So here, I'll use the user's API, which is this right here, you will find the link in the resources. Now we'll go ahead and start with our test. Let's name it something like test users API and then we can take in the page object. Now there's a different method as well to make an API call but we will use page because that's what we are used to. To make an API call using our page object we can use the go to method to go to the URL of our API like this. Now when it goes ahead and visits or makes a call to this API, it returns a response as well. Now when we navigate it to URLs or websites, we didn't require the response. But in this case, we need it. That's why we go ahead and store the same like this. Now this response has the actual response. So if I go to the website and show the output here, you can see we'll get…

Contents