Defining a new constant

Tasks in your page object classes often interact with objects, such as div and anchor tags, and form elements, on the storefront. The Storefront Test Automation Engine is designed to find these objects using their ID, Class Name, XPath, or other attributes which are encoded in the source of the page. The Aurora store was developed such that each object on the storefront as and many other HTML nodes have unique object IDs. These unique object IDs are stored in each Page Object file. These Ids can be used only in the page objects, and should not be directly called from the Test Scripts.

Procedure

  1. Determine the object ID for the object you want to define.
    • Using Mozilla Firefox:
      1. Start Firefox and browse to the starter store that uses the object.
      2. When the store home page is loaded, click the Firebug icon in the lower right side of the Firefox window.
      3. In the Firefox console, ensure that the HTML tab is selected.
      4. Click Click an element in the page to inspect to enable the ability to lock on to an object.
      5. Click the object that you want to define to lock on to it.
      6. Select the HTML tab in the Firebug console. The HTML source code of the object is highlighted.
    • Using Microsoft® Internet Explorer:
      1. Start Internet Explorer and browse to the starter store that uses the object.
      2. Click Tools > Developer Tools.
      3. Select the HTML tab. The HTML source code of the object is highlighted.
      4. Click the Select Element by Click (the cursor icon) to enable the ability to lock on to an object.
      5. Click the object that you want to define to lock on to it.
  2. Define the object ID in the Page Object file.
    1. Select and copy the object ID that is highlighted within the double quotation.
    2. In the development environment, browse to the specific Page object that needs a modified identifier.
    3. In the Page Object file, find the list of identifiers at the top of the page, add, or modify the needed identifier. Enter a name for the new constant and determine whether your identifier is an ID, a class, an XPath, and so on.
    4. Use Identifier.byObjectType methods to indicate the type of identifier you are defining.
      For example:
      private static final Identifier headerLinks = Identifier.byId("widget_masthead_links");
      or
      private static final Identifier departmentsWidget = Identifier.byXPath("//div[@id='widget_
         departments']//div[@class='content']//span[contains(text(),'Departments')]");
    5. Save the Page Object file.

Results

A new constant is created for a previously undefined object. You can reference the constant in your Page Objects as needed.