Browser Use. agent runner


Agent Automation · Browser Use
Solve CAPTCHAs Inside Your Browser Use Agent
Add CapSolver as a custom action in Browser Use. When a CAPTCHA or verification challenge appears, the agent can send the required details to CapSolver, receive the solution, and continue the authorized browser workflow. Built for QA, RPA, and other user-authorized browser automation.
Overview
What does the CapSolver + Browser Use integration do?
Browser Use helps AI agents navigate and interact with websites. When a CAPTCHA appears, CapSolver handles the challenge and returns the result so the agent can continue its task.
Works with Browser Use
Widely used verification challenges that appear during automated browser workflows and require token-based validation.
Token returned to the agent
CapSolver returns the CAPTCHA result so the agent can apply it and continue.
Production-ready
Each solve returns a task ID (taskId), status, and error detail for logging and retries.
The Problem
Why do CAPTCHAs stop Browser Use agents?
Browser Use agents can navigate, click, and type, but CAPTCHA and verification checks can interrupt a multi-step task. Without a way to handle them, the agent may stop, repeat the same step, or need human help.
Workflow interruption
A CAPTCHA can stop the agent in the middle of a browser task.
Manual fallback
Someone on your team has to step in when the agent gets blocked.
No CAPTCHA handling
Browser Use can click and type, but it still needs help when a CAPTCHA appears.
A new IP is not enough
Changing the IP may help in some cases, but it does not solve a CAPTCHA already on the page.
Use Cases
When should you add CapSolver to a Browser Use agent?
Public-data workflows
Support approved research and data collection when CAPTCHA checks interrupt the task.
Form and workflow testing
Test signup, login, checkout, and form flows in approved environments.
Internal business workflows
Support approved browser tasks across internal tools and business systems.
Supervised browser agents
Help supervised AI agents continue when a CAPTCHA interrupts an authorized browser task.
Quick Start
Register CapSolver as a custom action
The example below works today against CapSolver's public REST API. It registers one action the agent can call on any CAPTCHA, solves it, and returns the token to the agent — which fills the challenge field and submits.
# pip install browser-use capsolver-agent
# export CAPSOLVER_API_KEY=CAP-XXXXXX
# export OPENAI_API_KEY=sk-XXXXXX
import asyncio
import json
import os
from browser_use import ActionResult, Agent, Browser, ChatOpenAI, Tools
from capsolver_core import Capsolver
from capsolver_core.capsolver import SolveOnPageOptions
from _env import load_example_env # demo only: reads repo-root .env
load_example_env()
# 1. Adapt Browser Use's live page to capsolver-core's PageDriver (evaluate + url).
class PageDriver:
def __init__(self, session):
self.session = session
async def url(self) -> str:
return await self.session.get_current_page_url()
async def evaluate(self, script: str, arg=None):
cdp = await self.session.get_or_create_cdp_session()
result = await cdp.cdp_client.send.Runtime.evaluate(
params={
"expression": f"({script})({json.dumps(arg)})",
"returnByValue": True,
"awaitPromise": True,
},
session_id=cdp.session_id,
)
return result.get("result", {}).get("value")
# 2. Register one action: detect + solve + autofill on the page the agent controls.
tools = Tools()
capsolver = Capsolver(api_key=os.environ["CAPSOLVER_API_KEY"])
@tools.action(
description="Solve and autofill every supported captcha (reCaptchaV2 / reCaptchaV3 / "
"cloudflare) on the current page. Never solve a captcha yourself."
)
async def solve_page_captchas(browser_session) -> ActionResult:
results = await capsolver.solve_on_page(
PageDriver(browser_session),
options=SolveOnPageOptions(autofill=True, throw_on_error=False),
)
if not results:
return ActionResult(extracted_content="No supported captcha on this page.")
filled = sum(1 for r in results if r.filled)
if not filled:
return ActionResult(error="; ".join(r.error or "not filled" for r in results))
return ActionResult(
extracted_content=f"Filled {filled}/{len(results)} captcha tokens. Continue the "
"workflow now, e.g. click Submit.",
)
# 3. Hand the action to the agent; the LLM decides when to call it.
model = os.environ.get("OPENAI_MODEL", "gpt-4o")
# OpenAI-compatible gateways (DeepSeek, ...) reject OpenAI's structured-output format.
compat = {} if "openai.com" in os.environ.get("OPENAI_BASE_URL", "openai.com") else {
"dont_force_structured_output": True,
"add_schema_to_system_prompt": True,
}
agent = Agent(
task="Solve the captcha on this page, then click Submit and report the result.",
llm=ChatOpenAI(model=model, **compat),
browser=Browser(headless=False),
tools=tools,
initial_actions=[{"navigate": {"url": "https://www.google.com/recaptcha/api2/demo"}}],
)
# 4. Run.
asyncio.run(agent.run())
Step by Step
How to add CAPTCHA solving in 4 steps
Install & set your key
Install browser-use and an HTTP client, then export CAPSOLVER_API_KEY. Never hardcode it.
Register a custom action
Add a @tools.action that calls CapSolver to solve the CAPTCHA and returns the token.
Pass tools to the Agent
Give the tools registry to the Agent so it can call solve_captcha whenever a CAPTCHA appears.
Run & recover
Run the agent; on failure it returns a structured error with a task ID for logging and retries.
Coverage
Which CAPTCHA types does CapSolver support for Browser Use?
Browser Use supports reCAPTCHA v2, reCAPTCHA v3, their Enterprise variants, and Cloudflare Turnstile.
reCAPTCHA v2
Standard, invisible, and Enterprise reCAPTCHA v2 challenges.
reCAPTCHA v3
Score-based and Enterprise reCAPTCHA v3 challenges with action support.
Cloudflare Turnstile
Managed, non-interactive, and invisible Turnstile widgets.
More CAPTCHA types
Explore additional CAPTCHA task types available through the CapSolver API.
Positioning
Browser Use + CapSolver vs. proxy rotation
Proxies help Browser Use agents reach websites. CapSolver handles supported CAPTCHAs when they appear, helping the agent continue its task.
Capability
Proxy / IP rotation
CapSolver
Reaches the target page
Yes
Use alongside
Answers an on-screen CAPTCHA
No
Works alongside
Solves supported CAPTCHAs
No
Yes
Returns a CAPTCHA token
Retries, may re-block
Yes
Provides task details
Varies
Task ID, status, and errors
Keep your browser setup and proxies. Add CapSolver to handle supported CAPTCHAs when they appear.
Production
Best practices for production Browser Use agents
Add CapSolver before the agent runs
Make CAPTCHA solving available before the agent starts its browser task.
Handle success and failure
Let the agent continue after a successful result and stop safely when a request fails.
Log every CAPTCHA request
Record the task ID, CAPTCHA type, status, and errors for each request.
Set a request timeout
Stop waiting after a set time so the agent does not remain stuck.
Use the correct response field
reCAPTCHA and Cloudflare Turnstile return results in different fields.
Store your API key securely
Keep CAPSOLVER_API_KEY in an environment variable or secret manager.
FAQ
Policy
Responsible use
CapSolver is designed for responsible automation: authorized QA testing, RPA workflows, accessibility tooling, public-data access, and other compliant tasks. Users are responsible for ensuring their use complies with the applicable terms of service and regulations of the sites they access. CapSolver does not support or condone unauthorized access or malicious automation.
Related Integrations
Explore more CapSolver integrations for your agent stack
Choose another integration to add CAPTCHA solving to your agent or browser workflow.

Add CAPTCHA solving to your Browser Use agent
Start with a free trial and keep authorized browser workflows moving when supported CAPTCHAs appear.
