Thunder Code introduces three types of Variables:
Static Variables
Generated Variables
Extracted Variables
These fall into two categories based on when they are resolved:
Variable Type | Category | When it's resolved | Examples |
Static Variables | Static | Before the test, from Environment |
|
Generated Variables | Dynamic | During test execution (at generate step) |
|
Extracted Variables | Dynamic | During test execution |
|
These variables are involved in the different phases of Test Case Execution.
Static Variables
Thunder Code uses Environments to manage static variables for your Test Cases.
Prerequisites
An existing Project
An existing Environment
Add Variables
Scroll Down to the Environment Variables Section.
Click on “Add Variables”.
Fill in the fields:
Variable Name.
Value.
Save your changes.
Important: Variable names must follow these rules:
Can only contain uppercase letters, numbers, and underscores (_)
Maximum length of 32 characters
No spaces or special characters allowed
Secret values have a maximum length of 512 characters.
Using Variables in Tests
Reference variables in your Test Steps using [VARIABLE_NAME]
. Thunder Code will automatically replace this with the actual value during test execution. You can also reference variables in the chat, and Thunder Code will automatically include them in any test steps it generates for you.
Example: Using Variables in a Login Test
Let's say you want to test a login flow for your website. Instead of hardcoding sensitive information, you can store them as credentials in your environment:
1. Create Variables in Your Environment
Create a variable named USER_EMAIL with your login email
Create a credential named PASSWORD with your login password
2. Reference These Variables in Your Test Case
Create a new Test Case with the request:
Navigate to home page, enter [USER_EMAIL]
in the email field, and [PASSWORD]
in the password field. Finally, press the login button.
When Thunder Code executes this test, it will automatically replace [USER_EMAIL]
and [PASSWORD] with the actual values from your selected environment. This way, you can:
Easily switch between different test accounts by changing environments
💡 Tip: You can add multiple variables to a single Environment.
📝 Note: If they exist, the variables will be displayed during the execution of the Test Case and in the Test Report.
Important: If you want to run a test containing variables on different environments, those variables must be present in all environments. Otherwise, your tests will fail.
Using Variables in API Call Steps
Generated Variables (Dynamic)
Thunder Copilot can generate variables with different patterns, character sets and lengths that you can reference in subsequent steps.
These variables are determined at runtime, creating new random values during each test execution.
Prerequisites
An existing Test Case
Generating Variables in Test Cases
In the Copilot chat, request Thunder to create variables using prompts similar to these:
"Generate
[FIRST_NAME]
as random first name""Create variable
[RANDOM]
with random value""Generate variable
[MY_VAR]
with 5 lowercase alphabetic characters""Create a random email in
[EMAIL]
"
💡 Tip: Fine-tune your results by editing the Generation step as needed.
📝 Note: Reference generated variables the same way as static variables.
📝 Note: The naming rules for static variables also apply to generated variables.
⚠️ Important: Variable names are unique, using conflicting names will give you errors.
Extracted Variables (Dynamic)
Extracted variables allow you to capture values from the browser or API call results and use them in subsequent steps.
Prerequisites
An existing Test Case
Extracting Variables from Test Steps
You can extract information during test execution using Thunder's extraction capabilities:
Extract text from elements on a page
Capture response data from API calls
To extract variables, use prompts in the Copilot chat like:
"Extract the product ID and save it as
[PRODUCT_ID]
""Save the order number as
[ORDER_NUMBER]
""Extract the confirmation code from the success message and store it as
[CONFIRMATION_CODE]
""Extract the name attribute of the step1 API call response, and store it in
[NAME]
"
💡 Tip: Extracted variables can be used in subsequent steps just like static or generated variables.
📝 Note: The naming rules for static variables also apply to extracted variables.
⚠️ Important: When extracting values from API call responses, specify the test step you want to extract from.
⚠️ Important: To extract a specific attribute from API call responses, you must precisely indicate the path of the value to extract.