How to insert a reCaptcha v2 solution


  • Admin

    INSERTION
    If you want to submit a form that requires a reCaptcha v2 verification, you will need to:

    • solve the captcha through a RECAPTCHA block (you need to buy credit for one of the supported captcha solvers first). Let's assume you saved the challenge solution in the SOLUTION variable.

    • open the browser and navigate to the page

    • add an EXECUTEJS block and write

    document.getElementById('g-recaptcha-response').innerHTML = '<SOLUTION>';
    

    Example:

    RECAPTCHA "https://www.google.com/recaptcha/api2/demo"
              "6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-" -> VAR "SOLUTION"
    BROWSERACTION Open
    NAVIGATE "https://www.google.com/recaptcha/api2/demo"
    EXECUTEJS "document.getElementById('g-recaptcha-response').innerHTML = '<SOLUTION>';"
    ## Now you can fill and submit your form
    

    VALIDATION
    Sometimes the reCaptcha must trigger a validation function after you inserted it inside the textarea.
    You can easily see if that is the case by looking at the div using inspect element. For example on the reCaptcha demo site you can see this:

    <div id="recaptcha-demo"
      class="g-recaptcha"
      data-sitekey="6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-"
      data-callback="onSuccess">
    </div>
    

    The onSuccess function is the callback function when the challenge is solved.
    In this case you just need to add onSuccess(); to your script and it will look like this:

    document.getElementById('g-recaptcha-response').innerHTML = '<SOLUTION>';
    onSuccess();
    

Log in to reply