TestingDocs.com logoTestingDocs.com
Automation learning lab
TestingDocs • Self-paced course

Playwright Automation
Self Study Guide

Start from zero. Learn JavaScript and TypeScript, automate browsers, and build reliable end-to-end tests.

60 chaptersBeginner friendlyHands-on practice
Playwright / Chapter 54 of 60~18 min • Beginner
Chapter 54Playwright

Data-driven and parameterized tests

Parameterized tests use data records to define multiple independent cases. Generate a unique test title for each case at declaration time. Each test receives its own fixtures and should assert its own expected result.

How it works

Step-by-step walkthrough

  1. Define test records
  2. Loop to declare tests
  3. Run and inspect separate results

Example

TypeScript
import { test, expect } from '@playwright/test';
const cases = ['Alpha', 'Beta'];
for (const name of cases) {
  test(`renders ${name}`, async ({ page }) => {
    await page.setContent('<h1></h1>');
    await page.locator('h1').evaluate((el, value) => el.textContent = value, name);
    await expect(page.getByRole('heading')).toHaveText(name);
  });
}
Expected result: Two independently reported tests
💡 Point to remember
Use distinct titles and avoid shared mutable test data.

✎ Your practice task

Add a third data record.

Knowledge check

Why use unique test titles?

🌐 Continue learning