Skip to main content

๐Ÿงช Practice

This page contains hands-on exercises to help you practice Playwright step by step.


โœ… Practice Pathโ€‹

Use these exercises after completing the main lessons:

1. Locators Practiceโ€‹

  • Find buttons using getByRole()
  • Find inputs using getByLabel()
  • Find elements using getByText()

2. Actions Practiceโ€‹

  • Click buttons
  • Fill forms
  • Select dropdown values
  • Check checkboxes

3. Assertions Practiceโ€‹

  • Verify page title
  • Verify URL
  • Verify text is visible
  • Verify buttons are enabled

4. Debugging Practiceโ€‹

  • Run tests with --headed
  • Run tests with --debug
  • Check HTML report
  • Open trace viewer

๐ŸŽฏ Mini Exercisesโ€‹

Exercise 1: Login Formโ€‹

Create a test that:

  • opens a login page
  • fills username and password
  • clicks submit
  • checks success message

Exercise 2: Search Flowโ€‹

Create a test that:

  • opens a search page
  • searches for a term
  • checks search results are shown

Exercise 3: Form Validationโ€‹

Create a test that:

  • submits an empty form
  • checks validation messages appear

โœ… Practice Checklistโ€‹

  • I can use Playwright locators
  • I can perform UI actions
  • I can write assertions
  • I can debug failed tests
  • I can run tests in headed mode

Keep practicing until the commands feel natural.