WEB AUTOMATION - Lesson 2: Sub-flows and re-usability

  • How to reuse parts of an automation flow elsewhere by creating sub-flows.
  • How to add parameters to a sub-flow to make them even more reusable.
  • How to use the blue connectors in LEAPWORK for transferring values between building blocks.
Go to next video.

You will learn:

  • How to reuse parts of an automation flow elsewhere by creating sub-flows.
  • How to add parameters to a sub-flow to make them even more reusable.
  • How to use the blue connectors in LEAPWORK for transferring values between building blocks.
Go to next video.

TRANSCRIPT

Welcome to the second lesson in web automation with LEAPWORK.

In the first lesson we looked at the basics of building a flow,
and we used a simple login form as the example.

In this lesson we will look at how we can reuse parts of the flow
by creating reusable sub flows. And we will also look at how to parameterize
the sub flows to make them even more reusable.

We will continue with the login form and the flow we built in lesson 1.

Performing a login could be part of many web automation flows.
In some cases all flows will include a login at the very start of the flow,
so the login process is typically a good candidate for a reusable sub flow.

To create a sub flow you simply select the building blocks you want to make into a reusable component,
right-click
and select "Create sub flow".

We name it "Login" and press Save.
We now see that all the selected building blocks are wrapped up into one new building block named Login.
This is the sub flow,
and we can find it in the list of building blocks under the category "Custom",
or navigate to it in the treeview.

A sub flow is like a custom block that we create from existing building blocks,
and it can be reused in as many flows as we want.

If you make changes to a sub flow,
the changes are automatically reflected in the flows that includes the sub flow.
So from a maintenance point-of-view creating sub flows is a good idea.

If we double click the Sub flow it opens up,
and we can refind the selected building blocks.

They are now surrounded by some special building blocks - execution input and output.
These blocks define how the sub flow can connect to other building blocks,
so they basically define the green connectors on the sub flow.

This also mean that you can design your sub flow to have multiple output connectors,
if the flow branches inside the sub flow.

Another very useful feature with sub flows is parameterization.
Instead of hard coding the values inside the sub flow,
we can define input parameters to the sub flow,
allowing the flow uthat includes the sub flow,
to provide the actual values.

Adding a parameter is very easy.
Simply add a Value Input building block, and double click on the header to change the name.
In this case we will use it to parameterize the email address,
so we pull the blue connector from the parameter block to the
text value property on the Type Web Text block.

The blue connectors are used for transferring values and properties between building blocks,
so adding the parameter block to the Type Web Text means that any values added as parameter
will be inserted in the email-field.

We do the same with the password field:
- Adding a Value input and renaming it.
- Then connecting it to the text value property

When we save and confirm the custom block and move back into the flow,
we can see that the custom block now has 2 new input parameters defined: email and password.

To specify the e-mail address we use a Set Text building block and connect to the Email property.
We do the same with the password.
In the next lesson we will look at how use external datasources, like Excel or databases,
to input the data to the sub flow.

We are ready to run the login flow - this time using a reusable, parameterized custom block.

*** Run the flow

And the flow ended in status Passed as expected.

In this lesson we have looked at how you can reuse parts of a flow in other flows
by creating sub flows. We looked at how we can add parameters to a sub flow to make them even more reusable,
and we introduced the the blue connectors which are used to transfer values between building blocks.