Can we pass a variable as a selector?

I need to fetch data from a web page, I am using Get Ancestor activity for it. I need to call it several times in a process, so I need to pass a selector dynamically which is fine however I am looking to make it generic, so it can be utilized later on.

Is it somehow possible to pass a selector like this or any workaround?
image

I know how to pass the variable, however, I am looking to pass the whole

@loginerror @Palaniyappan

1 Like

Hello @mrkrunaldoshi,

image

You can also pass like this,

Cheers

You can also pass like this,

Cheers
@

I agree and I have done it in my code as well however I want to make this generic and need to pass the whole “webctrl” thing as a variable. Is it possible in 1st case?

1 Like

you can use get attribute to fetch all the details and pass it

HI,
You can create a string variable and assign the complete selector value to the variable without any new line.
Pass the assigned variable directly without any braces or quotations.

Hope it helps. Please try and let me know

1 Like

From what I can understand, this method might help:

First you need to assign a string value for the whole selector; for example, using the above selector code you shared:

strWebSelector = String.Format("<html app='chrome.exe' title='{0}' url='{1}' /> '{2}'",strBrowserTitle.ToString,strBrowserURL.ToString,strAncestorSelector.ToString)

The result will be a string, but this will allow you to have the individual components as generic values; which will then be converted as strings within the code.

Once all ready, assign strWebSelector into your activity’s selector area.

1 Like

Both the solutions provided by @Venugopal24 and @Thom_Co are working. However, I’ll prefer to go with @Venugopal24 solution in my project.

Thank you both!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.