
Lucas Mitchell
Automation Engineer
Published Nov 22, 2023
Updated Nov 22, 2023 ยท min read

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.
First, you need to install Selenium and other necessary components. You can do this using npm:
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).
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:
{
"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.
First, you need to set up Selenium WebDriver and configure it to use the Capsolver extension. Here's an example using ChromeDriver:
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();
}
})();
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 ๐

Lucas Mitchell
Automation Engineer
Helping browser automation recover and continue.
ABOUT THE AUTHOR
Compare CAPTCHA solver APIs and browser extensions for manual browsing, QA, and agents. Choose by runtime, page handling, task control, and verified outcomes.

Choose the best CAPTCHA extension for Chrome automation, QA, and browser testing with CapSolver support for reCAPTCHA, Turnstile, text CAPTCHA, and AWS WAF.
