How to pass a variable in a locator of ui Path

uiautomation

#1

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.


#2

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


#3

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.

#4

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


#5

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


#6

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.


#7

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


#8

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