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 natural language such as "set new_variable as value".
- Variable usage can be done using the
{{
prefix to list all existing variables. - 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. This will list down all existing variables for this test. 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
- Use camelCase or underscore for multi-word variable names