Page Object pattern



BlueDuck SDA has native support for Page Object Pattern.

The Page Object pattern represents the screens on your System Under Test (SUT) as a series of objects.

The idea of a page object model is that each screen in the SUT has a page class. These page classes expose elements through properties and actions through methods. The result makes it much easier to create new tests and to maintain your test code when changes happen to your SUT.

BlueDuck SDA uses AutoItObject. AutoItObject is an combination of a DLL and UDFs adds extended Object-support to AutoIt. Now it is possible to use an OOP-like syntax in your scripts and access many COM-Interfaces exposed from the Windows-API.

Why use the Page Object pattern?

Page Object pattern


  • Promotes Reuse
  • Make test readable
  • Make test more roboust
  • One place to make changes around the UI
  • Allows you to "model the UI" in your test
  • Exposes methods that reflect the things a user can see and do on the SUT
  • Page Object design helps us create a DSL for our tests that if something were to change on the page we don't need to change the test, we just need to update the object that represents the page.

A small example

Page Object pattern


In this example we will transform the Simple Test example, into a test using such a page class.

Alta Vista Page

First a new class needs to be created inheriting the $oPage class, lets call it AltaVistaPage

AltaVistaPage has "Search" method, this method exposed the SearchCriteria textfield and the Search button, all logic to find these controls is held in one place and can be easily reused in other tests.

Test Case

The code presented above shows an important point: the tests, not the PageObjects, should be responsible for making assertions about the state of a page.


  • Generally don't make assertions in Page class
  • The public methods represent the services that the page offers
  • Methods return other Page Objects
  • Different results for the same action are modelled as different methods