Ensure the Proper Functioning of Form Fills With Automated CAPTCHA Testing
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 the only global boutique agency that delivers the “best of both worlds” to clients seeking to achieve organizational success through digital transformation. Unlike smaller, regional agencies that lack the ability to scale or large organizations that succumb to a quantity-over-quality approach, we offer resource diversity while also providing meticulous attention to the details that enable strategic success.
Over the past 20 years, TA Digital has positioned clients to achieve digital maturity by focusing on data, customer-centricity and exponential return on investment; by melding exceptional user experience and data-driven methodologies with artificial intelligence and machine learning, we enable digital transformations that intelligently build upon the strategies we set into motion. We are known as a global leader that assists marketing and technology executives in understanding the digital ecosystem while identifying cultural and operational gaps within their business – ultimately ushering organizations toward a more mature model and profitable digital landscape.
Recognized in 2013, 2014, 2015, and 2019 Inc. 5000 list as one of the most successful technology companies in the United States, TA Digital is pleased also to share high-level strategic partnerships with world class digital experience platform companies like Adobe, SAP and Salesforce and possess global partnerships with industry leaders such as Sitecore, Episerver, Elastic Path, BigCommerce, AWS, Azure and Coveo.