> ## Documentation Index
> Fetch the complete documentation index at: https://docs.browserbase.com/llms.txt
> Use this file to discover all available pages before exploring further.

# CAPTCHA Solving

> Browserbase can solve supported CAPTCHA challenges automatically so your sessions can continue.

Browserbase enables CAPTCHA solving by default for all sessions.

**How it works**

* Expect CAPTCHA solving to take up to 30 seconds, depending on the challenge type.
* Pairing with [proxies](/platform/identity/proxies) improves success rates.
* For non-standard CAPTCHAs, you can provide custom selectors to guide the process.

Use CAPTCHA solving only for workflows that users and website owners authorize. Follow the site's terms, respect access controls, and use supported integrations when available.

To disable CAPTCHA solving, set `solveCaptchas` to `false` in `browserSettings` when [creating a session](/platform/browser/getting-started/create-browser-session).

### CAPTCHA solving events

Browserbase emits a console log when it detects a CAPTCHA and begins solving. Listen to these events before your agent continues.

<Tabs>
  <Tab title="Node.js">
    <CodeGroup>
      ```typescript Playwright theme={null}
      const recaptcha = await page.goto("https://www.google.com/recaptcha/api2/demo");

      page.on("console", (msg) => {
        if (msg.text() == "browserbase-solving-started") {
          console.log("Captcha Solving In Progress");
        } else if (msg.text() == "browserbase-solving-finished") {
          console.log("Captcha Solving Completed");
        }
      });
      ```

      ```typescript Selenium theme={null}
      // Replace your existing Builder configuration with this code
      const driver = new Builder()
        .withCapabilities({
          browserName: "chrome", // add browser name
          "goog:loggingPrefs": {
            driver: "ALL", // add driver logs
          },
        })
        .usingHttpAgent(customHttpAgent)
        .usingServer(session.seleniumRemoteUrl)
        .build();

      // Add this code where you want to check for CAPTCHA solving
      const driverLogs = await driver.manage().logs().get("driver");

      // Example check for CAPTCHA solving events
      driverLogs
        .filter((log) => log.message.includes("browserbase-solving"))
        .forEach((log) => console.log(log.message));
      ```
    </CodeGroup>
  </Tab>

  <Tab title="Python">
    <CodeGroup>
      ```python Playwright theme={null}
      # Add this code where you want to check for CAPTCHA solving
      def handle_console(msg):
          if msg.text == "browserbase-solving-started":
              print("Captcha Solving In Progress")
          elif msg.text == "browserbase-solving-finished":
              print("Captcha Solving Completed")

      page.on("console", handle_console)
      ```

      ```python Selenium theme={null}
      # Configure logging preferences when creating the driver
      options = webdriver.ChromeOptions()
      options.set_capability("goog:loggingPrefs", {"driver": "ALL"})
      driver = webdriver.Remote(command_executor=session.selenium_remote_url, options=options)

      # Add this code where you want to check for CAPTCHA solving
      logs = driver.get_log("driver")
      for log in logs:
          if "browserbase-solving-started" in log["message"]:
              print("Captcha Solving In Progress")
          elif "browserbase-solving-finished" in log["message"]:
              print("Captcha Solving Completed")
      ```
    </CodeGroup>
  </Tab>
</Tabs>

### Custom CAPTCHA solving

If you encounter a non-standard, or custom CAPTCHA provider, you need to specify the explicit selector for the CAPTCHA image and button itself.

For this custom CAPTCHA provider, you'll need to specify two CSS selectors:

<Steps>
  <Step title="The selector for the CAPTCHA image element">
    <img src="https://mintcdn.com/browserbase/m1Ny8qOvNHvtrY7y/images/features/custom-captcha.png?fit=max&auto=format&n=m1Ny8qOvNHvtrY7y&q=85&s=28c7563f272fab14a2a4822500ada092" alt="" width="450" height="124" data-path="images/features/custom-captcha.png" />
  </Step>

  <Step title="Right-click on the CAPTCHA image and select 'Inspect' then pull the 'id' from the HTML source code of the image">
    ```html theme={null}
    <img class="LBD_CaptchaImage" id="c_turingtestpage_ctl00_maincontent_captcha1_CaptchaImage" src="/BotDetectCaptcha.ashx?get=image&amp;c=c_turingtestpage_ctl00_maincontent_captcha1&amp;t=759cbf332a684ae3abe16213fe76438c" alt="CAPTCHA">
    ```

    The id in this example is `c_turingtestpage_ctl00_maincontent_captcha1_CaptchaImage`
  </Step>

  <Step title="The selector for the input field where the solution should be entered">
    <img src="https://mintcdn.com/browserbase/m1Ny8qOvNHvtrY7y/images/features/captcha-input.png?fit=max&auto=format&n=m1Ny8qOvNHvtrY7y&q=85&s=84649199696e32f8f46a0f469655ff23" alt="" width="450" height="78" data-path="images/features/captcha-input.png" />
  </Step>

  <Step title="Right-click on the input field and select 'Inspect' then pull the 'id' from the HTML source code of the input field">
    ```html theme={null}
    <input name="ctl00$MainContent$txtTuringText" type="text" value="Enter the characters shown above" maxlength="6" id="ctl00_MainContent_txtTuringText" class="swap_value field" initialvalue="Enter the characters shown above" title="Enter the characters shown above">
    ```

    The id in this example is `ctl00_MainContent_txtTuringText`
  </Step>

  <Step title="Configure your browser settings with these selectors">
    ```javascript theme={null}
    browserSettings: {
      captchaImageSelector: "#c_turingtestpage_ctl00_maincontent_captcha1_CaptchaImage",
      captchaInputSelector: "#ctl00_MainContent_txtTuringText"
    }
    ```
  </Step>
</Steps>

### Disabling CAPTCHA solving

CAPTCHA solving typically takes between 5 and 30 seconds.

If you'd like to disable captcha solving, you can set `solveCaptchas` to `false` in the `browserSettings` when creating a session.

<Tabs>
  <Tab title="Node.js">
    ```javascript SDK theme={null}
    import Browserbase from "@browserbasehq/sdk";

    const bb = new Browserbase({apiKey: process.env.BROWSERBASE_API_KEY!});

    async function createSessionWithoutCaptchaSolving() {
      const session = await bb.sessions.create({
        browserSettings: {
          solveCaptchas: false,
        },
      });
      return session;
    }

    const session = await createSessionWithoutCaptchaSolving();
    console.log(session);
    ```
  </Tab>

  <Tab title="Python">
    ```python SDK theme={null}
    from browserbase import Browserbase
    import os

    bb = Browserbase(api_key=os.environ["BROWSERBASE_API_KEY"])

    def createSessionWithoutCaptchaSolving():
        session = bb.sessions.create(
            browser_settings={
              "solveCaptchas": False,
            }
        )
        return session

    session = createSessionWithoutCaptchaSolving()
    print(session)
    ```
  </Tab>
</Tabs>
