Using Data Within Environment VariablesΒΆ

# examples/step/example-sign-in-as-user.yml
actions:
  - set $".sign-in-form .user" to $data.username
  - set $".sign-in-form .password" to $data.password
  - click $".sign-in-form .submit"

assertions:
  - $page.url is "https://www.example.com/account/"
  - $page.title is "Welcome $data.username"
# examples/data-provider/example-sign-in.yml
user1:
  username: $env.TEST_USER_1_USERNAME
  password: $env.TEST_USER_1_PASSWORD

user2:
  username: $env.TEST_USER_2_USERNAME
  password: $env.TEST_USER_2_PASSWORD
# examples/test/example-sign-in-with-data-provider.yml
config:
  browser: chrome
  url: https://www.example.com

import:
  steps:
    sign_in_step: "../step/example-sign-in-as-user.yml"
  data_providers:
    users: "../data-provider/example-sign-in.yml"

"open https://www.example.com":
  assertions:
    - $page.url is $config.url
    - $page.title is "Example Domain"

"sign in as user (literal data)":
  use: sign_in_step
  data:
    user1:
      username: $env.TEST_USER_1_USERNAME
      password: $env.TEST_USER_1_PASSWORD

    user2:
      username: $env.TEST_USER_2_USERNAME
      password: $env.TEST_USER_2_PASSWORD

"sign in as user (imported data)":
  use: sign_in_step
  data: users