Page Object

A Page Object is a plain class that represents a page or window on a web or desktop application. This concept comes from the PageObject design pattern for enhancing test maintenance and reducing code duplication.

Representation of a PageObject as a Window

Creating a Page Object

When creating a Page Object you will need the following:

  • Page Object classes must inherit from PageObject class which is under the Mobilize.QualityMate.Automation.Entities namespace.

  • The control property type has to be an interface from the Mobilize.QualityMate.ControlInterfaces namespace(link).

  • The control properties must be declared public and with both get and set accessors.

Simple PageObject

The following is an example of a PageObject declaration

using Mobilize.QualityMate.Automation.Entities;
using Mobilize.QualityMate.ControlInterfaces;

public class MyPageObject : PageObject
{
    public IButton myButton { get; set; }

    // Add other PageObject controls here
}

Inner PageObject

Sometimes, a PageObject has a lot of members to maintain, so you can create an Inner PageObject to group members into a smaller representation. Here is a sample of an Inner PageObject.

Representation of Inner PageObjects on a Window
using Mobilize.QualityMate.Automation.Entities;
using Mobilize.QualityMate.ControlInterfaces;

public class MyPageObject : PageObject // The Window
{
    public MyInnerPageObject myInnerPageObject { get; set; }

    // Add other PageObject controls here
}

public class MyInnerPageObject : PageObject // The Window's group controls
{
    public ITextBox myTextBox { get; set; }
    // Add other PageObject controls here
}

Usage in Code

Once your Page Object is created you will need the UiExecutionController to initialize the PageObject and members with the method GetPageObject(). You can achieve this using the following code:

public void MyMethod(UiExecutionController controller)
{
    MyPageObject mainPage = controller.GetPageObject<MyPageObject>();

    // Add interactions to PageObject or controls
}

Check the Best Practices article to know our recommendations on Page Objects.

Last updated

Was this helpful?