# Captcha (/browser-api/captcha)

RunHBrowser can solve captchas for you. Automatic solving is **off by default**.

> **Rolling out.** The `Captcha` CDP domain is rolling out together with the product. Detection covers common captcha widgets only; do not assume that every captcha on every site is detected or solved.

## Turn on automatic solving [#turn-on-automatic-solving]

Use any of these:

- the captcha setting of a browser account, in the dashboard;
- the captcha setting of a profile, in the dashboard;
- the `captcha-auto` modifier for one session:

```text
wss://<login>-captcha-auto:<password>@browser.runharvester.com
```

The usual [priority order](/browser-api/connection-url#priority) applies: the URL modifier wins over the profile, which wins over the account.

## Control solving from a script [#control-solving-from-a-script]

RunHBrowser adds a vendor CDP domain named `Captcha`.

| Item | Parameters | Meaning |
| --- | --- | --- |
| `Captcha.solve` | `{ targetId? }` | Solve the captcha on a page. `targetId` optionally names the tab. |
| `Captcha.waitForSolve` | `{ timeout }` in milliseconds | Wait for a solve to finish, for up to `timeout` milliseconds. |
| `Captcha.detected` (event) | | A captcha was found on a page. |
| `Captcha.solveFinished` (event) | | A solve succeeded. |
| `Captcha.solveFailed` (event) | | A solve failed. |

Puppeteer and Playwright do not know this domain, so send the commands through a CDP client. In Puppeteer, `page.createCDPSession()` returns one; in Playwright, `context.newCDPSession(page)`.

```javascript
import puppeteer from "puppeteer-core";

const browser = await puppeteer.connect({
  browserWSEndpoint: process.env.BROWSER_WS_URL,
});

const page = await browser.newPage();
const client = await page.createCDPSession();

client.on("Captcha.solveFinished", () => console.log("solved"));
client.on("Captcha.solveFailed", () => console.log("solve failed"));

await page.goto("https://example.com/protected");
await client.send("Captcha.solve", {});
await client.send("Captcha.waitForSolve", { timeout: 60000 });

console.log(await page.title());
await browser.close();
```

## Billing [#billing]

Captcha solving is billed per solve. A failed solve is refunded. See [Billing](/browser-api/billing).