Working with Global Variable - New UI


Global variables are the stored data that retain a consistent value throughout the project. These variables are used when there is a need to use a common and consistent data among different test cases, reusable components, or within a test suite.

Global Variable is basically used when we need some data at multiple instances. The account Name might be required in more than one scenario in a test case. Or even in multiple test cases if we are executing the job/suite. Because even if we want to run a standalone test case, we won’t need to insert data in LDR, instead we can simply change the data at runtime instead of searching the step in Mutiple components aligned in a test case. 

 

You can store dynamically generated data such a PO number, invoice number, requisition number, etc. in a global variable and use them in other test cases as per your testing requirements. 

Changes (if any), are made to the global variable at one single spot. This approach eliminates the need to modify it in every artifact it is used.


These variables fall into two categories: 
User-defined, where users create their own variables based on their needs and use them across the project.

System-defined: These are two system generated global variables where users can only update values in them. Default Browser and Default Mobile Device are two system generated global variables in Opkey.


To create a Global variable for the project, follow the steps mentioned below:

1. Login to the Opkey portal.

2. Click on the 'Tools' icon on the top-right panel and select Global Variable.


3. The global variable page opens up. Default Browser and Default Mobile Device are the two system-defined Global variables that exist in every project (even in a new project.). To add a new user defined global variable, click ‘+’ button.

A new row gets added to the User-defined Global Variable list. Name field is mandatory.


The string is the default Data type for a value stored as global variable, but you can choose a suitable data type for it by clicking on the Data Type cell. Next, add the value for your variable in the call of value column. You can check the box in the Externally Updatable column to enable updating of this variable where it is used. 

You have the option to see where a specific Global Variable has been linked to. To do this, pick the Global Variable and press the "UsedBy" button. The "Used By" panel will display the name, complete path, description, and type of component of the artifact that uses the chosen Global Variable. 



Global Variable Encryption

This is an advanced feature of Global Variable which allows the users to generate global variables with encrypted values utilizing the Secured String Data Type.

When these Global Variables are established in their encrypted form, their actual values remain concealed from users. The values can be decrypted by giving a decryption password set in Opkey Admin at the project level.

To create Global variables with encrypted values, Select the Secured String from the Data Type Dropdown and enter the value as shown below:


This Encrypted value cannot be edited. Although if you wish to edit or view value in the decrypted format then, click the Decrypt value icon. It will decrypt the value [provided there is no encryption password set at the project level. 


If an encryption password is configured at the project level, a pop-up window appears. You are required to input the encryption password and then click the OK button.


After the Execution is finished, you can choose to decrypt the values. To do this, click on the Decrypt Result icon. If there's an encryption password in place, you'll be prompted to enter it.


You can also Export the result in Encrypted or decrypted format for the Detailed report.

Mapping a global variable in a test case

1. To map a global variable in a test case, start by opening the test case. Here, we are opening a test case for Hire an Employee process in Oracle.


2.Click the three dots icon on the test step where you want to map the global variable and select Set Input Data option. This will open the Edit Test Data of Step page, where you can map the global variable to this step. Here, we are opening the input page of the test step where we last name of employee is entered. We will map a global variable with employee's last name as value in this step.


3. On the Edit Data of Step page, click the Data Drive icon beside the Data column of Input tab. 



4. Next, select the Advance Options tab on top.



5. In the Advance Options tab, click on the dropdown as shown and select the Global Variable option.


6. A list of stored globle variables of the project will appear on the page. You can scroll down to find your variable or search it by clicking the search icon. Here, we have searched the variable containing employee's last name.

Click on the variable to map it to the test step. Once done, click the close icon at the top to exit this page.



7. Your global variable is mapped to this test case. Next, you can save the test case and click the Run button to start the process of execution of this test case with the global variable.


Updating Values of Global Variables at Runtime:

You can change the value of the Global variables at runtime. To do so, opt for the Global Variable tab on the Run Wizard, and select dropdown. Select any global variable whose value has to be changed. Here, you can update the value before starting the execution. Once done, click the Start Run button to proceed with execution. 

You're at the end of this article. Click here to access article for Opkey's Auto Data Generation feature.


Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article