Page Object Root

Any page object that is unique inside the current browser view can be used as a root. A root page object can be loaded directly inside the browser.

The root of a page object can contain these properties:

  • elements (Optional) Array. A nested tree of element objects. An element object can be one of these types:
  • methods (Optional) Array. Each object declares a public method. The only supported method type is compose. A compose method combines several element actions, like clearing a text field (clear) and entering a value (setText).
  • root (Optional) Boolean. To load a page object from a test, set root to true and add a selector element that points to its most outer (root) element. If a component can be loaded only inside its immediate parent (for example, a navigation item can be loaded only inside a navigation bar), don’t mark it as root.
  • selector (Optional) Object. If root is true, add a selector that points to its most outer (root) element. The root selector must match the HTML tag name. See selector.
  • shadow (Optional) Object. A shadow boundary at the root of the page object. Contains only an elements property, which is a nested tree of objects. A page object can have elements scoped both inside and outside its shadow root.
  • exposeRootElement (Optional) Boolean. See Actionable Root.
  • type (Optional) String. See Actionable Root.
  • description (Optional) String or Object. See Page Object Description.
  • metadata (Optional) Object. See Page Object Metadata.
  • platform (Optional) String. See Platform Context.
  • beforeLoad (Optional) Array. See beforeLoad.

Here's a sample outline of a page object.

To make the root element actionable, expose it via a public method. Add these properties to the root element:

  • exposeRootElement Boolean. If set to true, UTAM creates a public method that returns an instance of the element with the given type. The name of the getter is getRoot.
  • type (Optional) See basic element types.

The UTAM generator converts this JSON into a public method. The method returns an instance of the page object root element for the test to interact with.

The word root is reserved and can't be used as an element name.