Part 6: Template Variables
Permalink to Part 6: Template VariablesHard-coding values makes tests brittle. Use template variables instead:
data:
username: '[email protected]'
password: 'SecurePass123!'
dashboard_url: 'https://app.example.com/dashboard'
steps:
- enter: field "Email" value "{{ username }}"
- enter: field "Password" value "{{ password }}"
- activate: button "Sign In"
- verify: url "{{ dashboard_url }}"
Variables are resolved from the data block before the test runs. This makes it
easy for extension cases to override specific values (see Part 8).
For shared data across many use cases, put common variables in external data files referenced in your config:
# usecase-runner.config.yaml
data_files:
- ./data/test-accounts.yaml
- ./data/urls.yaml
# data/test-accounts.yaml
accounts:
standard_user:
username: '[email protected]'
password: 'TestPass123!'
Then reference with dot notation: {{ accounts.standard_user.username }}