DESKTOP UI AUTOMATION - Lesson 2: Automating forms and fields

  • How to automate the opening of a form
  • How to set values in different kind of fields
  • How to create a reusable component
  • How to read and compare numbers and text

Go to next video

You will learn:

  • How to automate the opening of a form
  • How to set values in different kind of fields
  • How to create a reusable component
  • How to read and compare numbers and text

Go to next video

In this second lesson you will learn how to open a form and set values in different kind of fields:

  • Text and number fields
  • Combo boxes
  • Radio buttons and Checkboxes
  • Multi select fields

We also briefly introduce the concept of reusable components, Custom Building Blocks, which is a way for easily reuse functionality across automation cases.

You will also learn how to find, read and compare numbers and text and branch you automation cases based on the results.

TRANSCRIPT

Hi

And welcome to the second training video for desktop ui automation in LEAPWORK

 

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 flow that can

be used across multiple flows.

 

In the first video lesson we demonstrated how to login

to the desktop demo application that ships with LEAPWORK.

 

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 subflow". This wraps the selected building blocks into a new subflow

which you can freely re-use across your automation flows.

 

If we double-click the subflow block it will open up in a separate tab

and we can see the building blocks making up the flow.

I can rename the subflow to make it easier to understand what task it can be used for.

We will dig much more into sub flows in a later lesson

and among other things see how we can parameterise and drive external data into the sub flow.

 

——

 

After a succesfull 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” 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" to start the search.

We capture the button, and run the flow.

 

As we can see, the subflow 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.

 

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 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.

 

*** Run flow from here

 

And the form is updated.

 

For radio buttons it is 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,

And 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 flow 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 I want here is to check if the value is greater than 10000 and if it is, simply

insert the value 20000. If its not I will apply the value 5000 to the field.

 

To read the value from the field I will use a Get UI element number, 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". Also, I will configure the Comparison type as "Number". 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 LEAPWORK 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.

 

*** Run flow from here

 

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 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 inputed, 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 flow from the start.

 

*** RUN CASE

 

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, reusable subflow 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, dropdowns etc. We also

introduced the blue connectors which are used for transferring values between building blocks.