Skip to content

Playwright

In one line

Playwright is a modern E2E testing tool by Microsoft — fast, reliable, cross-browser, with auto-waiting built in.

In simple words

Playwright is a modern end-to-end testing framework created by Microsoft. It's become very popular because it solves many pain points of older E2E tools.

Key features:

  • Cross-browser: tests run on Chromium, Firefox, and WebKit (Safari)
  • Auto-waiting: automatically waits for elements to be ready, reducing flaky tests
  • Fast: runs tests in parallel across browsers
  • Multi-language: supports JavaScript, TypeScript, Python, Java, C#
  • Network interception: can mock and monitor network requests
  • Trace viewer: powerful debugging tool for failed tests

Playwright is often compared to Cypress. Playwright's advantages include multi-browser support, multi-tab testing, and no paid features. Cypress has a nicer developer experience for beginners and time-travel debugging.

Example

javascript
// login.spec.js — Playwright E2E test
import { test, expect } from '@playwright/test';

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

  await page.fill('#username', 'alice');
  await page.fill('#password', 'secret123');
  await page.click('button[type="submit"]');

  await expect(page).toHaveURL(/dashboard/);
  await expect(page.locator('h1')).toHaveText('Welcome, Alice');
});

// Run: npx playwright test
//  Running 1 test using 1 worker
//  ✓ login.spec.js:3 › user can log in (1.2s)
//  1 passed

Playwright drives a real browser: it navigates to a URL, fills inputs, clicks buttons, and asserts the resulting URL and page content — exactly like a human user would.

Related terms

Related Resources

Related Lessons

Decode error messages

Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.

View errors

← Back to glossary