How to pass a variable in a locator of ui Path

Hi Team

I have this locator

html title=‘* ~ Salesforce - Unlimited Edition’ />
<webctrl aaname=‘Sooria Narayanan45’ parentid=‘Contact_body’ tag=‘A’ /

It works fine as an individual but I need aaname to be replaced with a variable

I tried

html title=‘* ~ Salesforce - Unlimited Edition’ />
webctrl aaname=‘“+Variable.ToString+”’ parentid=‘Contact_body’ tag=‘A’ />

but its not working.

Can someone please help me on this.

Hi,
Don’t open selector editor just pass in minimized property like this:
"<html title=’* ~ Salesforce - Unlimited Edition’ /> webctrl aaname=’"+Variable.ToString+"’ parentid=‘Contact_body’ tag=‘A’ />"
In double quote and single line

Try this:

  1. Store the selector string in a variable with value of dynamic attribute as any dummy default text.
    Example:

string selector = “< html title=’* ~ Salesforce - Unlimited Edition’ /> < webctrl aaname=‘#name#’ parentid=‘Contact_body’ tag=‘A’ />”

  1. Replace dynamic value with actual variable.

selector = selector.Replace(“#name#”,PersonName)

  1. Pass this selector variable to the activity’s selector textbox.

Amazing Thanks Mr.ddpadil. I tried for 8 hours with all combination but it did’t work.

But this is now working. Thanks a lot. However when making this selector in editable mode it was throwing an error.

Cna you please explain

Sorry Palindrome , not able to understand how to use this techinique.

Can you please explain step by step so that other people can take advantage of this techinique

What I mean is that you can use Assign activity to store selector string in a string Variable then you can replace the attribute aaname value (which is some random word set by you) with actual values. This can be done using assign activity:

selector = selector.Replace(“#name#”,Variable)

Now if Variable is have new name that is required as aaname’s value.

OLD string:
string selector = “< html title=’* ~ Salesforce - Unlimited Edition’ /> < webctrl aaname=‘#name#’ parentid=‘Contact_body’ tag=‘A’ />”

After Replace:
string selector = “< html title=’* ~ Salesforce - Unlimited Edition’ /> < webctrl aaname=‘John Deo’ parentid=‘Contact_body’ tag=‘A’ />”

You can directly put variable name in minimized property of selector.

Yep its known minor issue.Will be fixed in coming days :slight_smile:

Thanks ddpadil :slight_smile: you have been a great help always.