Define Page Properties in a Page ModelΒΆ

# examples/page/google.com-element-scoped-literal.yml
url: "https://www.google.com"
elements:
  search_form: $"form[action=/search]"

  # finds "[name=q]" within the context of $"form[action=/search]"
  # using basil parent-child syntax
  search_input: $"form[action=/search]" >> $"[name=q]"

  # finds "[type=submit]" within the context of $"form[action=/search]"
  # using basil parent-child syntax
  search_button: $"form[action=/search]" >> $"[type=submit]"
# examples/page/google.com-element-scoped-reference.yml
url: "https://www.google.com"
elements:
  search_form: $"form[action=/search]"

  # finds "[name=q]" within the context of search_form
  # using basil parent-child syntax
  search_input: $search_form >> $"[name=q]"

  # finds "[type=submit]" within the context of search_form
  # using basil parent-child syntax
  search_button: $search_form >> $"[type=submit]"
# examples/step/google-assert-open-literal.yml
assertions:
  - $page.url is "https://www.google.com"
  - $page.title is "Google"
# examples/test/google-import-assert-open-with-page-model.yml
config:
  browsers:
    - chrome
  url: google_com.url

imports:
  steps:
    google_assert_open: "../step/google-assert-open-literal.yml"
  pages:
    google_com: "../page/google.com.yml"

"verify Google is open":
  use: google_assert_open

"query 'example'":
  actions:
    - set $google_com.elements.search_input to "example"
    - click $google_com.elements.search_button

  assertions:
    - $page.title is "example - Google Search"