How to use partial text or contains operator in edit selector

selector
uiautomation
studio

#1

Scenario
My UIpath selector is shown below
capture

Title is using = as comparator

I wan to use something like contains
say title contains "ServiceNow"
or say regular expression like title=’*ServiceNow’
How to make this wotk in UIPath
Quick response is apprreciated


#2

Hello,

I don’t believe it’s possible to find a selector using a Contains operator.
However, you can use the wildcard "*"
So basically, it will find any selector where any text appears in the wildcard.

Using your selector, it would look like:

title=’*ServiceNow’

The “*” will tell it to find any selector where there is text infront of the word ServiceNow

To take this a step further, you can also use variables inside the selector if you want this to be more dynamic. In order to do this you simply click inside the Selector box in the Properties pane on the right (not clicking Edit). Then, edit the selector expression as a string. Once edited, you can click the Edit button and it will bring up the Expression Editor to make it easier.
For example,
"< html app=‘chrome.exe title=’*"+variable+"’ / >"

But, for what you are needing, you can probably just stick with the wildcard “*”

Regards.

C

EDIT: Additionally, I’ll just add that technically if you want to see if a selector contains text, you can use Find Element then using the element variable retrieve the selector as a string and use str.Contains() in an If condition. That might be useful to know, however, I don’t use it for finding selectors cause variables and wildcards seem to accomplish everything I have seen in business processes.


#3

Hi Thanks for your quikc help
I am able to use wildcards
But I am struggling with using variables
I get text from a textbox and assign to variable
and then use this variable inside another ui element expression
It appears like variable is getting assigned correctly and showing desired value I can confirm by using message box and variable value shows that but in Edit Expression dialog it does not seem to work
I tried attaching my xaml file for script …realized that not able to upload xaml file)
I am using community edition let me know if it supports using variable n edit selector
see error below
Capture
I can get value of variable aed correctly in message box …


#4

Hi @Prasanna_Hegde
It doesn’t look like you placed the variable in the selector correctly.

If you click in the Selector textbox in the Properties pane it will show the selector as a string:
image

You wan the string to look something like this:
"<html app=‘chrome.exe’ title=’*ServiceNow’ /><webctrl aaname=’"+aed+"'tag=‘A’ />"

If you click the Edit button after you have changed something in the string it will show the Expression editor:
image

If you click Edit and it shows the Selector Editor then you are in the wrong place
image
THE ABOVE IS THE WRONG PLACE.

Ok, hope this helps you better. Remember that you want to edit the string form of the selector with quotes around it. Then you can just concatenate your variables to create your selector as a string.

Regards.

C


#5

Hi
NEED TO CREATE EMPTY UIELEMENT BY DRAGGING IT FROM ACTIVITIES PANE
IF YOU TRY TO EDIT ALREADY CAPTURED ELEMENT IT WONT WORK

Clearly explained in post “How to use a variable in: <webctrl aaname=VARIABLE />

The advice I got from the group on using variables in the Expression Editor was excellent, but like you I struggled to get the Expression Editor instead of the Selector Editor. As you found out, variables don’t work in the Selector Editor. Instead of using record or data scraping to define the object you want to manipulate with the Expression Editor you have to manually drag the object from the list on the left. Then when you go into its properties the Selector will bring up the Expression Editor instead of the Selector Editor. What I now do is use “record” to stage my process, then delete the object on which I want to use the Expression Editor and then manually added it back. And like magic, I am the able to manipulate it with the Expression Editor when I click on the Selector.

I hope this helps. If not let me know and I’ll try to re-explain what I do to get the Expression Editor.

Hibb