Test automation of GWT applications using Selenium WebDriver

With the advent of Software as a service (SaaS), responsive web applications running on Web 2.0 became more and more common. GWT by Google is a collection of tools that helps making applications running on web, more intuitive and responsive. The unique capability of GWT is that it compiles java code to highly optimized JavaScript. All modern browsers, irrespective of platform/device, can interpret JavaScript. This makes GWT based applications run on a broad range of devices, from smartphones to laptops to tablets. GWT makes it easy to develop a UI based on widgets.

Testing intuitive and highly responsive systems is a big challenge. Tools like Quick Test Professional were not fully equipped to handle AJAX/GWT based applications. Selenium WebDriver, an open source automation framework, quickly became the choice of automation engineers. Cost effective (no licensing fee), ready for AJAX/GWT based web applications and a rich framework to handle scenarios introduced by modern web UI are some of the key benefits.

Key considerations

Modern GWT/Ajax based applications have a UI that gets updated dynamically by making asynchronous requests to the server. These requests result in the view (widget/page content) to be updated. Changes to the view are done through DOM manipulation. Using DOM manipulation, new rows can be added to a table dynamically (like new mail in Gmail Inbox or building a table to display search results).

Keeping the dynamic nature of web applications in mind, here are some key points to consider when automating GWT/Ajax applications using WebDriver.

Page Object Model

In order to make automation scripts easy to maintain and easy to read, page object model can be used. WebDriver has an inbuilt support for this model.

In a page object model, a java class is written to model a particular page/UI. This class contains dedicated methods to identify and manipulate each UI control on a page. This allows a framework designer to hide implementation details, and at the same time makes the code reusable and readable.

Example: Normally, WebDriver script for entering login name would look like:
txtLogin = driver.findElement(By.Name(“editLogin

The following two tabs change content below.

Suyog Gupta

I love reading, especially reading between the lines. I love to observe, especially, that is yet to occur. I love when I find exceptions, if I don't find one, I cause one. That's me - Suyog -- Tests Gooood --

Latest posts by Suyog Gupta (see all)

Suyog Gupta

I love reading, especially reading between the lines. I love to observe, especially, that is yet to occur. I love when I find exceptions, if I don't find one, I cause one. That's me - Suyog -- Tests Gooood --

All stories by: Suyog Gupta