How to handle CAPTCHA using Selenium Web Driver


“Completely Automated Public Turing test to tell Computers and Humans Apart,” (CAPTCHA) is a type of challenge-response test used in computing to determine whether or not the user is human. The main purpose of the CAPTCHA is to prevent bots or automated programs from using various types of computing services or collecting certain types of sensitive information. In other words, it is a security feature of the application which generally prevents bots from filling.

Automation engineers across the world have been trying to find ways to achieve complete automation of web pages but CAPTCHA has been the hindrance, preventing them from achieving the goal. Many engineers have come up with different ways to automate it but all these have been unsuccessful so far and that is mainly due to the change in CAPTCHA’s form from visual to audio and drag n drop etc.

Intended to defeat automated programs like Selenium, getting around CAPTCHAs is difficult by design. Typically, one has to configure the website in certain ways in order to disable the CAPTCHA for testing purpose. Thought this will help automate the test in a smoother way but then the security of the application would be compromised.

CAPTCHA can be automated if you are able to decode the image using OCR (Optical Character Recognition). For that, one will need to write complex algorithm to sort out the image pattern and has to be an expert in image pattern mapping as well. But images with the passage of time have become progressively more unreadable, therefore reducing the very chances of CAPTCHA automation.

There is just one way to bypass CAPTCHA but it will not automate it. User will have to enter the CAPTCHA text himself while other fields will be filled automatically. Using this, automation engineers can achieve the target of complete web automation to some extent. The only way is using the WAIT command. Use wait and enter CAPTCHA manually while script is in wait.

WebDriverWait wait = new WebDriverWait );
{ return d.FindElement ; // here we can use any locator that identifies a successful / unsuccessful login });

The above mentioned ways are the only verified ways to handle CAPTCHA using Selenium Web Driver. Therefore, it is now very much clear that not everything can (or should) be automated, and CAPTCHA is one example where manual testing would still be needed. Hence, very simply, if there are any other ways around to handle CAPTCHA in Selenium, then the CAPTCHA is broken and pretty much useless!

Read more:  Top Software Testing Companies to Work within 2019


Subscribe to our newsletter and Get Our Latest Posts Instantly!

Leave a Reply

Your email address will not be published. Required fields are marked *

Talk to Us

Subscribe to Us

Subscribe to our newsletter and Get Our Latest Posts Instantly!