Groups Parameters
Learn how to pass parameters to groups to improve reuse
Groups can include parameters, which are variables that can be used to pass information into a test step. By using parameters in a test, you can test different scenarios without knowing the information in advance. For example, when testing a login scenario, you can use parameters to switch between various username and password options, such as a registered _user versus a _guest user, etc.
If the group is shared between multiple tests, the group parameters will be also available across all the tests and you will only need to set specific values for these parameters.
You can add parameters to groups the exact same way you define parameters in the Step Properties Panel Parameters. First you will need to create a group, add parameters, assign these parameters to specific steps in the group and then add values to these parameters.
Parameter Scope
The scope of the defined parameter is within the group itself. This means that all the steps within the group can use the parameter. If its a shared group, the parameter can be shared across multiple tests that use the shared group.
Parameters created in groups are considered as "local scope". Parameters can be overridden by the same scope or a “smaller” scope. For example, a "test scope" parameter can be overridden by either another test scope or local scope parameter with the same name.
Shared parameters
If its a shared group/step, the JS/HTML parameters themselves will be shared across tests, but not their inner values, so the parameters can be reused in other tests with other values. Deleting a parameter from a shared step or group will have a cascading effect on all instances of that step or group, and this action cannot be undone.
Adding Parameters to a Group
To add parameters to a group:
- Create a group by following the instructions in the Groups section. In this example we will create a "Login group" that includes typical login steps.
- Click the group's Show Properties icon ().
- Click the + icon next to Params and then click JS.
- Enter a name for the first parameter, by clicking the Edit icon and then replacing the "param" text with the new name.
5. Enter a value in the field below the parameter name. If the value is a constant string value use ' ' around it. For example, 'guest'. This value will be available in this test only (i.e., the value will not be shared across tests.
- Repeat steps 4-5 to add additional parameters.
- Click Save and then OK.
Assigning Parameters to Steps in a Group
To assign parameters to steps in a group:
- Double-click the group step to view the group's internal steps.
Note
If it’s a shared group you will need to confirm that the changes will be applied on all related tests.
- Select the relevant step to assign the parameter and click the Show Properties icon (). For example, we will select the "Set text" step to assign the
username
parameter. - In the Properties panel, in the Text to assign field, replace the current static value to the parameter's name (e.g. username).
- Repeat steps 1-3 to assign additional parameters to steps. For example, we will assign the password parameter to the Set password step.
- Click Save and OK.
That's it!
We have created a login group with parameters, that can be easily reused in other tests with a different set of values without the need to change the group itself.
Reusing the Group with the Parameters
To reuse the group with parameters:
- Add the group to another test by following the instructions in the Reusing a Group section. In this group, the parameters are already assigned to the relevant steps, but the values are empty.
- Click the group's Show Properties icon ().
Notice that the parameters exist, but the values are not assigned.
- Click the Assign Nowdrop-down menu and select JS.
- In the empty field, enter the relevant value. If the value is a constant string value use ' ' around it.
- Repeat steps 3-4 for additional parameters.
- Click Save and OK.
Updated about 1 year ago