How to fill CAPTCHA using Test automation?

  • How can I automate "Enter CAPTCHA" using Selenium WebDriver?

    If you could automate CAPTCHA, it would mean that it's a very poor implementation of CAPTCHA.

    I feel like you've missed the point of CAPTCHA.

    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?

    In my opinion, you need a very powerful image processing algorithm and SikuliX. Selenium doesn't suit this.

    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.)

    On a similar note: If you _can_ automate CAPTCHA input (e.g. by simple OCR means), this is a serious quality issue and might be worth testing in future releases.

    You can bypass No CAPTCHA reCAPTCHA - details are on the Google Dev FAQ:

    You can read captcha in selenium automation testing. please refer this link.

  • 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 to be a CAPTCHA.

    How to 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. The average response is 15 seconds with a result rate of 90% or so they say. Sounds like something to try.

    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.

    There are some captchas that has been automated ;-) See my answer.

  • 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, but only in the testing environment.

    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 to make sure workarounds for CAPTCHA testing are removed before it goes on production.

    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.

  • Here's an example of captcha and a robot to cheat it:


  • 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!

    +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.

  • For simple CAPTCHAs like the one below you can first extract the image with Selenium and then send it to the free OCR API for processing. This will return the text inside the (Captcha) image.

    OCR will return "Input this code: Z X 7 Z"

    Another option for solving simple Captchas, and for running image/video-related tests in general, is to use the Kantu Browser (like Sikuli, but for the web browser). It has built-in OCR features.

  • 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.

  • 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.

  • 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.

  • The best way to work with Captcha in Selenium would be to give a wait time for an element that is loaded after entering the captcha, enter the captcha manually and then proceed further. The part of captcha entering cannot be automated unless something very complex is used.

License under CC-BY-SA with attribution

Content dated before 6/26/2020 9:53 AM