Sunday, July 24, 2011

So you wanna play hardball huh?

Developing automated tests to verify web site functionality is already a major task in any web application testing effort. But what if you also had to validate the integrity of the html document itself? Or what if you've been tasked with designing a system that monitors websites html and alerts when changes are encountered?
Consider this approach to data driven tests when the integrity of the html code is also being verified against known (or at least last known) good values. Last known because the html element or its attributes can change at any time, however, using this approach, you'll be alerted of changes by your test scripts on the first test run after the change. This method is especially useful in scenarios such as the one depicted here: test page objects have been defined and implemented and now must be maintained. Meaning that when things change on the page the object will have to be updated. See diagram at the end of the post.
Approach:
  1. Assign each web page a unique id
  2. Since a page can have multiple objects, page objects also have unique id
  3. During test setup, load all the test data into variables from your scripts
  4. When the page objects are instantiated it loads the locators it needs for the test execution from the database
Benefits:
  1. Ease of maintenance
    • If your locators change, your page objects dont have to change
    • When locators change update the db with new locators
  2. Programming skills not needed to maintain the locator store
    • A person can be trained to use browser developer tools to determine new xpath
    • New xpath can then be easily entered into db by non technical person using db web forms access
  3. Notification whenever html changes are made to documents
  4. But the number one benefit, IMHO, by far is the resuction in test software maintenance costs
I will be the first to admit that that there is no cookie cutter solution to atomating web application tests (although Selenium comes close!), This is just one example I'm throwing out there to, not only add to your arsenal of solutions, but to get discussions going across the globe on this topic as well. It is my opinion that one of the main objectives of any automated software testing initiative be easy to maintain. This solution helps in that regard.

diagram 1

We welcome comments, feedback and questions!

No comments:

Post a Comment

Creative Commons License
VGP-Miami Web and Mobile Automation Blog by Alfred Vega is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.