KaneAI - Using Variables in Test Cases
The new variable definition feature in KaneAI allows users to define reusable variables, assign them values, and use those values within test cases. This feature enhances flexibility, readability, and consistency across test cases, making it easier to maintain and modify them.
Why Use Variables?
Using variables enables you to:
- Avoid repetitive entries in test cases.
- Get values from within the application under test & store it in variable to validate the accuracy of data.
- Increase the reusability and adaptability of test scripts, especially useful for parameters that might change frequently, such as URLs, credentials, or environmental settings.
Variable Syntax
To work with variables in KaneAI, you need to follow these syntax rules:
- Variables are defined using the
$
prefix - Variable names should follow the
$
symbol without any spaces - Example:
$username
,$phoneNumber
,$address
Creating Variables
To create a variable:
- Navigate to the "Write a Step" text field
- Type your instruction in natural language such as: Set username as John and a variable
$username
will be created with value John.
Example:
Set username as John
Using Variables
To use a previously created variable in any subsequent step or test case, reference the variable using the same $
syntax. Format: use the value of $variableName
Example:
use the value of $phoneNumber in the given text field
Best Practices
Naming Conventions
- Use descriptive names for your variables
- Avoid special characters except for the required $ prefix
- Use camelCase for multi-word variable names
Variable Management
- Document the purpose of each variable in comments
- Verify that variables are defined before using them