Skip to content
BENIBIX Learn

Playwright

Development🧪 Testing & QualityTest Frameworks

Also known as Playwright Test, Microsoft Playwright

A tool that drives a real browser from code, to test a site like a user.

Think of it like

Think of it like a robot at the keyboard. It uses your website for you.

Example

Jack's Playwright test opens his sign-up page in three browsers, fills the form and checks the welcome message. It catches a bug that only Safari had.

Why it matters

It tests the site the way people use it, in the browsers they really use.

Definition

Playwright is a tool that drives a real web browser from code. It is mostly used for end-to-end tests. Microsoft released it in 2020. One test can run in Chromium, Firefox and WebKit, the engine behind Safari. It waits for buttons and text to appear before it acts, which cuts down flaky tests. You can write tests in JavaScript, TypeScript, Python, Java or C#.

Example code

javascript
await page.goto('https://example.com');
await expect(page).toHaveTitle('Example Domain');
Open the page in a real browser and check its title.

Common mistake

Adding fixed waits, like two seconds. Wait for the button to show up instead; it is faster and less flaky.

Key takeaways

  1. 1
    A real browser. Driven from code.
  2. 2
    Three engines. Chromium, Firefox, WebKit.
  3. 3
    Waits on its own. Fewer flaky tests.

Compare