Dynamic selector in a changing list

Hey,

I’m having some issues with a Ui Automation project. The process-step takes a person (date of birth) as a variable and works in a long list of bookings. The person in the queue-item will have 1-n rows in this list and I have no way to filter out just the rows I need. When the automation runs additional rows will be added to the list and this breaks my selectors. What happens in for each new row I’m adding it’s making the automation select 1 item above the inteded target.

How I create my selectors:
The list-items return a tab-separated string:

virtualname='value1      value2       value3'`

What I have done is I use a Find Children activity on the <role='list'> UiElement with a filter of:

virtualname='*{{date_of_birth}}*{{specific_status}}*'

After also adding a idx-number to each UiElement I store these selectors in a List<UiElement> variable.

At this point in the code, these UiElements works perfectly as selectors to select the rows I want to work with.

Problem
Next I iterate through this List<UiElement> with workflow which takes a UiElement as an in-argument.

The first iteration works fine. But this adds another row in the list, the new row is squeezed in next to the row I worked with, but with a different {{specific_status}}.

In the second iteration the selector breaks, instead clicking the list-item above the intended target. Even if it doesnt match the selector at all. It can be a completely different date-of-birth + status combo.

I can understand what happens, the automation expects the row I want to select to be at a certain spot in the list but everything has been “pushed down” one step.

But what I don’t understand is why this happens. I figured the selector was dynamic, it’s as if it was cached the position of the selector when it was generated, not checking the actual state of the application when I’m telling it to click.

ANY IDEAS? :slight_smile:

1 Like

@OskarH

I would suggest first try creating a selector with some reliable attributes which would work on each list item using idx… and as you already know that the idx would change when a new item is added then instead of incrementing the idx by 1 increment it be 2 so that it again clicks on the same element you need

I know this is a very high level explanation that I have given, if you can provide some screenshots of how uilooks and some selectors, might I can give more information on how to proceed

but the end idea remains same to identify the element you have to find a logic on how the idx changes when new dynamic elements are added and create a logic aruoud that

Hope this helps

cheers

I understand what you mean, I will attempt something in those lines, thanks.

The strange this is:
I tried to put a Breakpoint in the execution at the time of the selector failing. From there I extracted the selector from the Locals-panel. If I then Stop the execution and try to use that selector in just a click-activity it chooses the right element.

I asked ChatGPT to create some comparable data of how the list looks like:

Time Date of Birth Customer Name Section Status Hair Dresser
09:00 AM 01/01/1990 John Smith Haircut Confirmed Maria
10:30 AM 05/12/1985 Lisa Johnson Haircut Confirmed Mark
11:45 AM 02/14/1978 Sarah Lee Haircut Confirmed Maria
01:15 PM 08/20/1992 Michael Chen Haircut Cancelled Lisa
02:30 PM 03/22/1989 Emily Kim Color Confirmed Lisa
03:45 PM 11/02/1983 Jason Lee Color Confirmed Mark
05:00 PM 07/14/1975 Adam Green Perm Confirmed Maria
09:00 AM 01/01/1990 John Smith Color Confirmed Maria
10:30 AM 05/12/1985 Lisa Johnson Perm Confirmed Mark
11:45 AM 02/14/1978 Sarah Lee Perm Cancelled Maria

Selector for the 8:th row would look like this:

<wnd app='xxx.exe' cls='XXX' title='XXX*' />
<wnd ctrlid='XXX' />
<ctrl name='Bookings' role='list' />
<ctrl role='list item' virtualname='*01/01/1990*Confirmed*' idx='2'/>
2 Likes

@OskarH

I would suggest not to use any name in the variable…because if you include names/time which uniques identifies few rows only then the idx will change as per names…our aim is to get each row separately…

So use some generic one like

<ctrl role='list item' class='abc' tablecolumn='1' idx='2'/> this can be the selector for first row and first column in the given table

This is just an illustration original selector might differ.

And by just changing the idx we can loop through each row then use get attribute or get text activity to get the value in that row and then process accordingly…

1 Like