▶️ You can also watch our tutorial on how to execute subscripts on our Youtube channel.
When a script is long enough, you can reduce it by creating a subscript.
Using subscripts will allow you to factorise the common functions of your tests, such as test data creation, login, regularly used operations, etc.
An additional advantage is that you can pass values as parameters to your subscripts, making your sub-scripts scalable and generic.
Finally, if you manage the granularity of your scripts and subscripts correctly, this will also enable you to have test scripts that are not too long, that are readable and easy to maintain.
Create a subscript
The subscript action has been designed to be scalable.
To create a subscript, select all the actions in your script that interest you. You can do so by pressing the CTRL key.
Then, drag and drop your actions on your “Subscripts” folder in your explorer.
Your subscript will appear in your project explorer.
It will also appear in the form of a subscript call action in the script from which the actions were extracted if you cross the “Insert subscript action” box
Open a subscript
There are different ways of opening subscripts, even if they have different typologies such as multiple iterations, blocked, random, etc…
When you want to open the child script with the link to the parent, click on the "Execute action" button to open your subscript and execute it.
If your subscript contains parameters, they will appear in a small window displaying these parameters for a few moments during the execution.
To make these parameters reappear, click on the "\x" button at the bottom right of the screen.
A subscript with only one iteration
In a subscript with a single iteration, if you click on the "Execute return values" button, it will return to the parent script.
The elements will no longer appear in your subscript but the parameters will remain in the subscript.
It is also possible to stop the link to the parent, so as not to return to the parent once the subscript has finished executing and to continue executing the script.
If you don't want this to happen, and simply run the subscript, simply click on the cross icon to cancel the return action.
A subscript with several iterations
In a subscript with several iterations, the number of iterations will appear on the subscript call action line
As well as at the bottom right of the execution of your subscript.
If you click on the arrow once, it will move on to the next iteration with its parameters, and so on if you click on the arrow again.
At the end of these iterations, as in the previous case, this button will be used to return to the parent.
You can also execute your iterations one after the other.
To do this, click on your editor's "Play" button in the channel management menu instead of executing the actions one after the other.
This corresponds more to a mode of execution, compared with previous cases which corresponded more to creation or maintenance.