Define Data Externally In a Data ProviderΒΆ

# 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/assert-page-open-parameterised.yml
assertions:
  - $page.url is $data.expected_url
  - $page.title is $data.expected_title
# examples/step/google-query-parameterised.yml
actions:
  - set $elements.search_input to $data.query_term
  - click $elements.search_button

assertions:
  - $page.title is $data.expected_title
# examples/data-provider/google-search-query.yml
foo:
  search_term: "foo"
  expected_title: "foo - Google Search"

bar:
  search_term: "bar"
  expected_title: "bar - Google Search"
# examples/test/google-search-parameterised-with-data-provider.yml
config:
  browser: chrome
  url: google_com.url

imports:
  steps:
    assert_opened_page_step: "../step/assert-page-open-parameterised.yml"
    query_step: "../step/google-search-query-parameterised.yml"
  data_providers:
    imported_query_data: "../data-provider/google-search-query.yml"

"verify Google is open":
  use: assert_opened_page_step
  data:
    0:
      expected_url: $config.url
      expected_title: "Google"

"query":
  use: query_step
  data: imported_query_data