In this video we will look at the Custom Building Block feature in Leaptest.
When you work with automation, and design workflows, you will relatively often find the functionality or sequences in the flows that you want to use in more than one case. Instead of rebuilding or copying parts or the whole flows, we have the option of creating Custom Blocks. We can even define parameters to the Custom blocks and thereby build a library of useful, reusable, easy-maintainable building blocks.
Another positive side-effect of the custom building is, that you can have technical testers or people with a high domain knowledge to create the custom blocks, and have users with other profiles using them in the flows.
So in other word wrap up the functionality and knowledge into building blocks that are easier to use.
I’m gonna show a few examples of how to build custom blocks, how to use parameters for custom blocks and how to use custom blocks within other custom blocks.
I’ll use the calendar in Outlook for a couple of examples.
- Show calendar
In the calendar, you can press [CTRL+G]
- Press [CTRL+G]
This opens a dialog where you can specify a date and by pressing ENTER, the calendar will move to this date.
I will automate moving the calendar to days in the current month using Custom Building Blocks.
First, I’m gonna add a Generate Datetime building block, that will give us the current date.
- Add Generate Datetime
If I want to get the first date of the current month, I can use this block as input to a “Set Date” building block.
- Add Set Datetime
I’ll wire up the year and the month, and just specify “1” in the Day field. This will set the Date property to the first of the current month.
- Wire up Year and Month.
Next thing is to open the dialog in Outlook. I’ll add a Type Text building block and enter [CTRL+G]
- Add Type Text
- Enter [CTRL+G[
Then I’ll add yet another Type Text building block and enter the date followed by an [ENTER]. I’m using a Field to compose the text value.
- Add Type Text
- Wire Date to new FIELD.
- Add ‘FIELD1 [ENTER] in Text Value
So if I run the case now we should see the calendar change to the first of the month – in this case January first 2017.
- Run case
And it did. Let’s change it to 31 instead and see it move to the last day in the month.
- Change Day value to 31
- Run case.
It worked as well.
As we can see now, we are actually testing 2 different scenarios here:
– Go to first day of month and
– Go to last day of month.
This means we should be able to package up some of the functionality in a Custom building block.
Before doing this I will just add a Pass block.
- Add Pass
To create a Custom Building Block I can start by selecting one or more building blocks,
right-click and select “Create Customer building block”. I’ll do this with the Type Text blocks.
- Select Type Text blocks
- Right-click and select “Create Custom building block”.
What you can see is that the building blocks kind of collapsed into a smaller and simpler building block.
If I double-click, I get access to edit the custom building block.
- Double-click Custom building block to edit block.
When it opens up, it looks like a test case, but there are 2 different things here:
– The start and end of the building block is defined by Execution Input and Execution Output. This defines where the green connectors will be in the Custom Building Block.
– The blue Value Input is added instead of the date we had previously. The Value input now defines a parameter or property we can provide to the custom building block. I’ll just rename this to “Date” and Save.
I can find my Custom Building Block in the list of building blocks to the left. Here! I’ll just rename it to “Go to date”.
- Rename “New Custom Block” to “Go to date”.
When I go back into the test case I’ll just show how to add the newly created building block by deleting the existing and adding the new one.
- Delete existing and insert “Go to date” block.
- Wire up date to “Go to date” block.
So this should give us the exact same result as before, but we have added some of the functionality in a custom building block.
Let’s run it to see it work.
- Run case
And it seems to work.
The next step could be to create some blocks that will just go to the first day of the month or the last day of the month. This would make the test case consist of just one building block and is an example of using custom building blocks inside other customer building blocks. Let’s try to create a “Go to Last Day Of the Month” Custom building block.
I’ll start by selecting the date building blocks and create a custom building block from them.
- Select date blocks and create new custom block
I can see the “New Custom Block” in the list on the left and will rename it to “Go to last day of the month”.
- Rename “New Custom Block” to “Go to last day of month”
I will open it and add the “Go to Date” block inside of it, and wire up the date.
- Add “Go to Date” block
- Wire up date
Now we have a building block that will take the calendar to the last day of the month.
Back in the test case I can now clean it all up and end with one Custom BB and the Pass block.
- Delete, Add and wire up.
So nice and simple.
Let’s see it in action
- Run case.
It seems to work fine.
Another way of creating a custom building block is to select “New” in the list of building blocks. This will create an empty new building block. If you do it like this, remember to add the Execution Input and Output building blocks to define where you want the flow connectors to be.
This was a simple example of how to create custom building blocks, how to use parameters in custom building blocks and how to use custom building blocks inside other custom building blocks.