Monday, March 25, 2013

Testing the UI of a web application


Testing is a quite tedious and repetitive work, some may say. This can be true for several applications. But the time put in testing can easily be monetized by the satisfaction of the customer who receives a software that does not contain any KNOWN bug during the tested use-cases.

But what if the software is so huge, that several tester is required to focus only on that specific project full time for several weeks before even a minor release could occur. Then an automatic testing suite must be seriously considered.

At our company, the scenario was as described above. Several testers worked several days before each minor release, and their task was quite repetitive. That is why we decided to move the testing to a concordion test suite with selenium engine.

The main benefit was that the test cases and fixtures can be written by the testers (the concordion does not require advanced programming skills for usage, only if you want to 'play' a bit with the output generation), and the developers created the test blocks similar to the selenium PageObject design pattern. So the complexity of the code for the testers was similar to the following:

LoginPage loginPage = new LoginPage("www.mysite.com/login");
loginPage.fillName("test");
loginPage.fillPassword("test");
loginPage.loginAction();
So the testers did not have to bother with various XPath expressions for finding a specific action button for a user in a html table, this was the task for the developer to do (and it forced the developer to create the user interface so that it can be easily put to automated testing via the selenium webdriver).

In a concordion fixture, several pages can be chained together, so the previous example can be extended as:

UserAccount userAccount = new UserAccount("www.mysite.com/myaccount");
useraccount.deposit(10000);
String userCredit = userAccount.getCurrentAmount();

LogoutPage logoutPage = new Logout("www.mysite.com/logout");
logoutPage.logout();

The concordion fixture then validates whether the userCredit meets the requirements established by the test scenarios:

<p concordion:execute="#result = myTest()">
  <span>Check account increased by 10000:</span>
  <span concordion:assertEquals="#result">10000</span>
</p>

Concordion with selenium is an incredibly powerful tool for testing not only just the business logic of the application, but due to the screenshot taking ability of the selenium package, the failed concordion tests can include the screenshot of the webpage on which the error occurred. What is more, it is possible to validate the layout (alignment, color, textual representation, etc.) of the pages against the standard. with the help of an image processing library.