How to Disable reCAPTCHA for Automated Testing

Overview

Are you using automated testing on your site and need to disable reCAPTCHA for your forms? More and more sites these days are turning to automated testing for their site. With reCAPTCHA enabled, these automated tests will fail and so it may become necessary to disable reCAPTCHA for forms while the testing runs through. In this tutorial, we’ll show you the filters you need to disable these settings for your automated testing.

Setup

You’ll need to add this code snippet to your site. If you need help in adding snippets to your site, please see this tutorial.

/**
 * Disable the reCAPTCHA for automated testing.
 *
 * @link   https://wpforms.com/developers/how-to-disable-recaptcha-for-automated-testing/
 *
 */

    // Disable reCAPTCHA assets and initialisation on the frontend.
    add_filter( 'wpforms_frontend_recaptcha_disable', '__return_true' );

    // Disable validation and verification on the backend.
    add_filter( 'wpforms_process_bypass_captcha', '__return_true' );

And that’s it! You’ve now successfully disabled the reCAPTCHA for your automated testing! Would you like to also change the theme of reCAPTCHA? Take a look at our article on How to Change the Captcha Theme on Google Checkbox v2 reCAPTCHA.