Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I automate, 'Enter CAPTCHA' using Selenium Web Driver ?

share|improve this question
If you could automate CAPTCHA, it would mean that it's a very poor implementation of CAPTCHA. – vsz Feb 15 at 15:01
I feel like you've missed the point of CAPTCHA. – ryan Feb 15 at 17:38
What do you need to use it for? Do you have a site with a CAPTCHA component that you still want to be able to test with Selenium, possibly by selectively disabling the CAPTCHA when testing? – Milo Price Feb 15 at 19:31
In my opinion, you need a very powerful image processing algorithm and SikuliX. Selenium doesn't suit this. – Buaban Feb 16 at 4:52
Are they using Sony's CAPTCHA? Your problem is trivial if so. (The worst part is that it's still there and contains the same problem 5 years later.) – jpmc26 Feb 16 at 23:13

10 Answers 10

up vote 25 down vote accepted

You don't, that is the whole idea behind a good CAPTCHA.

CAPTCHA stands for:

Completely Automated Public Turing test to tell Computers and Humans Apart

So, by definition, resolving a CAPTCHA cannot be automated: Otherwise it could not tell computers and humans apart and hence fails being a CAPTCHA.

Howto handle a CAPTCHA in a test environment:

  1. If you need to test an application which uses CAPTCHA, then you need to get the development team to build in a workaround/backdoor which is only active in the test environment.
  2. Use a service like which has an API to return the text of the CAPTCHA for you. Average response is 15 seconds with a result rate of 90% or so they say. Sounds like something to try.
share|improve this answer
Unlike other answers there you show a good point: "a good captcha": many captcha implementations are easy to break (old page, but has many examples). Of course breaking the captcha isn't an recommended at all, but if someone got here because wants to use some captcha to prevent automation and want to know how someone can automate it then is important to know when a captcha is good or not. – Gustavo Rodrigues Feb 15 at 11:35

We cannot automate CAPTCHA, as it is not meant to be automatized.

How to deal with CAPTCHA?

  1. Either ask dev team for a workaround, like configure CAPTCHA in test environment in such a way it will always accept 1 specific value.

  2. Ask developer to disable the CAPTCHA module in testing environment.

  3. If your are using custom CAPTCHA module, you can ask developer to generate an API of CAPTCHA generation for testing environment.

  4. You can ask dev team to add CAPTCHA code as title in markup, then you can access this title and bypass the CAPTCHA.

Most of the time we go with option 1 or 2.

NOTE: When you do work around for CAPTCHA in test environment, You should always have this point in your checklist whether work around of CAPTCHA is removed before it goes on production.

share|improve this answer
I'd like to emphasize something about all three of your points: for a testing environment. None of these should ever be put into your production environment, ever, because otherwise you break the whole point of CAPTCHA. Even if it was a class assignment, still don't, because your prof will fail you. – QPaysTaxes Feb 16 at 20:09

If you Google about scenarios, that Selenium cannot automate, then you will surely get an answer.

CAPTCHA scenarios cannot be automated using Selenium.

share|improve this answer
Apart from Selenium, does any other method exists? – Tom J Muthirenthi Feb 15 at 7:51
CAPTCHA cannot be automated. – log_file Feb 15 at 8:34
@TomJMuthirenthi The entire point of a CAPTCHA is that it cannot be automated (by any known method). – immibis Feb 16 at 8:34

As other posters explained, whole point of CAPTCHA is that recognition cannot be automated with our current pattern recognition programs. Even as AI algorithms solving pattern recognition will improve, new CAPTCHA will be developed.

So what you need is automated humans - a web service which outsources solving CAPTCHA, for like $1 per 1000 CAPTCHA solved. You post image to the service API, real humans in some country with cheap labor solve them within seconds, and send you answer back.

Long live human ingenuity!

share|improve this answer
+1 I wanted to give a similar answer, but services like seem to frown upon breaking CAPTCHA's with the use of humans, but still for testing purposes it should be fine. – Niels van Reijmersdal Feb 15 at 19:32

If you're trying to automate a CAPTCHA like Google reCAPTCHA, well, you just can't. Simple reason being the CAPTCHA code is updated and added to very frequently.

You may be able to automate some other CAPTCHA that use a limited database. Such CAPTCHA will have a limited number of code. You can somehow make a list of all the available codes and their IDs. I'm sure they'll have some sort of unique identification. Once you have that data, while automating it you can fetch the ID of the captcha being called, search in your list and filling in the value associated with that CAPTCHA in the text field. I remember this being told to me by Santhosh Tuppad a couple of years ago.

To automate modules that make use of CAPTCHA field you can,

  1. Ask your development team to remove the CAPTCHA field on the test environment.

  2. Ask them to make a sandbox like CAPTCHA, that will accept a single input text every time.

  3. Ask them to make a working model sandbox of the CAPTCHA, where each time the CAPTCHA text will be generated dynamically, but the same text will also be inserted in the text field or there is some way for you to know the text field generated, so that you can insert that in the text field.

share|improve this answer

There are tools and services to accomplish this, 75% of the time. The question reminded me of a piece of software called JDownloader, a download manager with CAPTCHA bypass abilities. According to their thread on the topic, they support many services in addition to their own automated OCR tool.

Some services they use:

Their tool, JAntiCaptcha, in SearchCode.

Depending on your language, integrating one service or another may be more challenging, so be sure to do your research.

share|improve this answer

How can I automate, 'Enter CAPTCHA' using Selenium Web Driver ?

Presumably you don't really want to test the CAPTCHA feature, you just want your automation to go past that portion of your application, so that you can test the remainder using automation.

If that's the case, you need to get your developers to give you a "back-door" - basically a test-only version of the page that will let you bypass the CAPTCHA feature and continue on.

Talk to your developers. Explain your predicament. Ask them to propose a solution.

In the past, I've had developers give me a "replacement" page for testing. It omitted the CAPTCHA but contained everything else.

share|improve this answer

What I have done to deal wit CAPTCHA, is to test on a dummy site but the CAPTCHA was a static one. I do not agree with the people here saying to remove it because they site layout will be affected.

share|improve this answer

I am presuming that you want to create automation for validating CAPTCHA, & you are familiar with automation with Databases.

Captcha is same concept in terms of generating automatically like OTP. It has been generating in back end and some scripting mechanism used to wrap those codes in to configuration which can be identify by human , only .

So In order to automate testing of it you can divide into two parts , one is automation using just getting back end CAPTCHA Data and store in variable and validate by inputting into captcha block using webDrviver & pass that captcha challenge. while other practice you need to verifying that captcha to be solve its purpose for human readable form only , you need to do manual testing for verification.

share|improve this answer

To summarise the above: A) you shouldn't that's the point of captcha. B) implement strong AI to mimic human capabilities C) implement a test harness to bypass captcha in your test automation suite

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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