# Create Constant Variable

This is a pre-built Action located under the **@Generic Element**. The functionality of this Action in Avo Assure is to create a constant variable, assign the value provided in the input value column, and use it when a fixed value must remain unchanged throughout the test execution. The execution result is stored in the given dynamic variable.

## **Syntax**

&#x20;**Input Value**: `<Constant Variable>;<Value>`&#x20;

{% hint style="info" %}
**Note:**

* Variable name should be enclosed between underscores. For example: \_var\_.
* A constant variable in Avo Assure stays the same throughout the execution at the Project Level.
* If the test step tries to modify the value of a constant variable, then the test step will fail.
* If the constant variable is not already created but is used in the **Output Value** field, Avo Assure creates the constant variable with the name given by the user and stores the test step result in it.
  {% endhint %}

| Argument                                     | Description                                                                                                                                                                                            |
| -------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| <p>\<Constant Variable></p><p>(Required)</p> | Provide the name of the constant variable you want to create.                                                                                                                                          |
| <p>\<Value><br>(Required)</p>                | <p>Provide the value you want to store in the constant variable.<br>Supported variables are: </p><ul><li>Number</li><li>String </li><li>Alphanumeric </li><li>Special Characters</li><li>URL</li></ul> |

&#x20;**Output Value**: `<Dynamic Variable>(Optional);<Dynamic Variable>(Optional)`

| Argument                                                    | Description                                                       |
| ----------------------------------------------------------- | ----------------------------------------------------------------- |
| \<Dynamic Variable>(Optional);\<Dynamic Variable>(Optional) | Both dynamic variables store the status as **True** or **False**. |

### Example 1: Creating a Constant Variable with a Fixed Value

In this example, we explain how to create a constant variable that remains unchanged during the entire test execution.

* **Action**: Create Constant Variable
* **Input Value**: \_AppURL\_;<https://avotestlab.avoassure.ai>
  * The first argument (**\_AppURL\_**) specifies the name of the constant variable.
  * The second argument (**<https://avotestlab.avoassure.ai>**) specifies the value of the constant variable.
* **Output Value**: {Status}
  * The execution status of the action is stored in this **{Status}** dynamic variable with the following possible values:
    * **True**: If the constant variable is created and assigned successfully.
    * **False**: If the variable creation fails due to invalid input or format.

{% hint style="info" %}
**Note**: If you do not define an output variable, Avo Assure displays the result only in the execution logs and does not store it in any variable.
{% endhint %}

* **Logical Explanation**: The **Create Constant Variable** action fetches the value from the **Input Value** column (**\_AppURL\_;<https://avotestlab.avoassure.ai>**). It creates a constant variable named (\_AppURL\_) and assigns the value (<https://avotestlab.avoassure.ai>) to it. The execution result is stored as (True) in the **{Status}** variable.

<figure><img src="https://2174257472-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fk8QZzXZMIJSStKAzDSTu%2Fuploads%2FtJbQy9LFK3HSfntxtmkn%2Fimage.png?alt=media&#x26;token=c560ba2d-dcef-4c84-a48b-c6ccc46c2d89" alt=""><figcaption></figcaption></figure>

#### **Knowledge Bites:**&#x20;

Here are some examples of different variable scenarios:

<table><thead><tr><th>Variable</th><th width="279">Input Value</th><th width="272">Result </th></tr></thead><tbody><tr><td>Text Variable</td><td>_Username_;Admin</td><td>True</td></tr><tr><td>Numeric Variable</td><td>_OTP_;35629</td><td>True</td></tr><tr><td>Alphanumeric Variable</td><td>_EmpID_;OJ1002</td><td>True</td></tr><tr><td>Wrong Input Variable</td><td>__Password__;Admin@12</td><td>False</td></tr></tbody></table>
