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.

CRUD operations

CRUD operations

To make an API call and get data from the same, we use the get method. In this lesson, we'll learn about the other methods like the post, put, and the delete, which can be used to perform different actions. Now to do the same, we'll go ahead and take a look at the documentation first. Here we looked at the search user one in the previous lesson. And if I scroll down a bit, you will find this section that is add a new user. To do that, what we have to do is call this API, that is dummy JSON users add. To the same, we have to provide the method as post, the headers, which is the content type specifying as application JSON. And finally providing the data of our user, that is their last name, first name, along with their age and the other fields. Now to perform this post action, we can just use the API context dot post method like this. So let's go ahead and in this lesson, create a test for the same that is creating a new user. So we'll go ahead and create a function that is test create…

Contents