Page Model

A page model holds properties of a web page, avoiding the need to repetitively define such properties at the point that they are needed.

Syntax

A page model is a YAML document with url and elements properties.

The url property provides the URL for the web page. The elements property is an optional collection mapping convenience names to selectors.

Element selectors may optionally be prefixed with an element name that has already been defined within the same page model. Doing so scopes the selector to the given element.

url: {url}
elements:
    {element-name-1}: [{{ {predefined-element-name} }}] {selector}
    ...
    {element-name-N}: [{{ {predefined-element-name} }}] {selector}

----------------------------------------------------------------

url:
    <url>

element-name-*:
    <string>

predefined-element-name:
    <string>, name of an element that has previously been defined

selector:
    <selector>

Examples

# examples/page/google.com.yml
url: "https://www.google.com"
elements:
  search_input: $".gLFyf.gsfi"
  search_button: $".FPdoLc.VlcLAe input[name=btnK]"
# examples/page/google.com-selector-scoped.yml
url: "https://www.google.com"
elements:
  # finds "[name=q]" within the context of "form[action='/search']"
  search_input: $"form[action='/search'] input[name=q]"

  # finds "[type=submit]" within the context of "form[action='/search']"
  search_button: $"form[action='/search'] input[type=submit]"
# examples/page/google.com-element-scoped.yml
url: "https://www.google.com"
elements:
  search_form: $"form[action=/search]"

  # finds "[name=q]" within the context of search_form
  search_input: $"{{ search_form }} [name=q]"

  # finds "[type=submit]" within the context of search_form
  search_button: $"{{ search_form }} [type=submit]"