DEV Community

Alex Spinov
Alex Spinov

Posted on

Playwright Has a Free Browser Testing Framework — Test Any Browser with One API

A QA team maintained separate test suites for Chrome (Puppeteer), Firefox (Selenium), and Safari (Appium). Three frameworks, three APIs, triple the maintenance.

Playwright by Microsoft tests Chromium, Firefox, and WebKit with a single API. Auto-wait, trace viewer, codegen - testing as it should be.

What Playwright Offers for Free

  • All Browsers - Chromium, Firefox, WebKit from one API
  • Auto-Wait - No more sleep() or waitFor hacks
  • Codegen - Record actions, generate test code
  • Trace Viewer - Debug failed tests with screenshots, DOM snapshots, network
  • Parallel - Run tests in parallel across browsers
  • API Testing - Test REST APIs without a browser
  • Visual Comparisons - Screenshot assertions
  • Mobile Emulation - Test mobile viewports

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/)
  await page.getByRole('link', { name: 'More' }).click()
  await expect(page).toHaveURL(/more/)
})
Enter fullscreen mode Exit fullscreen mode
npx playwright test
npx playwright show-report
Enter fullscreen mode Exit fullscreen mode

GitHub: microsoft/playwright - 68K+ stars


Need to monitor and scrape data from multiple web services automatically? I build custom scraping solutions. Check out my web scraping toolkit or email me at spinov001@gmail.com for a tailored solution.

Top comments (0)