CAPSOLVER
Blog
How to solve reCaptcha v2 using Selenium [Javascript] with Capsolver Extension

How to solve reCaptcha v2 using Selenium [Javascript] with Capsolver Extension

Logo of CapSolver

Lucas Mitchell

Automation Engineer

22-Nov-2023

reCaptcha solver selenium

Solving reCaptcha Using Selenium and Capsolver Extension

In this blog, we'll guide you through the process of setting up Selenium with the Capsolver extension to solve reCaptcha v2. This method can also be applied to other types of captchas.

1. Installing Selenium and Required Components

First, you need to install Selenium and other necessary components. You can do this using npm:

Copy
npm install selenium-webdriver

Make sure you have the appropriate drivers for the browser you intend to use (e.g., ChromeDriver for Google Chrome, GeckoDriver for Firefox).

2. Configuring the Capsolver Extension

Download the Capsolver extension from here. Unzip it into the ./CapSolver.Browser.Extension directory at the root of your project.

The extension offers various settings, including automatic captcha solving, proxy support, and more. These settings are located in ./assets/config.json. Here's an example of the configuration:

json Copy
{
  "apiKey": "YourApiKey",
  "useCapsolver": true,
  "useProxy": false,
  "proxyType": "http",
  "hostOrIp": "",
  "port": "",
  "proxyLogin": "",
  "proxyPassword": "",
  "enabledForBlacklistControl": false,
  "blackUrlList": [],
  "enabledForRecaptcha": true,
  "enabledForRecaptchaV3": true,
  "enabledForcaptcha": true,
  "enabledForcaptcha": true,
  "reCaptchaMode": "token",
  "captchaMode": "click",
  "reCaptchaDelayTime": 0,
  "captchaDelayTime": 0,
  "reCaptchaRepeatTimes": 10,
  "reCaptcha3RepeatTimes": 10,
  "captchaRepeatTimes": 10,
  "captchaRepeatTimes": 10
}

Insert your API key in the apiKey field in ./assets/config.json. You can find your API key on the Capsolver page.

For this example, we'll use the reCaptchaMode set to token, but you can also use click mode for reCaptcha.

3. Setting Up Selenium to Solve reCaptcha with Capsolver Extension

First, you need to set up Selenium WebDriver and configure it to use the Capsolver extension. Here's an example using ChromeDriver:

javascript Copy
const { Builder } = require('selenium-webdriver');
const chrome = require('selenium-webdriver/chrome');
const path = require('path');

(async function solveCaptcha() {
  let options = new chrome.Options();
  options.addArguments(`--load-extension=${path.join(__dirname, 'CapSolver.Browser.Extension')}`);

  let driver = await new Builder()
    .forBrowser('chrome')
    .setChromeOptions(options)
    .build();

  try {
    // Navigate to the page with reCaptcha
    await driver.get('https://www.google.com/recaptcha/api2/demo');

    // Wait for the captcha solver button and click it
    await driver.wait(until.elementLocated(By.css('#recaptcha-anchor-label')), 10000);
    await driver.findElement(By.css('#recaptcha-anchor-label')).click();

    // Add additional steps as per your requirement

  } finally {
    await driver.quit();
  }
})();

Full Code:

javascript Copy
const { Builder, By, until } = require('selenium-webdriver');
const chrome = require('selenium-webdriver/chrome');
const path = require('path');

(async function solveCaptcha() {
  let options = new chrome.Options();
  options.addArguments(`--load-extension=${path.join(__dirname, 'CapSolver.Browser.Extension')}`);

  let driver = await new Builder()
    .forBrowser('chrome')
    .setChromeOptions(options)
    .build();

  try {
    await driver.get('https://site.example');
    await driver.wait(until.elementLocated(By.css('#recaptcha-anchor-label')), 10000);
    await driver.findElement(By.css('#recaptcha-anchor-label')).click();
  } finally {
    await driver.quit();
  }
})();

And that's it! You have successfully solved reCaptcha v2 using the Capsolver Extension and Selenium. To solve other types of captchas, simply follow the same steps and adjust accordingly.

Capsolver Team šŸ’œ

Compliance Disclaimer: The information provided on this blog is for informational purposes only. CapSolver is committed to compliance with all applicable laws and regulations. The use of the CapSolver network for illegal, fraudulent, or abusive activities is strictly prohibited and will be investigated. Our captcha-solving solutions enhance user experience while ensuring 100% compliance in helping solve captcha difficulties during public data crawling. We encourage responsible use of our services. For more information, please visit our Terms of Service and Privacy Policy.

More

The-Ultimate-CAPTCHA-Solver
Best Captcha Solver Extension, What Extension Service Solves Captcha Automatically?

Solve CAPTCHAs automatically with the CapSolver browser extension — the fastest, AI-powered CAPTCHA solver for Chrome

Extension
Logo of CapSolver

Sora Fujimoto

21-Oct-2025

Captcha Solver Extensions
Captcha Solver Extensions, How to Install Captcha Solver Extension

How to install and use the CapSolver browser extension — the best AI-powered CAPTCHA solver for Chrome and Firefox. Discover its benefits, automation integration, and easy setup guide for effortless CAPTCHA handling.

Extension
Logo of CapSolver

Lucas Mitchell

20-Oct-2025

reCAPTCHA-Auto-Solver
How to Solve reCAPTCHAs Automatically | the Best reCAPTCHA Auto Solver

Discover the ultimate reCAPTCHA Auto Solver. Learn how CapSolver's AI-powered Chrome Extension automates reCAPTCHA v2, v3 solving with high accuracy and efficiency. Boost your productivity today.

Extension
Logo of CapSolver

Ethan Collins

20-Oct-2025

Auto Captcha Solver Chrome
Auto Captcha Solver Chrome: CapSolver Auto Solver Extension Download

Looking for the best Chrome extension to automatically solve captchas? CapSolver Auto Solver Extension offers a fast, AI-powered way to bypass reCAPTCHA and other verification challenges.

Extension
Logo of CapSolver

Lucas Mitchell

18-Oct-2025

Auto CAPTCHA Solver
Auto CAPTCHA Solver, Best CAPTCHA Solver Extension

Learn how to install and use the CapSolver browser extension, the most efficient auto CAPTCHA solver for Chrome, Firefox, Puppeteer, and Selenium. Automate Captcha with AI-powered browser integration.

Extension
Logo of CapSolver

Sora Fujimoto

17-Oct-2025

Auto captcha solver on chrome: CapSolver
What is the Best Auto Captcha Solver on Chrome

CapSolver for Chrome automatically solves CAPTCHAs, saving time and providing a seamless browsing experience.

Extension
Logo of CapSolver

Lucas Mitchell

16-Oct-2025