Human-in-the-loop CAPTCHAs in a streamed browser
Pausing a headless run and handing control to a person over CDP.
The web scraper in our workflow platform lets a workflow open real websites and pull data out of them. Most of the time that runs without anyone watching. Then a CAPTCHA appears, and a fully automated scraper has two bad options: fail, or try to defeat it. I built a third option: pause and ask a person.
How the scraper runs
The scraper is a NestJS service that drives browsers with Playwright. It can run them headless, with no visible window, for fast unattended jobs, or headful, as a real browser window, when a page behaves differently under automation.
Every browser session is connected over the Chrome DevTools Protocol (CDP). CDP is the same channel Chrome's own developer tools use, and it lets the service both control the page and stream what the page looks like.
Human in the loop
When the scraper reaches a CAPTCHA, the run does not fail. It pauses at that step, and the browser session stays open exactly where it stopped.
The live browser is streamed over CDP to the person running the workflow. They see the real page, solve the CAPTCHA themselves, and hand control back. The workflow then carries on from the same point, with the same session, as if nothing had happened.
A few design choices made this work:
- Pausing is a normal state, not an error. A waiting run is visible as waiting, so nobody mistakes it for a crash.
- The session is kept, not restarted. Cookies, navigation and form state all survive the pause, so the person's answer still counts when the run resumes.
- The person acts in the real browser. Nothing is re-created; what they see is what the automation sees.
Why not solve it automatically
CAPTCHAs exist to confirm a person is present. Having a person answer them is the honest way through, and it keeps the platform on the right side of the sites it visits. It also gives the workflow owner a natural checkpoint on sensitive runs.
Scrapers as subflows
Scrapers are subflows in the Visual Workflow Builder, so a scraping job built once, including its human-in-the-loop step, can be reused as a single node in other workflows.
What it unlocked
This build taught me CDP and Playwright properly, well beyond test automation. It also became my favourite example of a broader rule for automation in the AI era: the best automated systems know when to stop and ask a person, and they make that hand-off feel like part of the product rather than a failure.