Editorials

The Page Adapter Pattern for Testing Web Apps

Goals for the New Year
2012 is here. So, what’s going to make it any better than 2011? Or, was your 2011 so great that you don’t think it can get any better? I’m curious what you are doing to change your world this year. I’d like to collect ideas from our readers to see if I can find any patterns. Perhaps others would be interested in what your strategy for 2012 will be. Drop a note to btaylor@sswug.org and share your thoughts on how you’re going to make 2012 different.

The Page Adapter Pattern for Testing Web Apps
Today I had the opportunity to simply do some reading on testing techniques for system testing Web apps. As you may imagine, one of the most difficult things about testing a web application is how to identify objects in the DOM such that you can exercise a web page and evaluate the results.

Most often, properties of a web page are defined by different tags, and each tag has an ID. However, there is not that requires the ID for a control to remain the same. Many web development tools assign IDs, allowing the ID for a control to be changed over time. A control tag may be defined at run time so that it is always different. In these scenarios, it becomes more difficult for an automated testing engine to find, review, or manipulate such controls.

Another area of confusion when manipulating the DOM of a web page is when you have repeating controls. Tables often have multiple rows where the ID of a column in each row has the same identifier. In this case, you must not only locate the control by ID, but also its instance, resulting in even greater complexity.

One technique I found on the WatiN test site while trying to find the missing documentation was the technique of wrapping a web page with a Dot Net Class. Using an adapter pattern to wrap the DOM of the web page makes test maintenance much simpler. Now, if the ID for a control is modified, there is only one place where the fix must be applied; the Dot Net Adapter Class which encapsulates the web page. All tests are performed through exercising methods or evaluating properties of the adapter class, instead of manipulating the web page directly.

While this pattern is not suitable for a business analyst when recording tests, it makes a lot of sense for programmers when writing multiple tests for a web page.

Tell us about your experience testing web applications…drop me a note at btaylor@sswug.org.

Cheers,

Ben

$$SWYNK$$

Featured White Paper(s)
Office 365 SharePoint Online – what does it mean to my organization as a CIO?
Written by AvePoint

The goal of this white paper is to clarify the disjoint… (read more)

Featured Script
fn_listgetat() – get text from a delimited list
This function is similar to ColdFusion’s ListGetAt() function; it takes an ordinal position and a comma-delimited list as arg… (read more)