How to use selector to select if it CONTAINS/STARTS WITH certain word



I would like to use Click activity and select the radio button.

<input name="country" id="country" type="radio" value="Albania; AAA">
<input name="country" id="country" type="radio" value="Yemen; AAA">

How to click the radio button where value CONTAINS/STARTS WITH “Albania”? The string “Albania” is stored in a variable.

Tried using this but I know this is not correct.
<webctrl id='country' tag='INPUT' value='&quot;+country_variable+&quot;' />

Please advise.



Try to remove &quote attribute which is added implicitly. To avoid that don’t open selector editor just copy the entire selector in double quote and pass in property.
It should look like this.
"<webctrl id='country' tag='INPUT' value="'+country_variable+'" />"


Thanks for your response.

It produces an error “SelectorNotFoundException”

Guess this is because what I’m finding is NOT an exact match(=), but STARTS WITH a given string in variable.

Does UI Path has a way to search for CONTAINS or STARTS WITH?


do you have url where you tried to click on radio button.


Apologies but the URL I’m accessing is internal.

For example here:

<input type="radio" name="gender" value="male" checked> Male<br>
<input type="radio" name="gender" value="female"> Female<br>
<input type="radio" name="gender" value="other"> Other<br><br>

I would like to select radio button that STARTS WITH “fem” which is the second item.


Another one if I would like to search for STARTS WITH “FEM” (stored in variable) and would like to convert the input value above to UPPERASE so it will be case-insensitive.

To simplify, would like to search for STARTS WITH irregardless of its casing.


Check this i have done the same thing . Some one asked similar thing but i don’t think of any approach to start (fem) word and search in selector. May be some one will help on this.


Thanks for your response.

I think I can’t rely on idx since in my case, the list with radio buttons came from search result. Results will vary over time, idx=1 might represent one record, the next day, idx=1 can become another record which is different from the previous day.

Would appreciate if it would be possible to search STARTS WITH string.



If you want to use variable in selector, I think you have to use one more variable.

We cannot combine variable with other texts inside the selector field, so first we need to create new variable and assign what we want to set as selector to it.
Then set the new variable to selector.

create new variable “strSelector” then put this to selector box. Note that it contains asterisk, so that it can find something start with country_variable.

strSelector =""

(I’m using a bit old version so it can be different in newer version, though)

It’s not correct that we cannot combine texts inside selector field, based on andrzej.kniola’s post. Sorry for the wrong info. But I’m sure the selector above must work anyway :slight_smile:


@aksh1yadav pal any thoughts on this.


Selector is correct, but the part about combining texts in selector field is incorrect - you 100% can do it directly in that field. As long as the result is an XML string, you can do it however you wish.

Unfortunately the comparison is case sensitive. You can work around it by finding a common parent and filtering it’s children:
BecauseWhyNot.xaml (7.4 KB)

Key part is this:
UiElement button = radioButtons.Where(Function(x As UiElement) x.Get("value").ToString.StartsWith(startsWith, StringComparison.CurrentCultureIgnoreCase)).FirstOrDefault


:slight_smile: :thumbsup:


Perfect! This is what I’m looking for.

Thanks andrzej.kniola


Did you try @a-taniya response?