IntermediatePW-API-00125 minutesPlaywright

Create and fetch a user through the API

A test needs a unique session-scoped user fixture.

  • api
  • request-context

Objective

What to automate

Create a user, read it by returned ID, and compare the fields.

Preconditions and test data

Preconditions

  • Use a fresh isolated Practice Lab browser context.
  • Open the fixture identified by FX-FORM-001.

Test data

  • name: API Learner
  • email: api.learner@example.test
  • role: learner

Expected result

POST returns 201 and GET returns the same synthetic user.

Progressive hints

Hint 1

Create a Lab session and retain its cookie/header.

Hint 2

Send the CSRF token for POST.

Hint 3

Read the Location or response id, then GET that record.

I’ve tried it — show solution
  1. Create a Lab session and retain its cookie/header.
  2. Send the CSRF token for POST.
  3. Read the Location or response id, then GET that record.