Playwright

Target elements by label

Easy30 pts
  • getByLabel
  • Form Controls
  • Accessible Inputs
Practice app · Workshop Registration

A registration form with text fields, radios, checkboxes, selects and validation.

Test URL
/lab/playwright-target-elements-by-label

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

Objective

Locate form controls by their associated label text and complete the registration fields.

Your Task

  1. 1Navigate to the practice registration form at TEST_URL.
  2. 2Locate the input field labelled 'First name' and fill in 'Sarah'.
  3. 3Locate the input field labelled 'Email' and fill in 'sarah@example.com'.
  4. 4Assert that the first name input (#first-name) has value 'Sarah'.

Validation Checks

  • Practice registration form is loaded at TEST_URL
  • First name field is located by its label and filled with 'Sarah'
  • Email field is located by its label and filled with 'sarah@example.com'
  • First name input (#first-name) contains 'Sarah'
  • At least 1 assertion passes

Playwright · Playwright Practice Track · Locators & auto-waiting