How to get item in a for each loop? And compare that value to a current value?

I created a while loop to get a List of dates and stored that into a variable called Dates (List type DateTime).

I am trying to get the status for each date in my List, and compare the status to the current status. If the status is different for the current status, then mark it as an exception.

How would I do this? When I spy on the status element for each date, only the idx value changes.

1 Like

I don’t get this buddy

Kindly elaborate a bit more in this process pls

Cheers @happygal321


Im trying to check the status for each of the dates in my List Variable, and compare each status to the current status. I created a variable for current status by using the ‘Get Text’ activity and the variable is called Current.

For each item in Date, Get the corresponding status and compare with the current status. When I get the corresponding status, I used the ‘Get Text’ activity and indicated the first Status. The selector shows as “ctrl name=‘old_status’ role= ‘text’ idx=‘1’.”

But when i loop through all my dates, the status is showing as 1, even if some are 2’s. When i spy/highlight each status element, only the idx value changes. for example, the second date 201906, the selector is “ctrl name=‘old_status’ role= ‘text’ idx=‘2’”

I think my loop is not identifying the correct status for each date, and is only displaying the value of the 1st status,.

1 Like

Hope these steps could help you resolve this
— use a for each loop and pass the ist variables so input and change the type argument as DateTime in the property panel of for each loop activity and the reason why we mention as DateTime as type argument as each element in the list is of type DateTime
—Now inside the loop use a get text activity and use the same selector you have by now but with small change in the selector
“ ctrl name=‘old_status’ role= ‘text’ **idx=‘ “+counter.ToString+” ’ **“
Where counter is a int32 variable defined in the variable panel with default value of 1
—Keep in mind that don’t mention the variable with selector in selector editor instead of that copy the whole selector from selector editor put that within double quotes and mention this change with six attribute and pass it as string value to the selector property and the reason is selector editor won’t take the variables been passed to them rather if we send mention the variable and pass the selector as string between double quotes to the selector property then it will take them
—now next to this get text activity we need to increment the value of the counter with a assign activity like this
counter = counter + 1
—now use a if condition like this
If true will go for THEN part where we can use any activity we want or will go to ELSE part where can use a Throw exception activity to throw an exception so that the process will stop unless placed within a try catch activity

Hope this would help you
Kindly try this and let know for any queries or clarification
Cheers @happygal321

@Palaniyappan I edited the selector to include this, but it says “The Selector is not valid.”

My Selector is:

<wnd app = ‘test.exe’ cls=‘FNWND*’ / >
<ctrl name= ‘old_status’ role=‘text’ **idx=’ “counter.ToString+” ’ ** / >

pass this as string to the selector property
“<wnd app = ‘test.exe’ cls=‘FNWND*’ / >
<ctrl name= ‘old_status’ role=‘text’ **idx=’ “ + counter.ToString + ” ’ ** / >”

Cheers @happygal321

@Palaniyappan thanks

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.