How to work with a selenium script where the if found captcha is in the mid of the script. Is it possible to pass the captcha and continue the automation script?


2 Answers 2


The Selenium website is full of documentation. They have a section called Test Practices which contains encouraged and discouraged practices. One of the discouraging practices talk about CAPTCHAS

Discouraged practices are things to avoid when using test automation. It's a myth that everything can be automated or should be automated. In fact, not everything can be or should be automated. There are a number of factors that should be considered when writing test automation.

When it comes to CAPTCHAS, Selenium documentation says:

CAPTCHA, short for Completely Automated Public Turing test to tell Computers and Humans Apart, is explicitly designed to prevent automation, so do not try! There are two primary strategies to get around CAPTCHA checks:

  • Disable CAPTCHAs in your test environment
  • Add a hook to allow tests to bypass the CAPTCHA

So, what does this mean? It means you can't use a computer to bypass a CAPTCHA.

In your test environment, it's a good practice to disable CAPTCHAs. If your application uses them, you really only need to test the integration of the CAPTCHA library, not the implementation of the CAPTCHA library. Once the integration is tested, you can safely disable it in your test and stage environments. CAPTCHAs are only effective in a production environment. This can be done via a feature flag.

  • 1
    This is the correct answer IMO. Nov 3, 2022 at 22:43
  • Thanks, @ChrisKenst. I appreciate the support!
    – Lee Jensen
    Nov 4, 2022 at 17:49

My view points to handle captcha :

  • This is one of the limitation of automation to automate or handle captcha
  • There is not straight way to handle captcha or discard, by pass like popups, alerts
  • As it is mandatory step, even if you just avoid captcha somehow with hackish way, still you can not progress to test actual flow and scenario

On top of this for testing purpose there are few possible work around [Not recommended] as follows :

  • By disabling Captchas in test environments
  • By clicking the reCAPTCHA checkbox in Selenium
  • By adding a delay in your selenium script and manually solving Captcha while running

Note - If you are interested for more details for those work around. Please refer this.

  • Can you explain more about why the listed "workarounds" are not recommended?
    – Lee Jensen
    Nov 3, 2022 at 15:48
  • yes because when we are trying to implement end to end UI automation those are from end user prospective. If we add any work around then its not the exact end user scenario Nov 3, 2022 at 19:16

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