Hi all, in this tutorial we will explain a way to solve ReCaptcha by using Selenium.

2Captcha.com’s API used for solving Google’s Invisible Recaptcha and Recaptcha v2 with Java Selenium Chrome Browser Test Automation.

  • Solve image challenges.
  • Retry for image challenges.
  • Click I am no robot checkbox.
  • Response to invisible captcha forms.

Google has a demo website that includes a dummy form. This example has been tested on this demo website. URL without query string will show I am not a robot. You should add “?invisible=true” at the end of the following URL. When invisible=true there will be an extra request to 2captcha.com for resolution of the invisible captcha. This repository is compatible with all Google Recaptcha types.

https://www.google.com/recaptcha/api2/demo

Prerequisites for starting reCaptcha Automation?

  • https://2captcha.com/ Account with a minimum of 3$ balance for 1000 Recaptcha. (Starting from 0.5 USD for 1000 solved CAPTCHAs by data entry workers)
  • Development needs Java JDK v1.8.0, Maven, IntelliJ (preferable IDE)

You should also:

  • Change configuration and site settings from “src\test\resources\config.properties” file.
  • Use 2captcha.com Sandbox mode (for developers) for image selection challenges.
  • Use proxy settings for test automation running (not required, but recommended).

Why do we need 2captcha.com API services?

Because you can not fight with Google. You need to analyze and decide to answer like a human. If you have software that has artificial intelligence and learns continuously everything changes. All of these solutions are of course paid.

2captcha.com solves different types of captchas:

Normal Captcha, Text Captcha, ReCaptcha V2, ReCaptcha V3, GeeTest, ReCaptcha V2 (old method), Solving ClickCaptcha, RotateCaptcha, FunCaptcha, FunCaptcha Token Method, KeyCaptcha, hCaptcha

To start using 2captcha.com service:

Service provides an API that allows you to solve different types of captchas.

  • Register 2captcha.com.
  • Implement 2captcha.com API.
  • Send 2captcha.com to your CAPTCHAs.
  • Get your answer/directions as text.

Other popular alternatives

  • anti-captcha.com
  • deathbycaptcha.com
  • azcaptcha.com

How to configure?

Chrome Browser Driver

  • You have to download the correct driver for your operating system. There are 3 versions of the driver:
    (Windows/Linux/Mac) https://chromedriver.chromium.org/downloads
  • You have to download the correct version of the driver for your Chrome Browser. Just check your browser version before downloading the file to this location “src\test\resources\drivers“. After that, you should fix the filename and extension on this file “src\test\java\base\DriverBase

config.properties file

  • Required fields: apiKey,googleKey,pageUrl.
  • apikey is YOUR API KEY FROM 2captcha.com ->dashboard->Account Settings -> Copy API Key
  • googleKey is you should get it from target website(it will change for each application, you don’t have to change it for this dummy project. But you should find it from the website code. More information:https://2captcha.com/2captcha-api#solving_recaptchav2_new
  • pageUrl is the website that has ReCaptcha on this test page. You should solve the invisible captcha on this demo just change the query string which is at the and of the pageUrl invisible=false -> invisible=true
  • Optional fields: proxyIp, proxyPort, proxyUser, proxyPw

Image Challenge Locally Stored Images

You should find the Recaptcha’s iframe elements screenshots at this folder. This code is always taking screenshots and overwriting the existing 2 files automatically. “src\test\resources\screenshots

  • imageFile.gif: That’s the 3×3 or 4×4 image challenge box.
  • imageInstructions.gif: That’s the instructions for 2captcha.com workers. Example: “Select all images with crosswalks”.

solving recaptcha

How to run?

That’s a JUnit-java-maven-selenium Webdriver project. Default Test folder is “src\test\java\tests\Recaptcha2Test.java” just right click on IntelliJ’s project explorer window or run it from the command line with maven command.

Warning!!!
I cannot guarantee that it will always work. However, I developed necessary implementations for possible scenarios. Response times from 2captcha.com should take between 30-90 seconds depending on your settings at 2captcha.com. https://2captcha.com/setting/percent_100

What is the motivation behind this project?

If it is possible to do this just showing it to the community to raise awareness.

What they can do? They can automate many processes that require reCaptcha solving such as bulk ticket purchases, a limited number of product purchases, creating accounts automatically, testing login pages that need reCaptcha, etc.

GitHub Link

https://github.com/swtestacademy/Google-Recaptcha-Solver-SeleniumAutomation

References

https://github.com/2captcha/2captcha-api-examples

https://github.com/search?l=Java&q=2captcha&type=Repositories

https://2captcha.com/

Thanks.
Ozgur Kaya