Select Item unable to select based on a List<String> index?

I’m trying to select a list item, based on a string from a List variable.

The “Select Item” control works fine if I free-type the text into the control, but it breaks with the error below if I try and use a variable to work from instead.

The issue is that the elements that can be selected constantly change, so I need a way to select the 1st, 2nd, 3rd, etc, element in the list for every job I run. I have made a list of Strings, but don’t seem to be able to select elements based on that list…

Any help would be appreciated :slight_smile:



Source: Select Item ‘list’ (Select Item ‘list’)

Message: Error HRESULT E_FAIL has been returned from a call to a COM component.

Exception Type: UiPath.Core.ElementOperationException

RemoteException wrapping UiPath.Core.ElementOperationException: Error HRESULT E_FAIL has been returned from a call to a COM component. —> RemoteException wrapping System.Runtime.InteropServices.COMException: Error HRESULT E_FAIL has been returned from a call to a COM component.
at UiPath.UiNodeClass.Set(String bstrAttr, Object vValue)
at UiPath.Core.UiElement.Set(String attribute, Object value)
— End of inner exception stack trace —
at UiPath.Core.Activities.ScopeActivity.OnFaulted(NativeActivityFaultContext faultContext, Exception propagatedException, ActivityInstance propagatedFrom)
at System.Activities.Runtime.FaultCallbackWrapper.Invoke(NativeActivityFaultContext faultContext, Exception propagatedException, ActivityInstance propagatedFrom)
at System.Activities.Runtime.FaultCallbackWrapper.FaultWorkItem.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)


Welcome to the uipath community.

Make sure it should be case sensitive and also check spaces before and after the string.

I’ve just checked and it seems that the List items have a line break at the end of the string which may be causing the problem. There is also a blank space after each item in the list I want to select from. Is there an easy way to get rid of the line break?

Unfortunately the line break seems to have survived ? (When I’m appending the “_” to the variable, it’s just so I can see clearly where the line break is in the output window… I’m not going to want the _ in the long run…

Or… as possibly a better way… is there a way to get an array of strings that the list has available to select from, and then use that? I currently use the “get text”, and then split the lines to make a List but I wonder if it’s possible to just dynamically ask the selection list what options are available (and then select one of those). I will, one by one, want to select every item in the list during the process of the automation…

Can you try: tProduct.Replace(Environment.NewLine, “”)

Can you check if maybe the use of wildcard * can help?
Select Item Activity tProduct + “*”

If that is not working a reliable approach is

  • to retrieve the listitem via Find children activity
  • filter to the item of interest by eg. item.Get(“text”).Contains("…
  • Use this found item within a click activity

Thanks. How do I workout what the ‘attribute’ option should be though? Also, is it possible to then select an option using some sort of index, as there may be multiple options in the resulting list that are called the same thing… ? Thanks

For having a clear information what type of select box / drop down You have to automate please open standalone UiExplorer, indicate to the screen and post a screenshot of expandend visual tree and Properties for the combo box. With this we can find out the type of box and can help you faster

Attached below :slight_smile:


Perfect May I ask you to expand the list node to all listitems and show for a listitem the properties. Thanks

As below

Cool -
last screenshot you can check what value can be used within the select item activity - Property Text
You can inspect this for all list entries, especially for the failing/paining one

So if your issue is not solved by removing RowNotNullFieldsCount linebreak (Did you tried my Stetment with Environment.NewLine) then you try following approach:

Use a find children activity:

  • let point the selector to list
  • configure the filter to the list items

You will get a list with all listitems
From this you can identify the selectitem of interest by the text attribute (e.g. with a LINQ statement item.Get(“text”).toString.StartsWith(“Minimum Invoice”)…

This found item you can use within a click activity and you can click on this.

Give a try and let us know if its working

Sorry, we might have gone a little quick for me there (still getting used to UiPath).

I’ve made a Find Children activity and pointed it to the list view. I’ve asked it to save the output in a new variable - tChildList
However, if I try and parse the individual elements of the tChildList I can’t use the item.Get(“text”).toString command (it just gives the blue (!) error). If I iterate through them I can print each one to the console using ToString - but obviously doesn’ tell me much yet (other than the Find Children activity did find children…).


Use following in the writeline

Nope. That throws an error when I try that?

Check object type for for each and change to UiElement if required

1 Like

Ok, changing the TypeArgument to UiElement means each item can be processed with the Get(“text”).toString command
However, I can’t see how to tell the Mouse Click command to click the item in the list ? I can use the Click Text command to search the list for a certain string, and click that - but that obviously won’t work if I have more than 1 item in the list called the same thing (which can easily happen).

Use a click activity and pass the item to it

then the click will be executed with this particular item

1 Like

Thank you - that worked! :smiley::star_struck:

Hi @adam.williamson

thats great. :+1: You have done very good job with the screen shots. This helped me a lot for guidance. Feel free to flag it as solution, so others can benefit from it.