Introducing a new page object - iks-gmbh-tools/SysNat GitHub Wiki

Back


From time to time new data masks, screens or pages are added to an existing application due to new requirements. To make this extension of functionality easy, SysNat uses the Page Object Pattern. This means that a developer of the development team has to provide a new page object that supports all actions that can be performed on the new page. See also GenerationDialog and PageChangeEvents.

Given the test application MyTestApp there must be within the module sysnat.test.runtime.environment the java package com.iksgmbh.sysnat.language_templates.mytestapp.pageobject. Here you have to add a new page object class that implements the abstract class PageObject. This parent of all page objects implements a standard set of GUI actions which should work in most contexts. If you feel the need to overwrite these standard implementations in your newly created page object class or you have the need to add new methods for completely new GUI actions that are a not yet supported then feel free to do so.

The core task of any page object based on the PageObject parent is mapping the business name of a given GUI field (i.e. the term a domain user sees when looking at it on the page) onto the technical ID used by the driver to identify the graphical element within the page. For that purpose the PageObject parent contains the instant field idMappingCollection. This collection of mappings contains for each type of GUI element a separate list of mappings. Element types known to SysNat are listed in the enum SysNatConstants.GuiType.

For each type of GUI element the collection contains a list of key-value pairs in which each key represent the business name of a GUI element and each object a list of technical IDS. Since the technical ID may change during development (and therefore may differ between environments) SysNat allows to map one business name onto a list of technical IDs. These mappings are used in the standard implementations of the GUI actions in the PageObject parent.

A simple login mask with two text fields and one button may look like this

   public class LoginPageObject extends PageObject
   {	
      public LoginPageObject(LanguageTemplateBasics aLanguageTemplateBasics) 
      {
	   this.languageTemplateBasics = aLanguageTemplateBasics;
	   this.idMappingCollection = new HashMap<GuiType, HashMap<String, List<String>>>();
	
	   HashMap<String, List<String>> idMappings = new HashMap<String, List<String>>();
	   idMappings.put("Username", createList("username", "loginID));
	   idMappings.put("Password", createList("password"));
	   idMappingCollection.put(GuiType.TextField, idMappings);		

	   idMappings = new HashMap<String, List<String>>();
	   idMappings.put("Log in", createList("login_button"));
	   idMappingCollection.put(GuiType.Button, idMappings);		
      }
      
      @Override
      public String getPageName() {
	   return getClass().getSimpleName().replaceAll("Object", "");
      }
    
      @Override
      public boolean isCurrentlyDisplayed() {
	   return languageTemplateBasics.getExecutableExample()
                                        .isElementAvailable("login_button");
      }
   }

So typically, all you have to do as a developer to provide a new page object is creating a new page object class, implementing two simple methods and defining a collection of field mappings.


Back

⚠️ **GitHub.com Fallback** ⚠️