Why this matters
Browser automation tools appear across testing adverts: Selenium most often in the ones we read, with Cypress, Playwright and Appium (for mobile apps) also named. They drive a real browser like a person would. Learn one tool well; the ideas transfer between them.
Setting up Playwright (one example)
On a computer with Node.js installed, open a terminal in an empty folder and run:
npm init playwright@latestThis installs Playwright, its browsers and an example test. Playwright needs a recent operating system, such as Windows 11, a recent macOS or Ubuntu, and a current Node.js release, so check the system requirements on its Getting started page first. The download is a few hundred megabytes, so use Wi-Fi if you can. Run tests with npx playwright test.
A first test
This example uses Playwright's public practice to do app:
import { test, expect } from '@playwright/test';
test('adds a to do item', async ({ page }) => {
await page.goto('https://demo.playwright.dev/todomvc/');
const box = page.getByPlaceholder('What needs to be done?');
await box.fill('Buy shea butter');
await box.press('Enter');
await expect(page.getByText('Buy shea butter')).toBeVisible();
});Every test has the same shape as a manual test case: go somewhere, act, then check an expected result. The line is the expected result from your test case.