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.

TL;DR
  • Passive challenges and anti-bot scoring — browserscale already passes these without any code on your side. Don't call SolveCaptcha for them; there is nothing to solve.
  • Interactive challenges — that's what SolveCaptcha is 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 to 0 → 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.
  • retryAmount does 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 a Wait and call SolveCaptcha only 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.

Two parameters, both optional:

ParameterDefaultWhat it does
timeoutMs0 → server default of 60 000 msHow 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.
retryAmount0 (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:

CodeWhat happened
not_foundNo challenge waiting for an answer appeared within timeoutMs. One that passed on its own doesn't count, so the page may simply be through.
unsupportedA challenge was found that can't be solved yet.
solve_failedThe solver answered it and it didn't clear within retryAmount rounds.
blockedIt 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.
timeouttimeoutMs ran out while the solver was at it.
page_closedThe page closed during the solve.
cancelledA 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
}

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"))
}

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)
}

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, PressKey and ReleaseKey don't wait — they are refused with code busy while a solve runs. Retry them after the solve, or use Type, 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 / TSDefaultWhat it does
SolveTimeoutMs / solveTimeoutMs60000Budget for one solve.
RetryAmount / retryAmountthe solver's ownRetry 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 / maxSolvesPerMinute5At 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.
}

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()

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 Wait with Captcha() 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.
  • SolveCaptcha joins a running solve. Only one solve runs per page: if auto-solve is already working on one there, SolveCaptcha waits for it and returns its outcome instead of starting a second one.
  • Disabling is gentle. DisableCaptchaAutoSolve lets a solve that is already running finish; one waiting for the focus is given up with code disabled. 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 retryAmount to 1–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, retryAmount is 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 SolveCaptcha defensively. 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.
  • retryAmount is 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, SolveCaptcha won'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 SolveCaptcha returns 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 is blocked: 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".
  • busy from InsertText / PressKey means a solve is running. Those calls are refused instead of held. Retry after the solve, or use Type.
See also