Skip to content

Commit 4c64e6f

Browse files
authored
Merge pull request #1566 from Manuraj-7/stage
Stage: KTM-1072 Smart-Variables
2 parents 4b47f72 + aff31eb commit 4c64e6f

File tree

5 files changed

+127
-0
lines changed

5 files changed

+127
-0
lines changed
Loading
Binary file not shown.
Loading

docs/kane-ai-smart-variables.md

+126
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
---
2+
id: kane-ai-smart-variables
3+
title: 'Utilizing KaneAI Smart Variables Feature: A Step-by-Step Guide'
4+
hide_title: false
5+
sidebar_label: Smart Variables
6+
description: Learn how to utilize Smart Variables to dynamically adapt to various environments and conditions
7+
keywords:
8+
- lambdatest automation
9+
- lambdatest kaneai
10+
- kaneai smart variables
11+
- kaneai parameters
12+
url: https://www.lambdatest.com/support/docs/kane-smart-variables/
13+
site_name: LambdaTest
14+
slug: kane-ai-smart-variables/
15+
---
16+
17+
<script type="application/ld+json"
18+
dangerouslySetInnerHTML={{ __html: JSON.stringify({
19+
"@context": "https://schema.org",
20+
"@type": "BreadcrumbList",
21+
"itemListElement": [{
22+
"@type": "ListItem",
23+
"position": 1,
24+
"name": "Home",
25+
"item": "https://www.lambdatest.com"
26+
},{
27+
"@type": "ListItem",
28+
"position": 2,
29+
"name": "Support",
30+
"item": "https://www.lambdatest.com/support/docs/"
31+
},{
32+
"@type": "ListItem",
33+
"position": 3,
34+
"name": "KaneAI Smart Variables",
35+
"item": "https://www.lambdatest.com/support/docs/kane-ai-smart-variables/"
36+
}]
37+
})
38+
}}
39+
></script>
40+
41+
KaneAI's Smart Variables feature enhances test automation by providing predefined, dynamic variables that can be used across test steps, modules, and test cases. These variables enable dynamic adaptation to various environments and conditions, improving test reliability, reusability, and efficiency.
42+
43+
They cover categories such as date & time, system information, location, connectivity, randomization, and device-specific details, allowing users to create flexible and robust test scenarios that adapt to real-time conditions without manual input.
44+
45+
:::note
46+
Smart variables are predefined and cannot be created or deleted by users. They are accessible in test steps, modules, and test cases.
47+
When typing `{{` in the Web/App Agent, an overlay displays all available variables, including regular, secret, and smart variables, with smart variables labeled as "Smart" and accompanied by descriptions.
48+
:::
49+
50+
Smart Variables are listed under the variables section within an authoring session.
51+
52+
<img loading="lazy" src={require('../assets/images/kane-ai/features/smart-variables/smart-variables-list.png').default} className="doc_img"/>
53+
54+
## How to Use Smart Variables in Your Tests?
55+
56+
Smart variables can be referenced in test steps, modules, and test cases using the `{{smart.variable_name}}` syntax. Follow these steps to integrate them into your tests:
57+
58+
### Step 1: Access the Test Environment
59+
60+
Enter the Authoring or Editing mode for a KaneAI test case
61+
62+
### Step 2: Reference a Smart Variable
63+
64+
In the "Write a Step" field type `{{` to trigger the variable overlay. This will display a list of all available variables, including smart variables labeled with "Smart".
65+
66+
For example, to use the current date in a test step:
67+
68+
Use `{{` syntax to get the list of smart variables listed and type to search and filter them out then select the desired one.
69+
```
70+
Enter the value of {{smart.current_date}} in the date field
71+
72+
```
73+
74+
<img loading="lazy" src={require('../assets/images/kane-ai/features/smart-variables/smart-variables-fetching.png').default} className="doc_img"/>
75+
76+
### Step 3: Select a Smart Variable
77+
78+
From the overlay, select the desired smart variable. The variable will be inserted into the test step in the correct syntax (e.g., `{{smart.current_date}}`).
79+
80+
### Step 4: Run Your Test
81+
82+
Once the test step is executed the smart variable will dynamically resolve to its corresponding value based on the current environment or condition (e.g., `2025-04-29` for `{{smart.current_date}}`).
83+
84+
## Supported Smart Variables
85+
86+
Below is a comprehensive list of supported smart variables, organized by category, along with their syntax and descriptions:
87+
88+
| Category | Variable Name | Syntax | Description |
89+
|-----------------------|-----------------------|-------------------------------|-----------------------------------------------------------------------------|
90+
| **Date & Time** | `current_date` | `{{smart.current_date}}` | Current date in YYYY-MM-DD format |
91+
| | `current_day` | `{{smart.current_day}}` | Current day of the week (Monday, Tuesday, etc.) |
92+
| | `current_month` | `{{smart.current_month}}` | Current month name (January, February, etc.) |
93+
| | `current_month_number`| `{{smart.current_month_number}}`| Current month number (01, 02, ..., 12) |
94+
| | `current_year` | `{{smart.current_year}}` | Current year (YYYY) |
95+
| | `current_hour` | `{{smart.current_hour}}` | Current hour in 24-hour format (00 to 23) |
96+
| | `current_minute` | `{{smart.current_minute}}` | Current minute (00 to 59) |
97+
| | `current_timestamp` | `{{smart.current_timestamp}}` | Current timestamp in epoch milliseconds |
98+
| | `current_timezone` | `{{smart.current_timezone}}` | Current timezone name (e.g., GMT, UTC+5:30) |
99+
| | `next_day` | `{{smart.next_day}}` | Date of the next day in YYYY-MM-DD format |
100+
| | `previous_day` | `{{smart.previous_day}}` | Date of the previous day in YYYY-MM-DD format |
101+
| | `start_of_week` | `{{smart.start_of_week}}` | Date of the first day of the current week (YYYY-MM-DD) |
102+
| | `end_of_week` | `{{smart.end_of_week}}` | Date of the last day of the current week (YYYY-MM-DD) |
103+
| | `start_of_month` | `{{smart.start_of_month}}` | Date of the first day of the current month (YYYY-MM-DD) |
104+
| | `end_of_month` | `{{smart.end_of_month}}` | Date of the last day of the current month (YYYY-MM-DD) |
105+
| **User/System Information** | `os_type` | `{{smart.os_type}}` | Operating system name on which test is running (e.g., Windows, macOS, Linux)|
106+
| | `os_version` | `{{smart.os_version}}` | Operating system version on which test is running (e.g., 10.0, 14.2) |
107+
| | `browser_name` | `{{smart.browser_name}}` | Browser name on which test is running (e.g., Chrome, Firefox, Safari) |
108+
| | `browser_version` | `{{smart.browser_version}}` | Browser version on which test is running (e.g., 112.0, 101.0.1) |
109+
| | `user_name` | `{{smart.user_name}}` | Current user name on LambdaTest who trigger the test |
110+
| **Randomized** | `random_int` | `{{smart.random_int}}` | Random 3 digit integer |
111+
| | `random_float` | `{{smart.random_float}}` | Random 2 digit float |
112+
| | `random_string_8` | `{{smart.random_string_8}}` | Random alphanumeric string of specified length |
113+
| | `random_string_56` | `{{smart.random_string_56}}` | Random alphanumeric string of specified length |
114+
| | `random_email` | `{{smart.random_email}}` | Random email address |
115+
| | `random_phone` | `{{smart.random_phone}}` | Random phone number |
116+
| **Device-Specific** | `device_name` | `{{smart.device_name}}` | Name of the mobile device under test |
117+
| | `device_model` | `{{smart.device_model}}` | Model of the mobile device |
118+
| | `device_os` | `{{smart.device_os}}` | Operating system of the mobile device (iOS, Android) |
119+
| | `device_os_version` | `{{smart.device_os_version}}` | Version of the operating system (14.4, 11.0) |
120+
| | `device_orientation` | `{{smart.device_orientation}}`| Orientation of the device (Portrait, Landscape) |
121+
| | `app_version` | `{{smart.app_version}}` | Version of the app under test |
122+
| | `app_package_name` | `{{smart.app_package_name}}` | Package name of the app under test |
123+
124+
<video class="right-side" width="100%" controls id="vid">
125+
<source src= {require('../assets/images/kane-ai/features/smart-variables/smart-variables-guide.mp4').default} type="video/mp4" />
126+
</video>

sidebars.js

+1
Original file line numberDiff line numberDiff line change
@@ -1142,6 +1142,7 @@ module.exports = {
11421142
},
11431143
"kane-ai-modules",
11441144
"kane-ai-secrets",
1145+
"kane-ai-smart-variables",
11451146
"kaneai-upload-and-download-files",
11461147
"kaneai-modules-versions-and-enhancement",
11471148
"kane-ai-assertions",

0 commit comments

Comments
 (0)