Looping through a hardcoded list

Hello i am trying to perform a looping through a list inside a desktop program.
I have managed to increase the result by 1 so it loops, but the problem its to tell the robot when to stop when it has hit end of the list.

What i am doing now its i have made a var to a selector in a index number from the list. I then assign + 1 to that variable for making it go down the list ( increase its index number by 1 )
But at the end of the list its crashing ( because its looking for example index 8 )
any ideas ?

Thanks in advance

1.Take a count of list items in a variable
2. take a Counter Variable Default it to 1.
3. After Each Transaction . Increment the counter by 1.
4.Do the Processing only When Counter < Count of List Items.


Hey @langsem

Haven’t you tried using the data scraping wizard to scrape the data in the grid so that it would be easier for you to travel through the list?

If not, it you are using the current approach you have, I think you can use a try catch activity here. So in the try part you will have your activities and at any point it goes to catch part, that means you have reached the end of the line. Something like that…

Have this already, but uipath cant tell how many items thats in the list. Its a java based desktop program

Tried with scraping but uipath could not find anything so did not work.

Yes was wondering about try catch. Use a each loop then a try catch inside it or ?

Have you installed the java runtime plugin?

If not, you should and then try again.
You can find it in Studio -> Home -> Tools

Before passing the Index everytime -

how about checking the value - say - (If Not NullorEmpty or If Not BlankorWhiteSpace)

If it has value- then only loop.


You can have the loop inside the try catch


the indexnumber its simply just to keep track of what row its on.

hm thanks gonna give it a shot

1 Like

How about using “Element Exists” activity to check if row with given index/selector exists.
And if not just leave the loop.


hm not quite sure what you mean

Use “Element Exists” activity with the same variable selector like you use in the “Get Value” activity. It will return true/false depending on validity of given selector. When you step out of the list it will retun false so you know you should terminate the loop. Clear?


oh but then it depends if its a bool, currently its a int else it can count the rows and move

…in another bool variable which you will use in an IF decision

IF “Element Exists” returns true THEN do your action ELSE exit loop…

so do. while element exist loop else out of loop and continue ?

so problem solved? :slight_smile:

hm not yet :stuck_out_tongue:

because struggling with something else also xD

Need to make sure it goes through all lines also and fill them. Just a sec will give you a much clearer picture of it

So i have attached 3 images. They are all examples of how the list CAN look.

The task its to perform the following.

  • Make sure the robot goes through EVERY row.
  • Exclude the once who are mark out
  • Make it know when the list ends to perform the next tasks
  • Perform actions on every line that needs to be added to a variable
  • Do a security check to make sure it has included all rows and not left anything behind.

The row has a indicator to show what row its on ( right now i have changed the index 1 out with a variable to be able to navigate down the tableview)

indicator of what row

I believe the looping question is answered, right?
I can see you know how to use GetValue activity so the rest is “piece of cake” for you :slight_smile:

Good luck!