Playwright / Puppeteer with Stealth Plugins vs Selenium
What are Playwright and Puppeteer?
Puppeteer and Playwright are modern browser automation libraries developed by (or inspired by) Google and Microsoft respectively. They control browsers programmatically via the Chrome DevTools Protocol (CDP) or WebDriver BiDi.
| Feature | Puppeteer | Playwright |
|---|
| Developer | Google | Microsoft |
| Browsers | Chrome/Chromium (+ Firefox experimentally) | Chrome, Firefox, Safari (WebKit) |
| Language | JavaScript/TypeScript | JS/TS, Python, Java, C# |
| API Style | Async/await | Async/await |
| Built-in stealth | No (needs plugin) | Partial (better defaults) |
What are Stealth Plugins?
By default, headless browsers expose signals that websites use to detect bot traffic. Stealth plugins patch these fingerprinting vectors.
Common detection signals patched:
| Signal | What it leaks | Stealth fix |
|---|
navigator.webdriver | true in headless mode | Override to undefined |
| Chrome runtime object | Missing in headless | Inject fake window.chrome |
| Permissions API | Headless returns odd values | Normalize responses |
| User-Agent | Contains "HeadlessChrome" | Replace with real UA string |
| WebGL / Canvas fingerprint | Differs from real browsers | Spoof GPU/renderer info |
| Plugin/MIME arrays | Empty in headless | Inject realistic plugin lists |
| Language & timezone | Inconsistent headers | Align navigator.language, timezone |
Popular plugins:
puppeteer-extra-plugin-stealth — most widely used, patches ~20 evasion vectors for Puppeteer
playwright-extra + stealth plugin — same ecosystem ported to Playwright
undetected-chromedriver — Python equivalent for Puppeteer-style stealth (but for CDP)
Example (Puppeteer + Stealth):
const puppeteer = require('puppeteer-extra');
const StealthPlugin = require('puppeteer-extra-plugin-stealth');
puppeteer.use(StealthPlugin());
const browser = await puppeteer.launch({ headless: true });
const page = await browser.newPage();
await page.goto('https://bot.sannysoft.com'); // bot detection test
Comparison: Playwright/Puppeteer vs Selenium
| Dimension | Playwright / Puppeteer | Selenium |
|---|
| Protocol | CDP / BiDi (direct browser pipe) | WebDriver (HTTP-based W3C standard) |
| Speed | Faster (native protocol, no HTTP overhead) | Slower (JSON Wire Protocol over HTTP) |
| Browser support | Playwright: Chrome, Firefox, Safari; Puppeteer: Chrome | All major browsers + IE |
| Language support | JS/TS primarily (Playwright adds Python, Java, C#) | Python, Java, C#, Ruby, JS, and more |
| Stealth / bot evasion | Better baseline; stealth plugins available | Harder — WebDriver flag is deeply embedded |
navigator.webdriver | Easily patched | Difficult to hide; often still detectable |
| Auto-wait | Built-in smart waiting (Playwright) | Manual WebDriverWait required |
| Test features | Playwright has built-in tracing, screenshots, video | Requires 3rd-party tools (Allure, etc.) |
| Network interception | Native and easy | Limited (requires proxy or BrowserMob) |
| Mobile emulation | Native device emulation | Limited |
| Community/ecosystem | Newer, fast-growing | Mature, massive ecosystem |
| Grid/parallel execution | Playwright Test runner, Playwright Grid | Selenium Grid (battle-tested) |
| Enterprise use | Growing adoption | Industry standard for years |
Bot Detection: Why Selenium is Harder to Stealth
Selenium relies on the WebDriver protocol, which injects a webdriver property into the browser at a low level. This is much harder to suppress cleanly. Even with tools like undetected-chromedriver, detection is more fragile.
Playwright and Puppeteer communicate via CDP directly, making it easier to:
- Intercept and patch
navigator properties before page scripts run
- Inject scripts at document creation time (
page.evaluateOnNewDocument)
- Manage timing and fingerprinting at a lower level
When to Use What
| Use Case | Best Tool |
|---|
| Web scraping with bot evasion | Playwright + stealth or Puppeteer + stealth |
| Cross-browser enterprise test suite | Selenium |
| Modern end-to-end testing | Playwright |
| Legacy browser (IE) support | Selenium |
| Fast, headless automation pipelines | Playwright or Puppeteer |
| Large team with existing Java/Ruby infra | Selenium |
Bottom line: Playwright/Puppeteer with stealth plugins are the go-to choice for scraping and bot-evasion tasks. Selenium remains dominant in enterprise QA environments where cross-browser support, language diversity, and existing infrastructure matter more than stealth or speed.