Parameterized flows

Flows as functions

Looking to scope variables to a single flow, or reuse a flow later in the test but with different values? Adding flow parameters to a new or existing flow gives you the tools to do that and more.

If you're familiar with some common programming languages, you can think of this feature as allowing you to use flows as functions that accept inputs as parameters, which are then used inside that one instance of the flow. All instances of the flow have the same variables being used inside of the flow, but each instance of the flow may have different inputs. This, for example, would let you use a parameterized Search flow to search for an address you created earlier in the test, a phone number, or someone's name.

📘

What's a flow?

Common sequences of steps can be bundled into reusable flows, which can then be inserted into any test. Flows are always up to date; any changes to the base flow will automatically be propagated to all tests containing that flow. A test can be composed with any number of primary (non-reusable) steps and reusable flows. You can also insert the same flow multiple times within a test.

Learn more on our page dedicated to reusable flows.

Starting out with parameterized flows

New flows

For this example, we'll start with creating a new parameterized flow. If you're looking to convert an existing flow to use parameters, skip down below.

Adding a parameterized flow

Open a test where you'd like to start using parameterized flows. If you're starting from scratch, you'll want to start by adding a flow. Once you've selected New flow, you'll be prompted to give your flow a name. Switch over to the Parameters tab in that window and select Manage parameters.

594

Where to find the Manage parameters, after giving your flow a name.

Here's where you'll create the parameters that will be used within the flow. Give your parameters a name that you'd like to use later and give them a default value, which can be a static value like Boston or 11. Once you've added the parameters that you want to use in the flow, save the changes.

You'll see that all of the variables you've named have prepended flow. to the beginning of their name, such as flow.searchVar. This is how you'll be able to recognize and use them later.

594

Your new parameter with the default value in gray on the right.

Using override inputs

Before clicking OK and exiting the flow, add the overrides that you'd like to use for this test. You can think of these as the inputs for your flow. It's fine if you don't have any now, you can always add them later and your flow will use the defaults in the meantime. If you do have ones to add, just be sure to use the {{@varName}} syntax to reference another variable. You can also enter a static string or number, as well as create a random value using {{digit:10}} or {{alnum:3}}, just replace the number with the number of digits or characters you'd like to randomize. Once you're done, click OK to save the changes.

🚧

Using a variable override

If you're using a variable as an override, be sure that the variable is created or initialized before the start of the flow. Otherwise, the step that uses the variable will fail.

📘

Converting existing flows

You can easily convert an existing flow to use parameters by going to the "Parameters" tab and adding new parameters there via the "Manage Parameters" button shown in the image above.

Note: Just be sure to replace any variables you want to parameterize in the steps within the flow with your newly added parameters.

Importing a parameterized flow

When importing a parameterized flow, you'll be prompted immediately to add any overrides you'd like to that instance of the flow. As overrides are scoped to the instance of the flow, this won't impact other uses of the flow in different tests or even the same test.

Export parameters

If you'd like to use a flow parameter outside of a flow, create a new variable within the flow that uses a flow parameter as its value. For example, if you want to use the variable flow.searchResult outside of the flow, you'd want to create a new variable named mySearchResult and set the value equal to {{@flow.searchResult}}.

🚧

Be careful using the name of a variable already used earlier in the test, as assigning a new value to that variable is the same as overwriting the original variable.

Removing flow parameters

If you'd like to remove flow parameters for any reason, you'll need to edit any instance of the flow, click Manage Parameters, and remove the parameters. Once this is done, you must either revert the flow version to a version before you started using parameters or change the steps in the flow to use regular variables instead of flow parameters. Failure to do this will likely cause the flow and your tests to reference undefined variables, which can cause unwanted failures.

🚧

Renaming flow parameters

When renaming a flow parameter, you'll need to update the steps that reference it within the flow. Your steps will not automatically start using the new name.

Additional FAQs

Can I modify a flow parameter within the flow itself?

You can only modify the flow parameters when editing the test and flow instance. We do not currently support the ability to modify the flow parameter while the test is running, such as assigning it to a new value in the flow with a "Create variable" step.

Can I use a flow parameter to loop?

No, you currently cannot loop based on a flow parameter. Loops function similarly to flow parameters, however, and it is simple to set a flow to loop based on a variable created earlier in the test by using the standard {{@varName}} format.

If I update my overrides on one instance of the flow, will it update the other instances?

No, only modifying the parameter names and default values will impact other instances of the flow. Modifying the override or inputs will not alter other instances of the same flow, even within the same test.