Using variables in TestDriver
Variables in TestDriver allow you to dynamically store and reuse data during test execution. This feature is particularly useful for handling dynamic content, passing data between steps, and customizing test behavior based on runtime conditions.- Generate a random number or string and use it to fill out a form.
- Capture API responses and validate their content.
- Capture text or values from the screen and use them in assertions.
- Pass different values to the test using environment variables for testing multiple scenarios.
Example:
random.yaml
CI/CD pipeline example (platform-agnostic)
You can run TestDriver in any CI/CD pipeline. Here is an example using the CLI in a generic workflow (adapt for your platform, e.g., GitHub Actions, GitLab CI, CircleCI, Jenkins, etc.):workflows/testdriver.yml
login.yaml
test file you can refer the variables
login.yaml
Capturing outputs as variables
Example:
capture-text.yaml
Best practices for using variables
- Use Descriptive Names:
- Name variables clearly to indicate their purpose (for example,
capturedText
,randomNumber
).
- Secure Sensitive Data:
- Use environment variables for sensitive information like credentials or API keys.
- Log Variable Values:
- Use
console.log
or similar commands to log variable values for debugging.
- Test Variable Logic Locally:
- Verify the logic for custom variables locally before integrating them into workflows.
- Combine Variables with Assertions:
- Use variables in assertions to validate dynamic content or conditions.