Playwright

Use built-in page and context fixtures

Medium70 pts
  • Built-in Fixtures
  • Page
  • BrowserContext
Practice app · TargetQA Practice Store

A small storefront landing page for browser setup, navigation, titles, URLs and screenshots.

Test URL
/lab/playwright-use-built-in-page-and-context-fixtures

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

Objective

Understand Playwright's built-in page and context fixtures to navigate and set cookies.

Your Task

  1. 1Inject the built-in { page, context } fixtures into your test function.
  2. 2Add a session preference cookie named 'session_pref' with value 'dark' to the browser context for TEST_URL.
  3. 3Navigate to the store home page at TEST_URL.
  4. 4Assert that the page title header (#page-title) is visible.
  5. 5Assert that the browser document title matches 'TargetQA Practice Store'.

Validation Checks

  • Test consumes page and context fixtures
  • Session cookie 'session_pref=dark' is configured on context
  • Store home page is loaded at TEST_URL
  • Page title (#page-title) is visible
  • Document title matches 'TargetQA Practice Store'
  • At least 1 assertion passes

Playwright · Playwright Practice Track · Fixtures