Find children. How can I check that nothing found?

Hi, all !
I use ‘Find children’ activity and find specific cell elements. When elements exist it’s OK and activity set data to ‘rows’ variable. But when elements absent ‘Find children’ activity return null in ‘rows’ variable. How can I handle null for my ‘rows’ variable?
I tried to use ‘If’ activity and type “rows.IsNullOrEmpty(System.Collections.Generic.IEnumerable<UiPath.Core.UiElement>)” in Condition section, but error “Expression expected” arrived.

try using rows.count=0 as condition.

I tried but exception System.Argment.NullException appeared.

Can you check in condition if the collection of UiElelment is blank? It means If returnedUiCollection.Count=0?

Sorry, but I don’t understand how check collection of UiElelment.
I have variable ‘rows’ and it has type System.Collections.Generic.IEnumerable<UiPath.Core.UiElement>.
For “Find Children” activity in property “Children” set this variable ‘rows’.

If run debug I see that rows equals null. How can I work with this variable if it throws System.Argment.NullException exception? May be I use ‘Find children’ incorrect?

try rows.count() instead

rows.count() throws System.Argment.NullException exception

looks like you are not getting any results then, to be sure, directly after the find children activity put a write line in:


what is the result?

if it is zero, then reset the filter to "<webctrl />"and see how many results are being picked up before filtering. if it is greater than zero, then your filter is the issue and nothing is meeting your criteria.

It throws exception too.

But I found the solution. I have to use isNothing(rows) in condition.

@ronanpeter, @Tiberiu_Niculescu, @qwerty456 Thank you for replies!


Congratulation, I just want to write this. :slight_smile: And I found also second solution: Just intialize the IEnumrable collection as List. That means in your case, set deafult value to rows variable New List(Of UiEelement).
Hope somenoe helps in the future :slight_smile:

1 Like

@qwerty456, your solution also works. Thanks!

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