Playwright

Authenticate via the API

Medium70 pts
  • API Auth
  • Token Authentication
  • Speed Optimization
Practice app · Acme REST API

A live REST + GraphQL API with auth, validation, pagination, rate limiting and an interactive request console.

Test URL
/lab/playwright-authenticate-via-the-api

Your starter code already declares TEST_URL — never hardcode a host.

Objective

Authenticate via an API POST request to obtain an access token without going through UI login forms.

Your Task

  1. 1Send an HTTP POST request to the authentication endpoint with email 'qa@target.dev' and password 'Test@123'.
  2. 2Assert that the response status code is 200 OK.
  3. 3Parse the JSON response body.
  4. 4Assert that the response contains an access token ('access_token').

Validation Checks

  • Sends POST request to login endpoint
  • Asserts 200 status code
  • Asserts access_token in response
  • At least 2 assertions pass

Fixtures

apiKey
tqa_live_key_123
basicUser
admin
basicPassword
secret
username
qa@target.dev
password
Test@123

Playwright · Playwright Practice Track · API testing with Playwright