Jasper John Cinatad
← All work

webdriver-proxy

Run existing Selenium scripts on Patchright instead of ChromeDriver.

Role
Author
Where
Personal project
When
2025
Built with
TypeScript, Bun, Patchright, Chrome DevTools Protocol
Links
Source on GitHub
Terminal session driving the proxy with curl, next to a screenshot of example.com returned through it.
Real output Real session. I ran the proxy locally and drove it over plain W3C WebDriver HTTP calls; the screenshot came back through the proxy.

Problem

Selenium scripts driven through ChromeDriver are easy for bot detection to spot, and rewriting a suite for a stealthier library is a lot of work.

What I built

A W3C WebDriver server in TypeScript on Bun. Selenium clients talk to it as if it were ChromeDriver; underneath, it drives Chrome through Patchright.

How it works

  • A small Express-style router on Bun’s native HTTP server, with routes like app.get and app.post.
  • An abstract WebDriver class and a Patchright implementation (about 1,500 lines) that maps WebDriver commands onto Patchright calls.
  • Each session gets a CDP WebSocket endpoint (se:cdp) for direct DevTools access, cleaned up when the session ends.
  • Launches a persistent Chrome context and respects a user-data-dir passed in chromeOptions.
Session response
{
  "sessionId": "abc123",
  "capabilities": {
    "browserName": "chrome",
    "se:cdp": "ws://localhost:4444/session/abc123/se/cdp"
  }
}

Outcome

  • In my local run, a session loaded example.com, returned its title and reported navigator.webdriver as false.