DEV Community

Alex Spinov
Alex Spinov

Posted on

Playwright Test Has a Free API You Should Know About

Playwright Test is a modern end-to-end testing framework from Microsoft. It tests across Chromium, Firefox, and WebKit with auto-waiting, parallelism, and built-in reporting.

Why Playwright Test Over Cypress

A QA team using Cypress couldn't test cross-browser — Cypress only supports Chromium-based browsers. Playwright Test runs the same tests on Chrome, Firefox, AND Safari — catching browser-specific bugs automatically.

Key Features:

  • Cross-Browser — Chromium, Firefox, WebKit in one test suite
  • Auto-Waiting — No manual waits or sleep calls
  • Parallel Execution — Tests run in parallel by default
  • Tracing — Time-travel debugging with screenshots
  • Code Generation — Record tests by clicking in the browser

Quick Start

npm init playwright@latest
Enter fullscreen mode Exit fullscreen mode
import { test, expect } from "@playwright/test"

test("homepage has title", async ({ page }) => {
  await page.goto("https://example.com")
  await expect(page).toHaveTitle(/Example/)
})

test("can log in", async ({ page }) => {
  await page.goto("/login")
  await page.fill("#email", "user@example.com")
  await page.fill("#password", "password")
  await page.click("button[type=submit]")
  await expect(page.locator(".welcome")).toBeVisible()
})
Enter fullscreen mode Exit fullscreen mode

Code Generation

npx playwright codegen example.com
# Click around — Playwright writes the test for you!
Enter fullscreen mode Exit fullscreen mode

Why Choose Playwright Test

  1. True cross-browser — Chrome + Firefox + Safari
  2. Auto-waiting — reliable tests without flakiness
  3. Code generation — record tests visually

Check out Playwright docs to get started.


Need testing automation? Check out my Apify actors or email spinov001@gmail.com for custom solutions.

Top comments (0)