You have learned the theory. Now write real assertions. Each exercise targets a specific assertion skill. Do all of them. Reading about assertions is not the same as writing them. The difference between a tester who knows assertions and one who has practiced them shows up in interviews and on the job.
Exercise 1: Page-Level Assertions
Navigate to the Banking Portal (/banking)
Assert the page URL contains "/banking" using toHaveURL with regex
Assert the page title contains "Banking" using toHaveTitle
Click a navigation link and verify the URL changes
Verify the new page title matches the destination
Exercise 2: Element State Assertions
Navigate to a form page
Assert the submit button is disabled when the form is empty
Fill all required fields
Assert the submit button is now enabled
Check a checkbox and assert it is checked using toBeChecked
Uncheck it and assert it is not checked using not.toBeChecked
Exercise 3: Text Assertions
Find an element with known text and use toHaveText for exact match
Use toContainText for a substring match on the same element
Use regex with toHaveText to match a dollar amount pattern
Verify a list of items using toHaveText with an array
Use ignoreCase: true for a case-insensitive check
Exercise 4: Soft Assertions
Navigate to a dashboard or listing page
Write 6 soft assertions checking different elements
Intentionally make 2 of them wrong to see multi-failure output
Fix the assertions and verify the test passes
Add a hard assertion at the end for the critical check
Exercise 5: Custom Messages and Timeouts
Write 3 assertions with custom error messages
Make one fail intentionally and read the error output
Add a custom timeout of 10 seconds to one assertion
Verify the timeout works by checking a slow-loading element
Write a test that combines custom message and custom timeout
Exercise 6: Build an Assertion Helper
Create a helper function: assertPageLoaded(page, urlPattern, heading)
Create a helper function: assertFormField(page, label, expectedValue)
Use both helpers in a test for the Banking Portal
Verify the helpers produce readable error messages on failure
Bonus: create a DashboardAssertions class with 3 methods
Run exercises in headed mode: npx playwright test --headed. Watch the browser. See what the assertions are checking. This builds visual intuition for what each assertion does.
Key Point: Six exercises covering page assertions, state checks, text assertions, soft assertions, custom messages, and reusable helpers. Do all of them -- this is where the learning sticks.
Key Point: Practice page assertions, text checks, soft assertions, custom messages, and helper functions. Each exercise builds a different assertion muscle.