78

I'm implementing an invisible reCAPTCHA as per the instructions in the documentation: reCAPTCHA V2 documentation

I've managed to implement it without any problems. But, what I'd like to know is whether I can simulate being a robot for testing purposes?

Is there a way to force the reCAPTCHA to respond as if it thought I was a robot?

Thanks in advance for any assistance.

4
  • 5
    Build a robot XD
    – Stefan
    Apr 13, 2017 at 16:48
  • Haha. Strictly speaking, I wouldn't be simulating a robot then. ;)
    – strttn
    Apr 13, 2017 at 17:05
  • For anyone who wants to see what happens on failure to automatically determine that the user is human (which is what I wanted to achieve per the question), I've noticed that it quite often cannot automatically pass when using a touch device.
    – strttn
    Apr 19, 2017 at 10:17
  • Hi, post your answer and score points :-)
    – Stefan
    Apr 19, 2017 at 10:28

10 Answers 10

58

Update: This might not work in new versions of Chrome (see comments).

In the Dev Tools, open Settings, then Devices, add a custom device with any name and user agent equal to Googlebot/2.1.

Finally, in Device Mode, at the left of the top bar, choose the device (the default is Responsive).

You can test the captcha in https://www.google.com/recaptcha/api2/demo?invisible=true

(This is a demo of the Invisible Recaptcha. You can remove the url invisible parameter to test with the captcha button)

6
  • 1
    Having trouble impersonating a bot. I'm getting a score of 0.9 (very human-like) under the new reCAPTCHA v3 API with my site, same as a vanilla Chrome browser. Using the demo page on this custom device, it goes into overtime asking me to classify images, as if it's skeptical I'm human.
    – Bob Stein
    Jul 9, 2018 at 19:50
  • 4
    @BobStein I tried with v3 too and it didn't work. Unfortunately, I don't know how to use v3 in a way it thinks I'm a bot, or what it does exactly to consider someone as human or not. This topic is about v2 though. Jul 9, 2018 at 21:20
  • 2
    Not working for me, I get a success and green tick with button, even though I switched to custom device Googlebot/2.1 in my browser. Oct 23, 2020 at 8:11
  • 1
    @LaurenceCope Yeah, I tried and could not simulate. Maybe it's because I'm logged in Google Chrome. It seems something changed because it worked before. As a workaround, when I opened a new incognito window and tried the recaptcha it showed the box thinking that I'm a robot (I didn't even need to specify the user agent as Googlebot/2.1, just using the incognito window was enough). Oct 23, 2020 at 11:36
  • 1
    Same here. This does not work if you are signed into Google Chrome
    – foba
    Mar 22, 2021 at 23:54
29

You can use a Chrome Plugin like Modify Headers and Add a user-agent like Googlebot/2.1 (+http://www.google.com/bot.html).

6
  • Thanks Raphael. I haven't actually managed to try this out but it sounds like it should work so I'll mark it as the answer. :)
    – strttn
    Jun 13, 2017 at 9:18
  • 33
    To do this without extensions, use Chrome Device Mode, go to Dev Tools Settings > Devices and add a new device with user-agent Googlebot/2.1, then enable device mode and select the new device. It worked here.
    – Luizgrs
    Nov 6, 2017 at 17:01
  • 1
    @Luizgrs, post this as an Answer Jan 26, 2018 at 23:25
  • 6
    As of October 2018, this isn't triggering CAPTCHAs on Chrome or Firefox. Oct 11, 2018 at 4:55
  • 12
    In December 2018 this is no longer the answer, especially on reCAPTCHA v3. I have set my UA as Googlebot and I am getting a score of 0.9.
    – crmpicco
    Dec 3, 2018 at 8:16
6

For Firefox, if you don't want to install any add-ons, you can easily manually change the user agent :

  1. Enter about:config into the URL box and hit return;
  2. Search for “useragent” (one word), just to check what is already there;
  3. Create a new string (right-click somewhere in the window) titled (i.e. new
    preference) “general.useragent.override”, and with string value
    "Googlebot/2.1" (or any other you want to test with).

I tried this with Recaptcha v3, and it indeed returns a score of 0.1

And don't forget to remove this line from about:config when done testing !

I found this method here (it is an Apple OS article, but the Firefox method also works for Windows) : http://osxdaily.com/2013/01/16/change-user-agent-chrome-safari-firefox/

3
  • The problem with this is it seems that Google learns about your IP and ends up whitelisting it, certainly that is what has happened to me. To begin with I was getting a score of 0.1 with the Googlebot UA, but now i'm getting 0.9 and I think it's because I have had successful reCAPTCHA attempts with a legit UA from that IP. It's a pretty tricky thing to test, actually.
    – crmpicco
    Dec 3, 2018 at 8:26
  • @crmpicco Thanks for the feedback.Yeah, I did not try it that often, I just wanted to test my single implementation on one of the websites I manage. But I feel that you need a "leap of faith" to trust this. I put the email address of our entire team behind the new Recaptcha v3, and I cannot really say with 100% certainty that it really works. We would need a bad-bot-developer-turned-good-samaritan to offer a service where you can input your website and have it tested. I assume this exists as a paying service, but a open-source / community self-service would be nice ;)
    – Peter K.
    Dec 3, 2018 at 10:48
  • Nothing I tried would get rejected in Chrome, so I tried this Firefox solution and it worked for me. The form submission was rejected as spam, but I was not shown any images to prove my humanity. I removed the useragent preference and my form submitted successfully.
    – JeffreyPia
    Apr 6, 2021 at 14:24
3

yes it is possible to force fail a recaptcha v2 for testing purposes.

there are two ways to do that

First way :

you need to have firefox browser for that just make a simple form request and then wait for response and after getting response click on refresh button firefox will prompt a box saying that " To display this page, Firefox must send information that will repeat any action (such as a search or order confirmation) that was performed earlier. " then click on "resend"

by doing this browser will send previous " g-recaptcha-response " key and this will fail your recaptcha.

Second way

you can make any simple post request by any application like in linux you can use curl to make post request.

just make sure that you specify all your form filed and also header for request and most important thing POST one field name as " g-recaptcha-response " and give any random value to this field

1
  • Second method worked well for me testing Recaptcha V2 checkbox server side failure (without changing backend code). Thanks Jun 8, 2023 at 4:50
3

I find that if you click on the reCaptcha logo rather than the text box, it tends to fail.

This is because bots detect clickable hitboxes, and since the checkbox is an image, as well as the "I'm not a robot" text, and bots can't process images as text properly, but they CAN process clickable hitboxes, which the reCaptcha tells them to click, it just doesn't tell them where.

Click as far away from the checkbox as possible while keeping your mouse cursor in the reCaptcha. You will then most likely fail it. ( it will just bring up the thing where you have to identify the pictures).

The pictures are on there because like I said, bots can't process images and recognize things like cars.

2

Just completing the answer of Rafael, follow how to use the plugin

Modify headers Google Bot 2.1

2

None of proposed answers worked for me. I just wrote a simple Node.js script which opens a browser window with a page. ReCaptcha detects automated browser and shows the challenge. The script is below:

const puppeteer = require('puppeteer');

let testReCaptcha = async () => {
    const browser = await puppeteer.launch({ headless: false });
    const page = await browser.newPage();

    await page.goto('http://yourpage.com');
};

testReCaptcha();

Don't forget to install puppeteer by running npm i puppeteer and change yourpage.com to your page address

1

As of 2023, the new correct answer to this is a little simpler than one might think. User agent and device simulation no longer trigger Recaptcha, but in order to trigger the verification all one has to do is act like a bot.

Here is the invisible Recaptcha demo page: https://www.google.com/recaptcha/api2/demo?invisible=true

Submit that form ~10 times, and it'll start showing you verifications. The form is prefilled so it's just a matter of Submit, Back, Submit, Back. Then, you can go back to the site you're testing, and Google will recognize you as the same person who requires verification.

1
  • This process did not work for me when I tried going from v2 invisible to v2 checkbox.
    – neuquen
    Feb 15 at 19:21
0

If you only want to simulate what you would get in the backend, then an option is to temporarily disable JavaScript in your browser.

This causes the reCAPTCHA to not be shown on your web page. Then when you perform some action on the page, causing a POST, the backend code will not receive the g-recaptcha-response form field and the Captcha validation will fail.

0

All I had to do was use an incognito window in order to trigger a recaptcha.

I tried using the emulator and that never worked for me.

Not the answer you're looking for? Browse other questions tagged or ask your own question.