Modern QA2026Your First Test — tiles
Log inJoin
59 / 139 · 13 Browser Automation with Playwright · Setup and First Test← prev⊞ allnext →☰ Read as one page

5.4Your First Test

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

test('homepage has correct title', async ({ page }) => {
  await page.goto('https://playwright.dev/');
  await expect(page).toHaveTitle(/Playwright/);
});

test('get started link navigates to intro', async ({ page }) => {
  await page.goto('https://playwright.dev/');
  await page.getByRole('link', { name: 'Get started' }).click();
  await expect(page).toHaveURL(/.*intro/);
});

Running Tests

# Run all tests
npx playwright test

# Run a specific file
npx playwright test tests/login.spec.ts

# Run in headed mode (see the browser)
npx playwright test --headed

# Run in UI mode (interactive debugger)
npx playwright test --ui