14. Modern Web Automation Architecture

What is Playwright?

Playwright is an open-source automation library designed for modern, reactive web apps. It supports single-page apps (React, Next.js, Angular, Vue) with automatic waiting and zero-flakiness guarantees.

---

Playwright vs Selenium vs Cypress

| Capability | Playwright | Cypress | Selenium 4 |
| :--- | :--- | :--- | :--- |
| Protocol | Chrome DevTools Protocol / CDP via WebSockets | In-browser JS injection | W3C WebDriver HTTP |
| Speed | ⚡ Extremely fast (bi-directional) | Medium (browser thread bottleneck) | Slower (HTTP request per command) |
| Multi-tab & Frames | ✅ Native full support | ❌ Difficult / limited | ✅ Supported |
| Multiple Browsers | Chromium, Firefox, WebKit (Safari engine) | Chromium, Firefox (no native WebKit) | All via external driver binaries |
| Auto-waiting | ✅ Built-in for actionability | ✅ Built-in for assertions | ❌ Requires explicit/fluent waits |

---

Playwright Architecture

Playwright operates over a single persistent WebSocket connection. When your test commands page.click('button'), it evaluates actionability checks (visible, stable, enabled, receiving events) right inside the browser engine before sending the simulated hardware event.

Task

  • Implement getBrowserCapabilities:
  • 1. Accept browserName: "chromium" | "firefox" | "webkit".
  • 2. Return { engine, supportsMobileEmulation } matching each browser engine.
💡Common doubts
Did you like the problem?
Lesson 14 of 36
TypeScript
Loading code editor…
Next