Welcome to the second training video for desktop ui automation in Leaptest.
In this video we will look more at how to work with forms in desktop applications and show examples of how to operate with the individual types of fields and controls.
We will start by showing how to create a custom, reusable building block that can be used across multiple test cases. In the first video lesson we demonstrated how to login to the desktop demo application that ships with Leaptest. The login process will most likely be part of multiple test cases, so it’s a good candidate for a reusable component.
We simply select the building blocks that contains the functionality we want to re-use, right-click and click “Create custom building block”. This wraps the selected building blocks into one building block that can be used across test cases. If we double-click the custom building block it will open up in a separate tab and we can see the building blocks making up the flow. I can rename the block to make it easier to understand what the custom block can be used for. We will dig much more into custom building blocks in a later lesson and see how we can add parameters to the custom building block.
After a successful login, we will do a search for a contact person and change some of the personal data for this person.
To search for a contact person, we start by using a “Set Value” block to insert a search term into the search field. We capture the field and specify “Robinson” as the value to insert. We then use a Click block to click on the “Go” button to start the search. We capture the button, and run the case.
(Automation case runs)
As we can see, the custom, reusable block was used for the login, and the search matched 1 contact person.
To open the detail window for the found contact person, we add a Click block, and capture the first column. We expand the building block to change the “Button” property from “Left” to “Double left”. This means the block will double-click on the first column and thereby open the details window for the contact person. Let’s run the last block to open the details view for the contact.
(Automation case runs)
The form contains several different field types, and we will go through most of them one-by-one.
The first one we will look at is to set a simple value in a text field. We have seen this done, when we searched for the contact person. We add a Set Value block, capture the “LastName” field and insert the new value. In this case I will change the value to “Cruz” instead of “Crusoe”.
The next interesting field is the country selector. This is a Combobox – or dropdown – containing a long list of countries. We add a Select UI Element block to handle the combobox and capture the country list. Once captured we can use the Filter section to specify, what value in the list we want selected. In the Filter section we can select different options for the filter, and we can specify the value used in the filter. In this case we choose “Equal” and set the value to “Denmark”. This means the block will search for a precise match of the word “Denmark” in the list of countries.
Let’s just run the last 2 blocks to see the changes occur for the “LastName” and the country fields.
(Autmation case runs)
And the form is updated.
For radio buttons it’s a simple clicking operation, so we add a Click UI block and select another gender by simply capturing the option we want. Setting the industries is an example of selecting multiple values for the same field. We again use the “Select UI Element” block, but this time we choose the “Add to selection” method – not the default “Select” method.
I then capture the option I want to add, in this case “Accounting”. To select the second option in this field, I save a little time by simply copying and pasting the existing block and capture the second value in the pasted block. We now have 2 values selected in this field.
Let’s just run these 3 last blocks.
*** Run case from here
We can see the gender changed and that we have 2 selected industries.
The “Win chance” field and the “Status” field is the same as setting a field value and clicking a button, so we will look a bit more at the “Amount” field. What we want here is to check if the value is greater than 10000 and if it is, simply insert the value 20000. If its not we will apply the value 5000 to the field.
To read the value from the field I will use a Get UI element number block, and capture the “Amount” field. To inspect the number I will add a Compare block. You can use this block to compare text, numbers, dates etc. and then branch your flow depending on the result. The first input to the compare block is the number from the “Amount” field, and we can simply drag a blue connector from the “Number found” on the Get UI Element Number block directly to the blue connector on the Compare block. The blue connectors are used for moving data values between the blocks, just like the green connectors drives the execution of the flow.
I will add the second value in the Compare block manually – 10.000. If I expand the Compare block we can set the comparison method. In this case I will change it to “Greater than”. This means that if the value in the “Amount” field is larger the 10000,then the connector at the top of the compare block will trigger. If it’s lower, then the “Incorrect” connector is triggered. This is an example of how you can branch your flow based on a value. A lot of building blocks in Leaptest offers this opportunity in various scenarios.
I will use a Set Value in both cases, and for the top one add the value 20000 and 5000 for the lower.
Let’s try to run the last blocks.
(Automation case runs)
As we can see the values was changed to 20000.
Last action is to save the changes by clicking on the Save button. I add a Click UI block and capture the Save button. I will connect this “Save clicking” from both of the previous blocks. This is an example of converging 2 branches back into one.
After clicking Save we can see the updated data in the overview and do a final assert on one or more of the fields. We could read the changed “LastName” using a Get UI Element Text and compare this to the value inputted, by simply dragging a blue connector from the block where we added the value. If these values match, then we will pass the test case.
Let’s run the entire test case from the start.
(automation case runs)
It ended in status passed and in the video we can see that all the values was changed correctly.
In this video we started by creating a simple custom, reusable building block encapsulating the login functionality. We went through the contact details form and showed examples of how to read and write values to the individual fields, drop-downs etc. We also introduced the blue connectors which are used for transferring values between building blocks.