Captchas
Bot defences on the open web come in two flavours: passive checks that score every visitor in the background, and interactive challenges that ask the user to do something (check a box, drag a slider, pick the bicycles). browserscale handles those two cases very differently, and getting that distinction right saves you a lot of unnecessary code.
- Passive challenges and anti-bot scoring — browserscale already passes these without any code on your side. Don't call
SolveCaptchafor them; there is nothing to solve. - Interactive challenges — that's what
SolveCaptchais for. It detects the challenge, solves it in the live session, and wires the result back into the page for you. SolveCaptcha(timeoutMs, retryAmount)(Go) /solveCaptcha({ timeoutMs, retryAmount })(TS). Both default to0→ server default (60 s budget, no retries).- Returns an empty string on success — the solution is applied in-page, no follow-up call needed.
- Supports the common interactive challenge types you run into in the wild. The exact list moves over time; ping us on Discord for the current set.
retryAmountdoes not apply to every challenge type — some invalidate the page after a failed attempt and a retry is impossible.- When a challenge may appear, race
Captcha()against the page you expect in aWaitand callSolveCaptchaonly when it wins. - Or turn on auto-solve once per session with
EnableCaptchaAutoSolve(Go) /enableCaptchaAutoSolve(TS): every challenge on every page is solved as it appears, and a click, fill, type or drag it interrupts is held and carries on afterwards.
Passive vs interactive — when not to call SolveCaptcha
The thing most users get wrong on day one is calling SolveCaptcha
defensively on every page load "just in case". You don't need to.
Passive challenges are everything the page does behind the scenes
to decide whether you're a bot: fingerprint analysis, behavioural
scoring, automation-flag detection (navigator.webdriver,
CDP-leak probes), TLS/JA3 fingerprinting, headless-browser tells,
proxy-quality checks. There is nothing on screen for you to interact
with — the page just decides whether to serve you content or block
you. browserscale's native pipeline (real browsers, real fingerprints, real
residential-grade exit IPs, no CDP-attached automation) is already
designed to pass these. No code required. If you find a site
that blocks browserscale on passive checks alone, that's a bug we want to
hear about — open a ticket or message us on
Discord.
Interactive challenges are the ones you've seen: a checkbox
("I'm not a robot"), a "press and hold" button, a slider you drag
into place. The page has put a widget on screen and is waiting for
a human (or a solver) to satisfy it. That's the case SolveCaptcha
is built for.
The decision rule is simple:
| You see… | Call SolveCaptcha? |
|---|---|
| Page loads normally, content is there. | No — passive check already passed. |
| Page is blocked or redirected to "verify you're human" but with no widget. | No — usually a passive check browserscale will pass; check your country/fingerprint config first. |
| A visible challenge widget (checkbox, slider, press-and-hold, etc.). | Yes — call SolveCaptcha. |
| You're not sure. | Try without first. Add SolveCaptcha only if the flow doesn't progress. |
The basic call
SolveCaptcha scans the page (every frame) for the first supported
interactive challenge, solves it in the live session, wires the
result back into the page, and returns. Most challenges don't surface
a token to the caller — the empty string back means "done, keep going."
if _, err := page.SolveCaptcha(ctx, 0, 2); err != nil {
log.Fatal(err)
}
// Captcha solved; the page is ready to proceed.await page.solveCaptcha({ retryAmount: 2 });
// Captcha solved; the page is ready to proceed.Two parameters, both optional:
| Parameter | Default | What it does |
|---|---|---|
timeoutMs | 0 → server default of 60 000 ms | How long to wait for a supported challenge to appear and be solved. Passing 0 is fine for most cases; raise it for slow-loading sites. |
retryAmount | 0 (no retries) | If the first solve attempt fails, retry this many times before giving up. Only meaningful for challenge types that can be retried (see below). |
What you get back
The return value is an empty string on both success and failure — the
string doesn't tell you anything. Check the err (Go) or rely on
the rejected promise (TS) to detect failure. The solution is wired
back into the page for you (the field, cookie, or state the challenge
expects), so the next interaction just works — there's no token to
carry around.
The return type is kept as a string for forward-compatibility, but today you can ignore it entirely.
A challenge that wasn't solved comes back as a SolveCaptchaError
with a code, and with the Kind / kind of challenge it found:
| Code | What happened |
|---|---|
not_found | No challenge waiting for an answer appeared within timeoutMs. One that passed on its own doesn't count, so the page may simply be through. |
unsupported | A challenge was found that can't be solved yet. |
solve_failed | The solver answered it and it didn't clear within retryAmount rounds. |
blocked | It was answered and the site replied with a block instead of letting the visitor through. Solving again in this session won't help; a fresh session, usually with another proxy or country, does. |
timeout | timeoutMs ran out while the solver was at it. |
page_closed | The page closed during the solve. |
cancelled | A navigation of the page started during the solve. |
_, err := page.SolveCaptcha(ctx, 0, 2)
var ce *browserscale.SolveCaptchaError
switch {
case errors.As(err, &ce) && ce.Code == "not_found":
// nothing to solve; carry on
case errors.As(err, &ce) && ce.Code == "blocked":
return fmt.Errorf("blocked, start over in a new session: %w", err)
case err != nil:
return err
}try {
await page.solveCaptcha({ retryAmount: 2 });
} catch (e) {
if (!(e instanceof SolveCaptchaError && e.code === "not_found")) throw e;
// nothing to solve; carry on
}Solve only when one shows up
Most flows don't know in advance whether a step will be challenged.
Instead of calling SolveCaptcha on spec and paying its timeout when
nothing comes, put Captcha() into the Wait
that follows the step, next to what you expect on success. It matches
as soon as a supported challenge waits for an answer on the page,
including inside iframes; a widget that passes without interaction
doesn't count. The result's Kind tells you which condition won, and
on a captcha match Captcha / captcha names the type of challenge
and its frame.
r, err := page.Wait(ctx,
browserscale.CSS("#dashboard"),
browserscale.Captcha(),
browserscale.Timeout(30000),
)
if err != nil {
return err
}
if r.Kind == browserscale.WaitKindCaptcha {
if _, err := page.SolveCaptcha(ctx, 0, 2); err != nil {
return err
}
_, err = page.Wait(ctx, browserscale.CSS("#dashboard"))
}const r = await page.waitAny([css("#dashboard"), captcha()], { timeoutMs: 30000 });
if (r.kind === "captcha") {
await page.solveCaptcha({ retryAmount: 2 });
await page.wait(css("#dashboard"));
}The wait does not hold the page, so it can also run beside a
SolveCaptcha — for example to catch the request a solved challenge
sends, with Request(url) in the same or a parallel wait.
Auto-solve: let the browser handle them
If a flow can be challenged at any step, wrapping every step in a wait
gets tedious. Turn on auto-solve instead: the browser then watches every
page, frame and popup of the session — including ones opened later — and
solves each challenge as it appears. Your code keeps calling Click,
Fill and friends as if nothing happened.
if err := browser.EnableCaptchaAutoSolve(ctx, browserscale.CaptchaAutoSolveOpts{}); err != nil {
log.Fatal(err)
}
// A challenge that pops up while the form is filled is solved,
// then the fill types the rest of its text.
res, err := page.Fill(ctx, browserscale.CSS("#email"), "user@example.com")
if err != nil {
return err
}
for _, c := range res.Captchas {
log.Printf("held %.0f ms by solve %s (%s)", c.DurationMs, c.SolveId, c.Outcome)
}await browser.enableCaptchaAutoSolve();
// A challenge that pops up while the form is filled is solved,
// then the fill types the rest of its text.
const res = await page.fill(css("#email"), "user@example.com");
for (const c of res.captchas ?? []) {
console.log(`held ${c.durationMs} ms by solve ${c.solveId} (${c.outcome})`);
}It is a setting of the browser, not of a page, and lasts until
DisableCaptchaAutoSolve or the end of the session. Calling
EnableCaptchaAutoSolve again replaces the settings; solves already
running keep the ones they started with.
What happens to your actions
An action running on the page when a challenge appears — Click,
Fill, Type, DragBy, DragTo — is held at its next safe
point: a fill or type between two keys, a click before the button goes
down. Once the challenge is solved, it carries on:
- In the same document, it resumes: a fill types the rest of its text, a click goes for its target again.
- If the solve replaced the document (some challenges reload the page when they clear), it restarts against the new one.
Every solve that held an action is listed under Captchas / captchas
in that action's result, with how long it held it and what the action
did afterwards (resumed, restarted, continued, failed).
The rest of the page's input waits too:
- An action started while a solve runs waits for it, then runs.
- Short actions (
MoveTo, a click on coordinates) finish first; the solve starts after them. InsertText,PressKeyandReleaseKeydon't wait — they are refused with codebusywhile a solve runs. Retry them after the solve, or useType, which is held like the others.- Time spent held doesn't count against the action's timeout, nor
against a running
Wait.
Settings
All fields are optional; the zero value (Go) or no argument (TS) uses the defaults.
| Go / TS | Default | What it does |
|---|---|---|
SolveTimeoutMs / solveTimeoutMs | 60000 | Budget for one solve. |
RetryAmount / retryAmount | the solver's own | Retry cap per solve, as in SolveCaptcha. |
OnFailure / onFailure | "fail" | What a held action does when its solve fails. "fail" ends it with code captcha_failed; "continue" lets it carry on as if the solve had worked. |
Unfocused / unfocused | "wait" | What happens to a challenge on a page that doesn't have the focus. Input only reaches the focused page, so it can't be solved there as it is. "wait" reports it and solves it once the page has the focus; "focus" brings the page to the front and solves it right away. |
MaxSolvesPerMinute / maxSolvesPerMinute | 5 | At most this many solves start per page within any 60 seconds. Further challenges are reported and given up with code limit_reached. Protects you from a page that keeps putting one up. |
With onFailure: "fail", a failed solve surfaces where you'd expect it:
the held Click, Fill or DragBy/DragTo fails with a ClickError,
FillError or DragError whose code is captcha_failed, and Type
fails with a CommandError with that code.
err := browser.EnableCaptchaAutoSolve(ctx, browserscale.CaptchaAutoSolveOpts{
OnFailure: "fail",
Unfocused: "focus",
MaxSolvesPerMinute: 3,
})
if err != nil {
log.Fatal(err)
}
_, err = page.Click(ctx, browserscale.CSS("button.submit"))
var ce *browserscale.ClickError
if errors.As(err, &ce) && ce.Code == "captcha_failed" {
// Re-navigate and try again, or give up on this flow.
}await browser.enableCaptchaAutoSolve({
onFailure: "fail",
unfocused: "focus",
maxSolvesPerMinute: 3,
});
try {
await page.click(css("button.submit"));
} catch (e) {
if (e instanceof ClickError && e.code === "captcha_failed") {
// Re-navigate and try again, or give up on this flow.
}
}Watching the solves
Each solve is reported on the browser's context
events: first a captcha detected event, then
exactly one captcha resolved event with the same solve id. Detected
says which page and frame, the type of challenge, what found it (auto,
or command for SolveCaptcha), whether the solve starts now (solving), waits for the
page to get the focus (waiting_for_focus) or was skipped because of
the per-minute limit (skipped), and which action it holds. Resolved
says whether it worked, how long it took and, if not, why — with a
code: solve_failed, blocked (see above), timeout, limit_reached,
page_closed, disabled (auto-solve was turned off before the solve started) or
cancelled (the page navigated away during the solve).
listener, err := browser.ContextEvents(ctx, func(ev browserscale.ContextEvent) {
switch ev.Kind {
case browserscale.ContextEventCaptchaDetected:
log.Printf("captcha on %s: %s", ev.Page.Id(), ev.Captcha.State)
case browserscale.ContextEventCaptchaResolved:
if ev.Captcha.Success {
log.Printf("solved in %.0f ms", ev.Captcha.DurationMs)
} else {
log.Printf("not solved: %s", ev.Captcha.Error.Code)
}
}
})
if err != nil { log.Fatal(err) }
defer listener.Stop()const listener = await browser.contextEvents((ev) => {
if (ev.kind === "captchaDetected") {
console.log(`captcha on ${ev.page.id}: ${ev.state}`);
} else if (ev.kind === "captchaResolved") {
console.log(ev.success ? `solved in ${ev.durationMs} ms` : `not solved: ${ev.error?.code}`);
}
});
// … later
await listener.stop();The events are reports, not state you need to track. A listener that
falls so far behind that it is sent a fresh page snapshot may have
missed some of them; the Captchas list on each action's result is the
reliable record for that action.
Auto-solve, Wait and SolveCaptcha together
- A
WaitwithCaptcha()takes precedence. While it runs on a page, auto-solve leaves that page's challenges alone, so the wait sees them first and your code decides. A solve that was already running is not affected. SolveCaptchajoins a running solve. Only one solve runs per page: if auto-solve is already working on one there,SolveCaptchawaits for it and returns its outcome instead of starting a second one.- Disabling is gentle.
DisableCaptchaAutoSolvelets a solve that is already running finish; one waiting for the focus is given up with codedisabled. It reports whether auto-solve was on.
Retries, and why they don't apply everywhere
retryAmount controls how many times the solve step is repeated
on failure, not how many times the detect step is repeated. The
useful distinction is:
- Retriable challenges — the widget stays on the page after a
failed solve, so another attempt can be made against the same
instance. Set
retryAmountto1–3. - One-shot challenges — the widget invalidates itself after a
failed attempt (rotates the puzzle, refreshes the token, or
outright blocks further attempts). For these,
retryAmountis effectively ignored — you get one shot, period.
There isn't a clean way to know in advance which bucket a given
challenge falls into; what we can tell you is that retryAmount
is a maximum, not a guarantee. Treat any specific value above zero
as best-effort. If a flow keeps failing on retries, drop the retry
count back to 0, let SolveCaptcha error cleanly, and handle
the retry at the script level (re-navigate, fresh attempt).
Which challenges are supported?
SolveCaptcha covers the common interactive challenge types you run
into in the wild. We deliberately don't enumerate the supported
providers here — the list shifts as both sides evolve, and the most
accurate answer is always the current one. For the up-to-date
list, ping us on Discord. If you've got
a site that uses a challenge we don't yet support, send us the URL
and we'll usually have it queued within a release or two.
Gotchas
- Don't call
SolveCaptchadefensively. If the page loads and your interactions work, there's nothing to solve. Adding a call "just in case" only costs you 60 s of timeout per page. - An empty result string is not an error. Both success and
failure return
""— only the error tells you whether it worked. retryAmountis a best-effort cap. One-shot challenges invalidate themselves after a failed attempt and retries can't recover. Handle retry at the script level (re-navigate, try again) for those.- Passive failure looks different. If a site silently shows you
a "we couldn't verify you" page with no widget,
SolveCaptchawon't help — there's no challenge to solve. The fix is upstream: check your country code and proxy quality. - A solve can take real time. The solver interacts like a human — moving, dragging, holding — so a challenge can take a few seconds to clear, and a slow-loading widget adds to that. Account for it in any per-action timeout you've configured elsewhere in your flow.
- The session keeps running on failure. A failed
SolveCaptchareturns an error but doesn't tear down the session — you can re-navigate, call it again with different parameters, or fall back to a manual workflow. The exception isblocked: the site has decided about this visitor, so start over in a fresh session. - With auto-solve, a background tab waits. By default a challenge
on a page that isn't in front is only solved once that page gets the
focus. If you drive several tabs and never bring that one forward,
set
Unfocused: "focus"/unfocused: "focus". busyfromInsertText/PressKeymeans a solve is running. Those calls are refused instead of held. Retry after the solve, or useType.
- Loading pages — first action you'll typically take before evaluating whether a challenge is on screen.
- Waiting — racing
Captcha()against the rest of the page. - Discord — for the current list of supported challenge types.
- Core concepts: Page — context events, which also report every captcha solve.
- API reference: Go
SolveCaptcha· TSsolveCaptcha· GoEnableCaptchaAutoSolve· TSenableCaptchaAutoSolve.