How define Selector variable

Hi, I am struggling to define the selector variable for this webpage to perform inputs.
web1b

I have searched through the forum, taking note that I should modify the expression, but no luck so far.

Any help and advice would be much appreciated.

1 Like

hi,

you can pass the selector to variable and give the variable name in this editior. it will take automatically…
image

in above image i have selector now i defined in variable and passed as below.

1 Like

Hi @COOLBOT,

There are two ways to modify(Adding variables or wildcards) the selector.

  • As @venkat4u mentioned, the selector can be stored in a variable

  • Another way is you can provide the selector as string(enclosed in double quotes) in the Selector field.
    E.g. “<webctrl aaname=‘Part ID Title Loan ID *’ parentid=‘loanpart-table’ tag=‘TABLE’ /><webctrl isleaf=‘1’ tableCol=‘5’ tableRow=’” + iRowStr.ToString + “’ tag=‘TD’ />”

If you need to change the attributes, click on Open in UI Explorer. Modify the attributes and click on Save.

Thanks,
Saranya K R

Thank you guys for the inputs. However, I am still stuck. I understand that I have to “incorporate” the variable into this string:

Hello @COOLBOT You can Edit the selector in as a string instead of opening the selector builder if you want to add a variable to to a selector.

Please note that doing this makes UIPath recognize the value as a string instead of a selector, so you won’t be able to edit it as a selector after adding a variable.

Before:

"<html title='staticvalue'/>"

After:

"<html title='" + dynamicValue + "'/>"
2 Likes

@COOLBOT can you share the selector for which you need to replace dynamic value with a variable.

Hi Ranjith,

Hope I understood you correctly.

The selector string is as below. When I varies
“[0]” in the above string, the selection changes as what I desired.

web1c

1 Like

@COOLBOT

Assuming your variable name as String_value
String_Value = “1”

Create new string variable for selector and in assign activity use the below.

string_selector = "<webctrl id = 'poDetailItemDatas["+String_Value+"].unitPrice' tag = 'INPUT'>"

If your value is not string then use (toString) to convert into string.

string_selector = "<webctrl id = 'poDetailItemDatas["+int_value.tostring+"].unitPrice' tag = 'INPUT'>"

Refer this xaml. sample.xaml (7.1 KB)

2 Likes

Hi Ranjith,

Thank you very much. That’s exactly what I need and it works like a charm. Cheers!!

1 Like

Hi everyone,

You can now define your variables for selectors directly in Studio.

Please check our official documentation here:

As well as this short tutorial on our Forum:

I took the liberty to change the solution flag to this post to let our users know about this feature :slight_smile:
Old solution post is this one.

1 Like