
Ethan Collins
Pattern Recognition Specialist
BrowserCloud is a high-performance, cloud-based browser automation platform designed for scalable and distributed web automation. It enables developers to run hundreds of headless Chrome browsers in parallel for use cases such as web scraping, automated testing, SEO monitoring, data extraction, and content generation. With built-in support for Puppeteer, Selenium, and Playwright, BrowserCloud simplifies complex automation workflows by offering proxy rotation, session management, and real-time monitoring.
However, CAPTCHAs, bot detection systems, and advanced anti-automation measures often disrupt these browser automation tasks by demanding human-like interactions to verify authenticity. Such barriers can block scraping scripts, slow down testing pipelines, and break automated form submissions, resulting in wasted time and reduced efficiency.
CapSolver, an AI-powered CAPTCHA-solving and bot detection bypass service, provides a reliable solution. It programmatically detects and solves a wide range of CAPTCHA types—including reCAPTCHA v2/v3, Cloudflare Turnstile, and image-based puzzles—ensuring uninterrupted browser automation workflows.
In this article, we’ll provide a step-by-step integration guide for connecting CapSolver with BrowserCloud using Puppeteer, along with a fully working code example. By following this guide, you’ll be able to seamlessly bypass CAPTCHA challenges, defeat anti-bot measures, and maximize the efficiency of your automation scripts.
BrowserCloud is a versatile platform that manages a grid of full-featured Chrome browsers on high-performance infrastructure, eliminating the need to handle local browser dependencies, memory leaks, or infrastructure maintenance. Its key features include:
BrowserCloud supports a range of automation tasks, including:
These use cases often encounter CAPTCHAs, making CapSolver’s integration essential for uninterrupted automation.
Websites deploy CAPTCHAs and anti-bot defenses to protect against automated access, spam, and malicious activities, posing a significant challenge for automation tasks like web scraping. CAPTCHAs require interactions such as clicking checkboxes or solving image puzzles, which can halt BrowserCloud scripts if not addressed. Common CAPTCHA types include:
| CAPTCHA Type | Description |
|---|---|
| reCAPTCHA v2 | Requires users to check a box or select images based on a prompt. |
| reCAPTCHA v3 | Uses a scoring system to assess user behavior, often invisible to users. |
| Cloudflare Turnstile | A privacy-focused CAPTCHA alternative that minimizes user interaction. |
For web scraping and other automation tasks, CAPTCHAs can prevent access to critical data, requiring manual intervention that defeats the purpose of automation. While BrowserCloud’s proxy rotation helps reduce CAPTCHA triggers, it may not eliminate them entirely. CapSolver’s API provides a reliable solution by solving CAPTCHAs programmatically, allowing BrowserCloud scripts to bypass these barriers and continue extracting data or performing tasks seamlessly.
CapSolver’s API can be integrated with BrowserCloud within a Puppeteer/Playwright/Selenium script to handle CAPTCHAs effectively. The process involves:
This integration leverages BrowserCloud’s scalable browser infrastructure and CapSolver’s AI-driven CAPTCHA-solving capabilities to ensure robust automation workflows.
Below is a complete code example that demonstrates how to integrate CapSolver with BrowserCloud to solve a reCAPTCHA v2 on a demo page. The code is based on the provided script, with minor improvements for clarity and reliability.
Install the required dependencies:
npm install puppeteer node-fetch@2 dotenv
Create a .env file with your API keys:
BROWSER_CLOUD_TOKEN=your_browsercloud_token
CAPSOLVER_API_KEY=your_capsolver_api_key
import puppeteer from 'puppeteer';
import fetch from 'node-fetch';
import dotenv from 'dotenv';
dotenv.config();
const BROWSER_CLOUD_TOKEN = process.env.BROWSER_CLOUD_TOKEN;
const CAPSOLVER_API_KEY = process.env.CAPSOLVER_API_KEY;
async function solveCaptcha(sitekey, pageUrl) {
const createTaskRes = await fetch('https://api.capsolver.com/createTask', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
clientKey: CAPSOLVER_API_KEY,
task: {
type: 'ReCaptchaV2TaskProxyless',
websiteURL: pageUrl,
websiteKey: sitekey
}
})
});
const createTask = await createTaskRes.json();
if (!createTask.taskId) throw new Error(`CapSolver: Failed to create task: ${JSON.stringify(createTask)}`);
let solution = null;
while (true) {
await new Promise(resolve => setTimeout(resolve, 2000));
const resultRes = await fetch('https://api.capsolver.com/getTaskResult', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
clientKey: CAPSOLVER_API_KEY,
taskId: createTask.taskId
})
});
const result = await resultRes.json();
if (result.status === 'ready') {
solution = result.solution.gRecaptchaResponse;
break;
}
if (result.status === 'failed') throw new Error(`CapSolver: Failed to solve: ${JSON.stringify(result)}`);
}
if (!solution) throw new Error('CapSolver: Timeout waiting for solution');
return solution;
}
(async () => {
try {
const browser = await puppeteer.connect({
browserWSEndpoint: `wss://chrome-v2.browsercloud.io?token=${BROWSER_CLOUD_TOKEN}`
});
const page = await browser.newPage();
await page.goto('https://recaptcha-demo.appspot.com/recaptcha-v2-checkbox.php', { waitUntil: 'networkidle2' });
const sitekey = await page.$eval('.g-recaptcha', el => el.getAttribute('data-sitekey'));
console.log('Sitekey:', sitekey);
const solution = await solveCaptcha(sitekey, page.url());
console.log('CAPTCHA solution:', solution);
await page.evaluate(token => {
const textarea = document.getElementById('g-recaptcha-response');
if (textarea) {
textarea.value = token;
textarea.innerHTML = token;
textarea.style.display = '';
textarea.dispatchEvent(new Event('input', { bubbles: true }));
}
}, solution);
const submitBtn = await page.$('body > main > form > fieldset > button');
if (submitBtn) {
await Promise.all([
page.waitForNavigation({ waitUntil: 'networkidle2' }),
submitBtn.click()
]);
console.log('Submit button clicked!');
} else {
console.log('Submit button not found!');
}
console.log('Page content after submission:', await page.content());
await browser.close();
} catch (error) {
console.error('Error:', error);
}
})();
| Step | Description |
|---|---|
| 1. Set Up Environment | Install puppeteer, node-fetch@2, and dotenv using npm. Create a .env file with your BrowserCloud and CapSolver API keys. |
| 2. Define solveCaptcha Function | The function takes the site key and page URL, creates a CapSolver task for reCAPTCHA v2, polls for the solution (up to 30 attempts with 2-second intervals), and returns the solution token. |
| 3. Connect to BrowserCloud | Use puppeteer.connect with the BrowserCloud WebSocket endpoint, including your API token. Note that createIncognitoBrowserContext is not supported in BrowserCloud’s remote mode, so use browser.newPage() directly. |
| 4. Navigate to Target Page | Open a new page and navigate to the demo page with reCAPTCHA v2, waiting for the network to be idle. |
| 5. Extract Site Key | Use page.$eval to retrieve the data-sitekey attribute from the .g-recaptcha element. |
| 6. Solve CAPTCHA | Call solveCaptcha with the site key and page URL to obtain the solution token from CapSolver. |
| 7. Inject Solution | Inject the solution token into the g-recaptcha-response textarea and dispatch an input event to simulate user interaction. |
| 8. Submit Form | Locate the submit button, click it, and wait for navigation to ensure the form submission is processed. |
| 9. Verify Result | Print the page content to confirm successful submission. |
| 10. Close Browser | Close the browser connection to free resources. |
Note: The original code used page.waitForTimeout(3000) after clicking the submit button, which may not reliably wait for navigation. This example improves it by using page.waitForNavigation() to ensure the page has fully loaded after submission.
This section describes the script’s execution on a demo page with a reCAPTCHA v2 checkbox:
g-recaptcha-response textarea, simulating a successful CAPTCHA verification.In practice, you would observe the browser navigating to the demo page, the reCAPTCHA checkbox being marked automatically, and the form submitting successfully, all without manual intervention.
| Question | Answer |
|---|---|
| What types of CAPTCHAs does CapSolver support? | CapSolver supports reCAPTCHA v2/v3, Cloudflare Turnstile and more. See CapSolver documentation for details. |
| How do I get API keys for BrowserCloud and CapSolver? | Sign up at BrowserCloud and CapSolver to obtain your API keys after registration. |
| Can I use this integration with Selenium or Playwright? | Yes, you can adapt the integration for Selenium or Playwright by modifying the browser control and page manipulation logic to match those frameworks’ APIs. |
| What if CapSolver fails to solve the CAPTCHA? | Implement retry logic in your script or check your CapSolver account for issues like insufficient balance. Log errors for debugging. |
| Do I need proxies with CapSolver? | The example uses ReCaptchaV2TaskProxyless, but proxies may be needed for region-specific CAPTCHAs. BrowserCloud’s built-in proxy rotation can complement this. |
Integrating CapSolver with BrowserCloud creates a powerful combination for automating web tasks that encounter CAPTCHAs. CapSolver’s AI-driven CAPTCHA solving ensures that your Puppeteer scripts on BrowserCloud can bypass anti-bot measures, while BrowserCloud’s scalable infrastructure and proxy support enhance automation reliability. This is particularly valuable for web scraping, automated testing, and content generation, where CAPTCHAs are common obstacles.
To get started, sign up for BrowserCloud and CapSolver, obtain your API keys, and implement the provided code example. Explore the CapSolver documentation and BrowserCloud documentation for advanced features and additional task types. Try this integration in your next automation project and experience seamless, uninterrupted workflows!
Bonus for Browser-use Users: Use the promo code BROWSERCLOUD when recharging your CapSolver account and receive an exclusive 6% bonus credit—no limits, no expiration.
CapSolver evolves into a core automation layer with improved UI, integrations, and enterprise-grade data capabilities.

Discover the best AI for solving image puzzles. Learn how CapSolver's Vision Engine and ImageToText APIs automate complex visual challenges with high accuracy.
