Jasper van den Bosch
Jasper van den Bosch

Reputation: 3218

How to acceptance test captcha-protected web application functionality?

I would like to add a captcha, such as reCaptcha, to a certain functionality on my site. How could I adapt my acceptance tests?

Is the only solution to disable the captcha's on the staging site?

Clarification:

Of course I am not speaking of brute-force cracking my own captcha, but e.g. some option to inject a state into the captcha from the server side that my test knows about.

PS My server side code uses the Pyramid framework, and my tests are written using Selenium

Upvotes: 5

Views: 4127

Answers (3)

user3886650
user3886650

Reputation: 159

Disable the CAPTCHA by using a test code in the input box. If the captcha fails but matches the test code, continue.

Upvotes: 1

Jim Holmes
Jim Holmes

Reputation: 1690

The point isn't to test Captcha with your Selenium tests -- Why spend the significant effort to test a third party tool?

Instead, I'd have a Selenium test that verifies your Captcha is showing up. This validates your Captcha is present and active. After that test I'd turn Captcha off and proceed with your other validation tests. I'd also have a final step of turning Captcha back on and repeating the test detecting Captcha is active. That way you're ensuring you didn't miss something when reactivating Captcha.

Upvotes: 4

Arran
Arran

Reputation: 25076

Yes, the only option is disabling Captcha - for a very good reason. If it's easy enough to bypass it with Selenium, why would you have a Captcha in the first place?

Upvotes: 5

Related Questions