SetVariable Action

SetVariable Action Overview

What is a Variable?

At its most fundamental, a variable is anything that stands in for other data. The variable represents a piece of data that may be altered for various testing reasons. Variables can be substituted for site credentials, order numbers, cookies, and other data.

Variables allow users to deal with data in a flexible and dynamic manner, enabling them to save, change, and retrieve information while a program is running.

The system supports three types of variable scopes:

Local Variables

  • Local variables are only accessible inside the environment of a single test. When you need dynamic data for a test but don't want parallel executions of that or other tests to interfere with the data, this is the most popular sort of variable.

  • A local variable is one that is defined and used within a single block of code, such as a function or method, and whose scope is restricted to that block. This signifies that the variable can only be accessed and used within the code block where it is declared. When you leave that block, the variable usually exits the scope and is no longer available.

  • Local variables are frequently used within functions and methods to hold temporary data or interim outcomes. They are essential for encapsulating and isolating data within a certain area of code, which helps to avoid name conflicts and makes the code easier to comprehend and maintain.

  • Variables are accessed or set as an object named fze.local within expressions.
  • For Example: If you want to override text in an input field with a local variable, the input value will be:
    {{fze.local.yourOverrideVariableName = 'Override Text'}}

Local Variable Action Use Case Scenario

  1. In this test case, we are verifying a product whose text may change overtime


  2. So, we put a Set Variable Action below this Verify Action and set it to the Previous Action, so that it takes whatever text the Verify Action in the previous step captured

 

How to Create a Local Variable

There are 2 ways to create a Local Variable for a Functionize automated test case

  • Architect: While recording a new test case
  • Quick add: From the Functionize Front-End UI, Test Details page and Slider View

Architect

  1. Click the Variables button at the bottom of the Architect to open the Variables panel


  2. Click + Add Variable button to open the Expression Builder, Project Variables that have already been created by you or a teammate within this Project, will be displayed in this panel


  3. Select the Scope of the Variable to be created: Local will be set by default
    Note: Local Variables are available within a specific test case. When you need dynamic data for a test but don't want parallel executions of that or other tests to interfere with the data, this is the most popular variable scope.


  4. Enter the Name of your Variable, in this example, we used LocalDemo


  5. Select the Type of function you will use to help define your variable, in this example, we will use Previous Action for storing the Verify Action value, learn more about the provided Types below.
    NOTE: Different Variable Types will open subsequent fields to enter or select the necessary information.


  6. Click Select Step to select the step to retrieve the data from, in this example we have selected Step 2 which will store the Verify Action value from that previous step


  7. Click Select Step Attribute to select the attribute from the dropdown for the data to store in the Variable, in our example we have selected the Text attribute


  8. Select the Operator that you want to use, or you can leave the default/blank Operator, learn about the provided Operators below


  9. The Expression output can be unlocked to customize your expression beyond the default expression, click the Lock icon to edit and click the Unlock icon again once finished to re-lock the Expression


  10. When your Variable is complete, click Save button in the Add Variable side panel

 

Quick Add

  1. From the Test Details page, hover between the Actions and locate the bar with the symbol


    From the Slider view, Click the Quick Add button at the step where you would like to insert the action.


  2. To access the Insert drop-down menu, click the Quick Add button

  3. Choose Set Variable from the Insert dropdown menu


  4. Choose Local as the Scope


  5. Choose Static Value or Javascript Expression in the Type drop-down
    Note: Javascript Expression is used when we want to use test case data and Static Value is simple text input. If fze.iteration is a variable, you can provide a custom iteration. For example - fze.local.loop[fze.iteration].title.

  6. Click on the Name field, to add a variable name for the Local Variable


  7. The Expression field is now unlocked, and you may enter a Javascript Expression


  8. Enter the Javascript Expression in the Expression field and click on the Insert button, in this example, the expression is to save the previous step value 

Project Variables

Project Variables are available for all tests in that Project. They are scoped to the Environment of the Project. Variables are accessed or set as an object named fze.project within Expressions.

For Example: if you want to utilize a Project Variable to enter an email address, the input value will be:

{{fze.project.yourEmailVariableName}}

Variable names must not have spaces and must be valid JavaScript names, accessible via the '.' notation for object access.

 

Project Variable Action Use Case Scenario

  1. In this test case, we first add a new Set Variable Action labeled as test and entered the value testing


  2. Then the Input Action enters the Project Variable value in the Search field using the Expression{{fze.project.test}}

 

How to Create a Project Variable

There are 3 ways to create a Project Variable:

  • Architect: While recording a new test case
  • Quick Add: From the Functionize Front-End UI, Test Details page and Slider View
  • Project Actions menu: Project Variables option

Architect

  1. Click the Variables button at the bottom of the Architect to open the Variables panel
    AV1.png

  2. Click + Add Variable to open the Expression Builder, Project Variables that have been created by you or a teammate within this Project, will be displayed in this Variables panel
    ARCvar2.png

  3. Enter the Name for your Variable, in this example, we will named it searchCriteria
    AV2.png

  4. Select the Scope of the Variable, in this example, Project Variables are global to the project so any other test may use or modify that variable at any time


  5. Select the Type of function you will use to help define your variable, in this example, we will use Value for a static number or string, learn about the provided Variable Types here
    NOTE: Different variable Types will open subsequent fields to enter or select the necessary information.


  6. Select an Operator to perform on your data if applicable, in this example, we have selected toUpperCase, which alters our value entered above tripod to TRIPOD as seen in the Result section. Learn about the provided Operators below


  7. The Expression output can be unlocked to customize your expression beyond the provided Operators, click the Lock icon to edit and click the Unlock icon again once finished to re-lock the Expression


  8. When your Project Variable is complete, click the Save button on the Add Variable left side panel

Quick Add

  1. From the Test Details page, hover between the Actions and locate the bar with the symbol


    From the Slider view, Click the Quick Add button at the step where you would like to insert the action.


  2. To access the Insert drop-down menu, click the Quick Add button.


  3. Choose Set Variable from the Insert dropdown menu.


  4. Choose Project as the Scope

  5. Choose Static Value or Javascript Expression in the Type drop-down, the Static Value is simple text input and Javascript Expression is used when we want to use test case data, suppose fze.iteration is a Variable then you can input a custom iteration
    For Example: fze.local.loop[fze.iteration].title.


  6. Click on the Name dropdown, you can either + Add New Variable or select a pre-existing Variable


  7. If you click on + Add New Variable, then a field will appear below the Name drop-down where you can enter a unique Variable Name, in this example, we named it testVariable


  8. Enter the Static Value in the Value field

  9. Click Insert

Project Variables Window

  1. On the Test Details page, click on the Project Actions menu > Project Variables


  2. In the Project Variables modal, you can + Add New Variable, Edit, Delete and Mask existing Project Variables


  3. To create a new variable, click on the + Add New Variable button
  4. A new row with blank fields will appear, enter Variable Name and Value


  5. Click Save

How to Mask Project Variables

A user can Mask Project Variables so that the values are obscured and are not visible anywhere in the Functionize UI. Once the value is masked, then it cannot be unmasked.

Note: Local Variables cannot be masked because it is a technical limitation.

  1. On the Test Details page, click on the Project Actions menu > Project Variables


  2. In the Project Variables modal, you can Mask a Project Variable by clicking on the Mask checkbox for any existing listed Project Variable


  3. Click Save


  4. Before saving, a Confirmation message will appear giving you a warning - Once a variable is masked, the value cannot be unmasked - you can check the Don’t show this message again checkbox if you don’t want this message to appear again


  5. Click Confirm to save the changes

TDM Variable

Set Variable TDM Action Overview

What is the TDM Scope of the Set Variable Action?

The TDM Scope of the Set Variable Action allows users to interact with a TDM Data Source and provides various Actions, which include (see details in links below):

It is highly useful when generating reports or when adding or updating rows, deleting complete data, or creating a new sheet in the current TDM Data Source during testing.

How does the TDM Scope of the Set Variable Action work?

It operates through a global extension that interacts with all data sources in the background using the Swagger API. If the user wants to add a row to the dataset, the runtime will pass all data to the extension, which will parse it and ensure that the action type is Add Row. The Swagger API then calls the API for adding the row, and the row gets added to the data source.

A user interface is provided to make these tasks easy for users. This feature is simple to use with the UI and allows the user to interact effortlessly with any data source.

There is 1 way to create a TDM Variable:

  • Quick Add: From the Functionize Front-End UI, Test Details page and Slider View
    Note: Quick Add can be done from the Page Object Details page as well, following the same steps from the Test Details page below. Like any other change to a Page Object, when you click the Insert button, a Confirmation modal appears, with the option to click Continue to save the changes to all tests that use this Page Object or Cancel to discard the changes
    Note: TDM Variables cannot be added from the Architect while recording a new test case.

Quick Add

  1. From the Test Details page, hover between the Actions and locate the bar with the symbol


    From the Slider view, Click the Quick Add button at the step where you would like to insert the action.


  2. To access the Insert drop-down menu, click the Quick Add button.


  3. Select Set Variable from the Insert dropdown menu


  4. Select TDM as Scope


  5. Choose any TDM Data Source on the Data Source field




  6. Choose any one Action type from the drop-down menu


  7. Finally, click Insert

TDM Variable - Search Action

The SearchAction type in the TDM scope is used when a user wishes to search for a value in a specified column of a TDM Data Source.

  1. Open the Set Variable modal from the Quick Add Insert menu, select TDM as the Scope, in the Data Source field select any TDM Data Source


    Note: Following the selection of any TDM Google Sheet Data Source, an additional field will appear, allowing you to select the Sheet List on the TDM Google Sheet Data Source. If you pick any other format TDM Data Source, this field will not appear.


  2. Choose Search from the Action drop-down menu

  3. The Search Parameter section appears, in the Search field select the Column Name for which the Value will be searched


  4. In the Value field, enter the value to be searched

  5. The Value Type field can be set to Static Value or Javascript Expression, based on the Search Value being used
    For Example: For Static Value, the user must enter any alphabet or numerical value (i.e. Checkup1).


    For Example: For Javascript Expression, the user must enter any JavaScript value (fze.iteration).


  6. If the input value is not in the correct JavaScript format, the user will receive an Invalid Syntax error and the Insert button will not be enabled, making it impossible for the user to save the updates


  7. When an Action is successfully saved, the TDM tag will be reflected beside the intended action


  8. After execution, click on the Action's View button which is located to the right of the Set Variable Action, and then move to the Variable tab on the Slider view Footer data


  9. You can see param response and data response details, and buttons to see full data and/or copy data to clipboard


  10. You can see param response properly by clicking on the button

  11. You can see data response properly by clicking on the button

  12. You can download the current CSV file from the TDM Data Source page and tally the results


  13. If you search for a wrong value, the tdm response will be blank after execution


 

TDM Variable - Add Row

Add Row Action type is used when we want to add a new row in a particular column of the TDM Data Source.

  1. Open the Set Variable modal from the Quick Add Insert menu, select TDM as the Scope, in the Data Source field select any TDM Data Source


    Note: Following the selection of any TDM Google Sheet Data Source, an additional field will appear, allowing you to select the Sheet List on the TDM Google Sheet Data Source. If you pick any other format TDM Data Source, this field will not appear.


  2. Choose Add Row Action type from the drop-down menu


  3. In the New Row Data sections, add the new data in any/all of the fields


  4. Click on Insert button


  5. New Set Variable Action for Add Row is added


  6. Execute the test case with Headless Run
  7. Check the TDM Data Source to see the newly added row

TDM Variable - Add Multiple Row

When a user wants to add multiple rows to specific columns of a TDM Data Source, the Add Multiple Row Action type under the TDM scope is used. This feature is primarily designed for advanced users.

  1. Open the Set Variable modal from the Quick Add Insert menu, select TDM as the Scope, in the Data Source field select any TDM Data Source


    Note: Following the selection of any TDM Google Sheet Data Source, an additional field will appear, allowing you to select the Sheet List on the TDM Google Sheet Data Source. If you pick any other format TDM Data Source, this field will not appear.


  2. Select Add Multiple Row Action type from the drop-down menu


  3. On the New Multi Row Data section, hover over the icon to see the Multiple Row Data format


  4. On the Multi Row Data field data the data according to the example data format


  5. Click on Insert button


  6. If the input value is not in the correct JavaScript format, you will receive an Invalid Syntax error and the Insert button will not be enabled, making it impossible for the user to save the modifications


  7. When the Action is successfully saved, the TDM tag will be reflected beside the intended action


  8. After execution, click on the Action's View button which is located to the right of the Set Variable Action


  9. On the Slider view, move to the Variable TAB in the Footer data, you can see param response and data response details, and buttons to see full data and/or copy data to clipboard


  10. You can see param response properly by clicking on the button

  11. You can see data response properly by clicking on the button


  12. You can download the current CSV file/Google Sheet from the TDM Data Source page and determine whether the result was correctly inserted or not

TDM Variable - Search and Update Row

Search and Update Row Action type is used when we want to search and update a column of a row in a TDM Data Source.

  1. Open the Set Variable modal from the Quick Add Insert menu, select TDM as the Scope, in the Data Source field select any TDM Data Source


    Note: Following the selection of any TDM Google Sheet Data Source, an additional field will appear, allowing you to select the Sheet List on the TDM Google Sheet Data Source. If you pick any other format TDM Data Source, this field will not appear.


  2. Choose Search and Update Row Action type from the drop-down menu


  3. In the Search Parameter section, select any Data Source column in the Search field


  4. Enter the Value of any row of the selected column, we can select Static Value or Javascript Expression in the drop-down to the right of the Value field


  5. Under the Update Row Data section, select the Data Source column field you want to update the row data be clicking the checkbox


  6. Enter the Update Value you want to replace the Current Value with and select Static Value or Javascript Expression from the drop-down field


  7. Click the Insert button


  8. The new Set Variable with Search and Update Row Action type will be added to the test case


  9. Execute the test case with Headless Run
  10. Check the TDM Data Source to see the newly updated row

TDM Variable - Hash

The Hash Action type is used if the user wants to retrieve data from two columns. For example, if there is a report containing employee data, and you want the contact numbers of employees, you can select the employee name column in the search and the contact number column in the value. This will provide you with the data in TDM response on the Slider view.

  1. Open the Set Variable modal from the Quick Add Insert menu, select TDM as the Scope, in the Data Source field select any TDM Data Source


    Note: Following the selection of any TDM Google Sheet Data Source, an additional field will appear, allowing you to select the Sheet List on the TDM Google Sheet Data Source. If you pick any other format TDM Data Source, this field will not appear.


  2. Choose Hash Action type from the drop-down menu

  3. Under the Search Parameter section, select Column header from the drop-down list

  4. Enter the Value to search for under the selected Column header


  5. Click the Insert button


  6. When the Set Variable Action is successfully saved, the TDM tag will be reflected in the Footer of the intended Action


  7. After execution, click on the Action's View button which is located to the right of the Set Variable Action


  8. On the Slider view, move to the Variable TAB in the Footer data, you can see param response and data response details, and buttons to see full data and/or copy data to clipboard


  9. You can see param response properly by clicking on the button
  10. You can see data response properly by clicking on the button


  11. You can download the current CSV file/Google Sheet from the TDM Data Source page and determine whether the correct results


TDM Variable - Truncate Data Source

To remove row data from a TDM Data Source, use the Truncate Data Source Action type. It will keep the columns but delete all of the row data.

  1. Open the Set Variable modal from the Quick Add Insert menu, select TDM as the Scope, in the Data Source field select any TDM Data Source


    Note: Following the selection of any TDM Google Sheet Data Source, an additional field will appear, allowing you to select the Sheet List on the TDM Google Sheet Data Source. If you pick any other format TDM Data Source, this field will not appear.


  2. Choose Truncate Data Source Action type from the drop-down menu


  3. Under the Expression section, hover over the icon to see the value to add a Static Value or create a variable using a Custom Expression


  4. Click Insert button


  5. When the Action is successfully inserted, the TDM tag will be reflected in the Footer of the intended Action


  6. After execution, click on the Action's View button located to the right of the Set Variable Action

  7. On the Slider view, move to the Variable TAB in the Footer data, you can see param response and data response details, and buttons to see full data and/or copy data to clipboard


  8. You can see param response properly by clicking on the button


  9. You can see data response properly by clicking on the button


  10. You can download the current CSV file/Google Sheet from the TDM Data Source page and evaluate the results

    Original Data Source


    Current Data Source

 

TDM Variable - Create New sheet

The Create New SheetAction type allows you to add a new worksheet in the Google Sheets Data Source.

Note: This option will only appear if the Data Source is a Google Sheet TDM Data Source

  1. Open the Set Variable modal from the Quick Add Insert menu, select TDM as the Scope, in the Data Source field select any TDM Data Source


    Note:
    Following the selection of any TDM Google Sheet Data Source, an additional field will appear, allowing you to select the Sheet List on the TDM Google Sheet Data Source. If you pick any other format TDM Data Source, this field will not appear.


  2. Choose Create New Sheet Action type from the drop-down menu

  3. Enter the name of the sheet in the Sheet Name field


  4. Enter the syntax in the Column Headers field as suggested when you hover over the icon


  5. Click the Insert button


  6. The new Set Variable with Create New Sheet Action type will be added to your test


  7. Execute the test case with Headless Run
  8. Check the TDM Google Sheet Data Source to see the newly added Sheet