After creating a new user in Playwright, I need to retrieve the user's ID for deletion. To achieve this, I save the ID in a variable at the end of my code snippet:
const loginResponseJson = await response.json();
const id = loginResponseJson.id;
console.log(id);
console.log("New Created User is: " + id);
This leads me to my question: How can I pass a variable like an ID to a URL in Playwright? For deletion, I attempted the following approach:
test('Should be able to delete a newly created user', async ({ request }) => {
const response = await request.delete(`/public/v2/users/`, {
});
The challenge lies in correctly including the ID after the URL in the request parameter. How can I accomplish this using Playwright?