Welcome to the second part of the fourth lesson in desktop ui automation in LEAPWORK.
We have split lesson 4 into 2 parts to make it easier to consume the more advanced features
Covered in these lessons.
In this video we will continue to look at the strategy editor
and look at dynamic fields in the strategy editor.
Using dynamic field allow us to inject values into the conditions behind a strategy
and this way change what LEAPWORK will capture on-the-fly.
Imagine we wanted to verify that the search functionality in the demo application
was working correctly.
We could do this by searching for a list of search terms and for each search term
verify that we can find a specific contact person or company. This would
require that we changed the contact person we were looking for as part of the flow
which is a good example of how we can use dynamic fields.
We start out very simple by opening the demo application and logging in as usual.
Then we have a block inserting a search term, and a click on the "Go button".
If we run the flow, we can see that the search term "Crusoe" returned the contact
person "Robinson Crusoe".
To verify that this search worked correctly we add a Find UI element and capture the
company name from the first column. If the company name is found, we pass the test case.
To really verify the search we want to do multiple searches and we will use a Read Excel block to help us.
We add an Excel block before the Set Value block.
Then point to a local excel file, and click Define.
The excel sheet has 2 columns, Search Term and Company Name, and 3 data rows
containing matching pairs of search terms and company names.
We select all of it, check the "Use first row as header" and click save.
I want to use all 3 data rows in the excel sheet, so I expand the Excel block
and select "Iterate". As shown in a previous lesson this means the top connector
on the Excel block is executed for all data rows.
I connect the search term directly to the Set Value block,
so the value in the Excel sheet will be inserted in the search field for each data row.
So far - so good.
The next thing is to add the Company Name to the Find UI block
that is looking for the cell containing the Company Name.
In order to get this connected we have to add a dynamic field in the Strategy.
We open the strategy editor by clicking on the captured element and click "Edit element".
When we look at the first strategy we can see, that it selects the cell based on the
text inside the cell - in this case the company name.
This is exactly the value that we want to set for each of the data rows in the Excel sheet.
To achieve this we select and delete the hardcoded value and right-click in the field,
click "Insert token" and "Add new field". This inserts a token - or a dynamic field - in the condition.
When I click Save, this new field will be available on the building block - like this -
and allow us to easily connect the value from the Excel sheet.
When the test case runs it will go so fast, that it can be a bit hard to see what is going on,
so we add a Wait block for each search.
The last thing we need to remember is to move the Pass block to the "Completed" connector,
so it's not executed until all searches are successful.
let's run the entire flow-trat
*** Run the case
And it passed, meaning that all companies were found after the searches.
In this lesson we looked at how we can use dynamic fields in the strategy editor
which makes it very easy to drive the cases with external data.
We used the same building block to find different elements based on data from an Excel sheet.
This is the end of Lesson 4 part 2.