Local variables

BugBug has the option to set up and insert a variable from the tested source during test recording. Now you can store any text value from the web page you are testing in a variable and use it in feature steps. For example, to find out newly registered unique users in your CRM. Also, you can use built-in variables or custom variables added to the project.

A new option for variables in the test recording process can be found in the BugBug Extension overlay.

When you click on the "Variables" button there will be two options:

  • Save variable for later

  • Insert variable

Save variable for later

This option is used to save the new text value as a variable during the test recording. You can find an element and copy the value directly from the browser. Now there is no need to hardcode values and change them later in a BugBug web app steps edition. You can move forward.

Click on the "Save variable for later" button. Saving a variable mode is now active.

At this time you can click on an element with text value on a tested web app and save it into a variable. For example, you can save the search phrase - "Bugbug automation tool".

When an element is selected and a value is recorded, you will see an input in the BugBug extension menu where you can save the name for the new variable. Later this name will be visible in a list of variables in the BugBug extension menu.

When you save a variable, you will be taken to the main menu of the BugBug extension and can continue recording steps.

The saved variable is a cross-domain feature. Now you can use the saved value on different web apps in one test. eg. You can open a new tab and use the stored value there.

The variable can be overwritten several times during the test recording by using the same name. If you want to avoid this situation, use some unique names each time.

Using the same name of the variable as the built-in or custom variable name will override the data. This can cause a problem if your test is based on them and overriding these variables is not intended.

Insert a variable during step recording

Now you can insert a variable during step recording in BugBug. You can use saved variables from previous steps, use custom variables from the project, or use global variables that are predefined by default.

Click the "Insert Variable" button. A variable menu will open. As you can see, we suggest the last saved variable by default. Every variable has a name and length-limited value presented below the name. You can open the drop-down menu to select another variable from the list. Available variables will be discussed in another chapter. Now we will focus on how to insert our saved variable into the designated input.

When you open the "Insert variable" menu the insert variable mode is now active for the selected variable. Now let's move on to the web application we're testing.

If you have an input that you want to automatically fill and you have opened the Insert Variable menu with the selected variable, you can simply click on an input to fill it with a value.

The "Insert variable" menu closes. The entry is saved with the value, and you can continue recording steps such as clicking Enter to open search results.

Available variables

During recording, you can also insert a variable added by default from BugBug such as:

  • Built-in variables

  • Custom variables

All these variables are described in the Variables section of BugBug documentation.

Using built-in or custom variables is now easy and you do not need to edit steps in the BugBug web application UI. You can find them in the list.

Unavailable variables during step recording

Built-in variables based on a suit or scheduled run

We cannot provide data such as {{suiteRunId}} because when recording, there is no suiteRunId. It's only accessible when the suite is running. You can insert this variable in normal test-edit mode on the BugBug web app UI for a case.

Some of the built-in variables are now disabled with notification. BugBug cannot import data from these variables. You can use it in step edit on the BugBug web app UI.

Custom JS variables

Currently, there is no way to use a custom js variable during test recording. We are working on providing such a feature, but for now, we can only use variables with values that are accessible before the test starts recording. You can use custom JS variables in step edit on BugBug web app as we suggest in our documentation.

Search variables on the list

You can search for variables on the BugBug extension list by the variable name.

Local variables in web app UI

There is a new step form for local variables recorded from the tested source. You can edit this variable freely. The recorded variable can be found in the step list as a "set variable".

You can edit values such as the variable name or the correct item selector in the BugBug web application UI after you have finished recording.

Use a local variable

You can use local variables by selecting the "Insert variable" option during recording in the BugBug overlay. At the end of the recording session, the step using the local variable will be saved as "Type text" with the variable name used in the "value" field.

You can also add a local variable from the BugBug web app UI by selecting "add a new step" on the list and filling it all manually.

Select "Set variable" from the modal.

And fill in the requested inputs

Any recorded local variable can be used in the following steps by mentioning the local variable name in double curly brackets e.g. {{savedVariable}} in any text field like an assertion or custom selector. For more info check out what are variables.

Combine local and other variables in one JS custom variable

You can create a new variable using two different values in the JS form, which allows you to combine stored variables from the recording process and those that we provide as default global variables.

When you set variable from recording

You can use its name when creating a new custom JS variable. All stored variables are accessible in JS form by using the argument variables combined with the variable name.

When you use a new custom JS variable in step, BugBug will automatically combine the stored value with another variable that you want. These options allow you to combine values from all saved variables. You can call them as many times as you like.

To use a newly created variable, just put a variable name in double braces. After the first test run, you can find the calculated value of your variable from the previous test run in Step Details.

Do not use the local variable and its combination in steps before BugBug captures the wanted value. Otherwise, BugBug will return an undefined string instead of the desired local value.

Last updated