Playwright

Share worker-scoped state

Hard120 pts
  • Worker Scope
  • Shared State
  • Performance Optimization
Practice app · Profile Settings

A settings page for clicking, typing, reading text/attributes/CSS and element state.

Test URL
/lab/playwright-share-worker-scoped-state

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

Objective

Create a worker-scoped fixture that runs once per worker process to share setup across multiple tests.

Your Task

  1. 1Extend the base test with a custom fixture configured with worker scope.
  2. 2Initialize the shared state inside the worker fixture and provide it to tests.
  3. 3In your test function, navigate to the profile page at TEST_URL.
  4. 4Assert that the display name input field (#display-name) is visible.

Validation Checks

  • Custom fixture is defined with { scope: 'worker' }
  • Worker fixture provides shared state using use()
  • Profile page is loaded at TEST_URL
  • Display name input field (#display-name) is verified visible
  • At least 1 assertion passes

Playwright · Playwright Practice Track · Fixtures