Staring at an empty test folder is often the hardest part of end-to-end testing. To help, here are ten common end-to-end test ideas you can build with Playwright, with code examples for two of the most requested scenarios: login and form submission.

1. Login functionality

Test the login flow of your web application, including successful logins, invalid login attempts, and forgotten password recovery.

import { test, expect } from '@playwright/test'

test('user can log in', async ({ page }) => {
  // Navigate to the login page
  await page.goto('https://www.example.com/login')

  // Fill in the username and password fields
  await page.getByLabel('Username').fill('myusername')
  await page.getByLabel('Password').fill('mypassword')

  // Submit and verify the logged-in state
  await page.getByRole('button', { name: 'Log in' }).click()
  await expect(page.getByText('Logged in as')).toBeVisible()
})

This test navigates to the login page, fills in the username and password fields, clicks the login button, and then verifies that the user is logged in by checking the login status text on the page. Playwright's expect retries until the element appears, so there is no need for manual waitForNavigation calls.

2. Navigation

Test how well your web application handles user navigation, including clicking links, navigating back and forward, and using the browser's back and forward buttons.

3. Form submission

Test how your web application handles form submissions, including submitting valid and invalid data, handling form validation errors, and checking that the correct data is displayed after submission.

import { test, expect } from '@playwright/test'

test('contact form submits successfully', async ({ page }) => {
  // Navigate to the form page
  await page.goto('https://www.example.com/form')

  // Fill in the form fields
  await page.getByLabel('Name').fill('John Doe')
  await page.getByLabel('Email').fill('johndoe@example.com')
  await page.getByLabel('Message').fill('This is a test message.')

  // Submit the form and verify the confirmation
  await page.getByRole('button', { name: 'Submit' }).click()
  await expect(page.getByText('Your form has been submitted.')).toBeVisible()
})

This test fills in the form fields with sample data, clicks the submit button, and then verifies that the submission succeeded by checking the confirmation text on the page.

4. UI elements

Test the functionality of various UI elements such as buttons, dropdowns, checkboxes, and radio buttons.

5. User registration

Test the user registration process, including entering valid and invalid data, handling form validation errors, and ensuring that the correct data is displayed after registration.

6. Shopping cart

Test the shopping cart functionality of your web application, including adding and removing items from the cart, updating item quantities, and checking out.

7. Search functionality

Test the search functionality of your web application, including searching for valid and invalid keywords, filtering results, and verifying that the correct results are displayed.

8. User profile

Test the user profile functionality of your web application, including updating user information, changing passwords, and verifying that the correct data is displayed after changes are made.

9. Checkout process

Test the entire checkout process of your web application, including entering billing and shipping information, selecting payment options, and verifying that the order is placed successfully.

10. Mobile responsiveness

Test how well your web application performs on mobile devices, including checking that the layout is optimized for smaller screens and that all functionality is still accessible. Playwright's built-in device presets make this a one-line configuration change.

These are just starting points. The specific tests you run will depend on your application and what your users actually do in it. If you want a deeper look at test structure, locators, and assertions, our Playwright guides walk through them step by step. And once your critical flows are covered in CI, you can run the same scenarios on a schedule against production with browser checks, so you find out about breakage before your users do.