Find Children and Index of each child

I’m using the find children activity to get all the rows from a table. The xml identifier for the rows are generating random numbers, so the rows are numbered variably every time it runs.

I want to search for the row that contains the phone number I’m looking for, then I want to get the next row, because that’s the one I’m actually looking for. then I need to check if that row contains a certain string as well. Something like,

 if ( row.get("aaname").Contains(phoneNum)  )  {
      
        currentRow= row.index()
        nextRow = row.next()

 }

I see that on the find children activity under properties there is an output for the index. Can I use that within the find children activity body? Or is that out of scope? Thanks for the help.

Hi @HsDev

I hope I will be able to help you with this, can I request for some real time example (preferably with a sample table from a publicly accessible website) so that I can stitch a better solution rather that just giving it in the air…

Regards :slight_smile:

1 Like

You could really use any list I believe. I think you can try with this site. This is an index. It’s a rather large set of data, I would probably limit it to the first 10 rows or something. A to Z Index

This is just a college website.

I agree to @Raghavendraprasad some more details would be helpfully. Especially " I see that on the find children activity under properties there is an output for the index" is unclear

However maybe following is helping you:
searchterm is a string variable with the value of your phone no
finding the index in the children list can be done with an assign activity:
Childrens.ToList.FindIndex(Function ( r ) r.Get(“aaname”).toString.Contains(searchterm)).ToString
then take next element from the list

if index is an attribute of the UiElement then you can sort the childrens in advance:
Assign Activity: Datatype: List Sample Statement:
Childrens.ToList.Sort(Function ( r ) r.Get(“aaname”).toString.Length)

In my sample Statement I sortet on the text length of aaname

2 Likes

I’m sorry, What I meant was in the for each activity, when you are traversing through the children, in the properties panel of Uipath there is an output labeled index. I’m just wondering how that could be utilized in my case.

Can you please post a screen shot of this: Uiexplorer for a row element, that you areretrieving with find children. Please expand also the Uirproperties. Thanks

Index

This is a for each activity, you can see the output says index. The zero-based index of the current element in the collection.

What I am trying to scrape is a very simple list of phone numbers that looks like this:

 Telephone:801-555-6666
 Telephone:801-555-6622
 Access:4651325748abc123
 Telephone:801-666-1234
 Telephone:801-666-5555
 Access:123654123asdf

So this is what a given random list will look like, it will have telephone and access in any random order.
The automation searches for the phone number I’m looking for in the rows.

Once the number is found, I want to check and see if it says access on the row right below that one. Access HAS to be on the row right beneath the telephone number I’m currently working with. Once it finds the telephone number I’m looking for, I want it to only check the row right below it to see if it says access.

So I just need a way to get the next row, but there aren’t any good identifiers for that with what I’m working on. So I’m grabbing ALL of the rows, searching through each one for the number, once I find the number I want to go to the next row.

Ok but should be solved with my statement or can be implemented in the classical style with for each acitvity.

first of all lets clear the index variable from for each:

  • a variable defined as Index starts by 0 and is increased by 1 for each iteration
  • it can be used e.g. access, count … purpose

lets assume or repeat the requirements:

  • all rows are in the list outcoming from find children
  • the row of interest is direct the next element in the list of the row with particular phone no

ChildrensVariableFromFindChildren.ToList.FindIndex(Function ( r ) r.Get(“aaname”).toString.Contains(searchterm)).ToString

gives you the index in the children list for particuar phone no
row of interest is accesable in the list by found index plus 1

in the classical for each style can it be done as well, but requires some steps more

IF the case is that you are interested on the next ACCESS row, that is not directly followed by the phone no row, than use the found index of phone row as starting index and search for the next following ACCESS row