Prerequisite

git clone https://gitlab.com/nirranjan.raut/fast-captcha-client-library.git

cd fast-captcha-client-library

mvn clean install

How to bypass recaptcha using java selenium automation.

1. Register on fast captcha with your email id, mobile number and password of your choice.

2. Activate your account by entering OTP received on email and mobile number.

3. Generate API Secret Key.

4. Import fast-captcha-client-library in your source code.

  <dependency>
      <groupId>com.fast.captcha</groupId>
      <artifactId>fast-captcha-client-library</artifactId>
      <version>1.0.0</version>
  </dependency>

4. Call Fast Captcha service to solve recaptcha.

    com.fast.captcha.model.FastCaptchaResponse response = com.fast.captcha.CaptchaSolver.solve("fast_captcha_api_key", "g_recaptcha_site_key", "website_url");
    if(!"SUCCESS".equals(response.getStatus())) {
        LOGGER.error("Response is not successful {}", response);
        throw new RuntimeException("Captcha solution not found.");
    }

5. Inject obtained recaptcha token or image captcha solution into automated web page.

    String solution = response.getSolution();
    //enter it in text area
    WebElement captchaSolutionElement = chromeDriver.findElement(By.id("g-recaptcha-response"));
    String javaScript = "arguments[0].style.height = 'auto'; arguments[0].style.display = 'block';";
    ((JavascriptExecutor) chromeDriver).executeScript(javaScript, captchaSolutionElement);
    captchaSolutionElement.sendKeys(solution);

6. Submit the page and done.