How to select item containing certain text?



I want to use the “select item” activity to select one item.

The items are: Item1,ItemTwo and Item3.

I would like to know if there is a fast way to select one of them according to a variable that contains part of the name of the item.

Example: the string value is “Two”, so as “ItemTwo” contains “Two”, I want the robot to select the second item.

How could I do it?



yes you can.
Refer below link for writing dynamic selectors.
We can use 2 methods to make selectors dynamic:

  1. Adding wildcards characters in selectors
    Asterisk (*) – replaces one or more characters
    Question mark (?) – replaces a single character

for more info can use this link :

2.Adding variables in selectors : we can keep the dynamic part of the selector as variable


Supposedly, you can use a Wildcard for the Select item activity.
So in the Item property, you would place the string like this: "*"+variable+"*"

If the wildcard doesn’t work though, you can also get all the items in the dropdown using a Get Attribute activity, using items as the attribute. I have used this method in the past. So, essentially, you get the items stored in an array variable from the Get Attribute activity. Then find or filter it based on your variable.
One method to filter your array would be like this: arrayvar.Where(Function(x) x.ToUpper.Contains(variable.ToUpper) )(0)
and use that filtered item into the Item property.

I hope one of these will work for you.




Thank you very much

Please, could you provide the example in xaml of the second method?

Thank you.




That’s assuming “items” is the right attribute. That’s what I used in the past if I remember right.




When I use it, the next message is shown:

[Window Title]
Workflow Exception

[Main Instruction]
Main has thrown an exception

Source: Get attribute ‘SELECT jsfwmp9072:impo…’

Message: CollectionConverter cannot convert from System.String[].

Exception Type: NotSupportedException

[Expanded Information]
System.NotSupportedException: CollectionConverter cannot convert from System.String[].
at System.Activities.Statements.Throw.Execute(CodeActivityContext context)
at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.ActivityInstance.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)

What could I do?



I’m not really sure.
Here were some example solutions to get the items from a combobox:

Your error leads me to believe that your variable is of the wrong type, since it says “cannot convert from”. However, I’m not sure. If you provide some screenshots of how you are using the activities and variables it might help. It also depends on the website, like sometimes you can’t use the Get Attribute in this way.