# Using Page Object Model

# What is a Page Object?

Page Object Model is a design pattern that helps users write better tests and less code. It makes an object-oriented class that represents a page in your AUT (Application Under Test). Instead of rewriting the same code over and over again, you can describe your page once and share that description with many different tests. If your page changes, you can make the change is one place instead of many tests. Additionally, with Gondola's ILocator, you can use the same Page Object for the web, Android and iOS versions of an application.

# Creating a Page Object in GTD

  1. Navigate to the directory src/pages
  2. Right click on the pages directory and click New Gondola Page
  3. GTD will open with the default template for Page Object

NOTE

A Page Object Model contains only methods and locators

  1. Enter the locators and methods
  2. Click the save icon in the top right hand corner. GTD Save Icon
  3. Enter the name of your Page Object
  4. A new file named YourPageObject'sName.ts will appear in the pages folder

# Working with Page Objects

Page Objects consist of two sections:

  • Locators
    • Locators define the elements of your app you wish to interact with
  • Methods
    • Methods allow you to interact with those elements

# Defining Locators

Locators are defined on the LOCATORS section in GTD.
Locator format:
[element locator] [name:<name of locator>] [locator:<value>]
Element Locator
Please go here or to the Gondola API article for more information on Element locator.

# Defining Methods

Methods are defined under the Methods section when viewing a Page Object in GTD. Here is a template: Method Template

Note

Just like ABT tests, ABT Page Objects only support executable keywords that are understood by Gondola For a list of keywords, refer to the Gondola API As an advanced user, you may create more complex Page Objects in TypeScript, however those Page Objects might not display properly in GTD.

# Using the Page Object in Test Module

  • Your Page Object will automatically be imported to your test when you use one of its methods.
  • Predictive text selectbox will appear while typing. It's a useful tool for selecting correct method as it shows all information about highlighted method such as keyword and location.
    Importing a Page Object
  • A new line which imports Page Object class aka method's location will appear if user opens the saved test file in TypeScript mode
import loginPage from "../pages/loginSamplePage";
Last Updated: 8/14/2020, 12:49:56 PM