Ensure the Proper Functioning of Form Fills With Automated CAPTCHA Testing
Sep 23, 2015
Forms are a necessity on websites. However, forms are vulnerable to spam posting by automated bots. CAPTCHA is a highly popular mechanism used in websites to distinguish human input from that of a computer, in order to prevent bots from spamming the web forms.
Ironically, for this same reason, pages with CAPTCHA cannot be tested with common automated tools. Since CAPTCHA is an image element, the automation tools cannot extract text embedded in CAPTCHA images.
This creates a problem: How do you efficiently perform quality assurance (QA) testing on large numbers of website forms equipped with CAPTCHA?
While most organizations opt for manual testing of form fills using CAPTCHA, some companies need comprehensive automated testing of web pages with CAPTCHA-protected forms, especially when there is a large number of forms to be tested, or when there are frequent builds on the website and form testing is part of regression testing.
Testing CAPTCHA forms using Selenium WebDriver
In this method, the tool implements the same strategy that is used by the Application Under Test(AUT) to decode the CAPTCHA. One such method is to capture the encrypted text from the browser that includes the CAPTCHA value in it and decrypt this encrypted text with the same programming method used by AUT. The CAPTCHA value is then retrieved from the decrypted value and provided as input into the CAPTCHA text box.
In one such example, the Document Object Model (DOM) component of CAPTCHA image in the HTML page is as follows:
“<img width=”90″ height=”50″ border=”0″ src=”/CAPTCHAImage.ashx?spec=U5hh2S%2b3XwOZzsxCon%2bv7Ts7tVuEeBFqZ%2bsmxSwT6ua3hHfateH3MlZE3nD%2fSX1y”/>”
In this case, the “src”(source) attribute is captured and parsed to get the encrypted data “U5hh2S%2b3XwOZzsxCon%2bv7Ts7tVuEeBFqZ%2bsmxSwT6ua3hHfateH3MlZE3nD%2fSX1y”within the “spec” parameter.
This encrypted data is then framed to a URL which is further sent as http request through Selenium’s WebDriver html unit driver to the CAPTCHA decrypted method that is hosted on a local host. This method decrypts and responds with the plain text CAPTCHA value. This text is then captured by the Selenium Unit Driver and places it in the corresponding CAPTCHA box.
Code snipped for the same is something like below:
String frameurl = http://localhost/DecodeCaptcha/CaptchaDecoder.aspx?spec= spec=U5hh2S%2b3XwOZzsxCon%2bv7Ts7tVuEeBFqZ%2bsmxSwT6ua3hHfateH3MlZE3nD%2fSX1y;
HtmlUnitDriver unitdriver = new HtmlUnitDriver (BrowserVersion.CHROME);
String capvalue = unitdriver.findElement (By.xpath (“html/body”)).getText ();
driver.findElement (By.id (or.getProperty (“Forms_CaptchaTxt”))).sendKeys (capvalue);
Web marketers concerned about user experience and onsite conversions should be very concerned about the risks of malfunctioning CAPTCHA-protected forms. The automated testing of those forms using the method described above prevents such a problem.
Explore Additional Resources
Learn more on how to select the Right CMS for your business and excel the Digital Experience.
Our Quality Assurance team helps our clients build a managed QA department.
GET HELP FROM OUR EXPERTS
We have one of the largest and deepest multi-solutions digital consulting teams in the world. Our proprietary processes and years of Digital Experience expertise have earned us a 97% customer satisfaction rating with our clients ranging from Global Fortune 1000 to Mid-Market Enterprises, leading educational institutions, and Non-Profits.
Contact us today to learn more about our Quality Assurance services and other automation solutions we have implemented.
About TA Digital
TA Digital is an innovative digital transformation agency, specializing in delivering the digital experience, commerce, and marketing solutions. For nearly two decades, we have been helping traditional businesses transform and create dynamic digital cultures through disruptive strategies and agile deployment of innovative solutions.