Interpolated selectors like in C#

studio
i_research

#1

For very specific/difficult automation some parts of the selector is known at run-time so the selector looks like
"<wnd title='" + someVariable + "'/>"
which is hard to get right and it is not correctly parsed by our tools (selector editor etc)
It would be nice if we can have something like:
"<wnd title='{someVariable}'/>"

In C# it is called interpolated strings; see: https://msdn.microsoft.com/en-us/library/dn961160.aspx


Dynamically generated Selectors
Dynamically generated Selectors
#2

Great idea - we do this all the time.

Also UiExplorer will not validate the selector but if it prompted you for the variable name you could enter it to prove that he selector is valid. :slight_smile:


#3

The same syntax should also be available in VB.NET since version 14:

Perhaps the selector editor fields could be made to accept variable names and generate such a string? It would definitely be a neat improvement to be able to use variables transparently with the validator and especially the highlighter function in UiExplorer.


#4

What do you say @adrian?


#5

I didn’t find this in the forum:

The selectors are currently a XML strings, but they cannot be dynamically generated. The ability to use wildcards is not enough for me. I think it would be very useful to be able to create selectors using variables eg:
Auto generated Selector:
“(webctrl aaname=‘Insert 1 file’ idx=‘1’ parentid=‘app’ tag=‘SPAN’ /)”

With wildcard:
“(webctrl aaname=‘Insert * file’ idx=‘1’ parentid=‘app’ tag=‘SPAN’ /)”

I would like:
“(webctrl aaname=‘Insert “+fileCount.ToString+” file’ idx=‘1’ parentid=‘app’ tag=‘SPAN’ /)”

Please note quotes and replace brackets with more than and less than as required.

P.


#6

Yes, you can use variables instead of wildcards.


#7

I just tried - is there a limit in community edition?
Or alternatively - what am I doing wrong?


#8

There is also this idea in order to simplify the use of variables in selectors:


#9

How do I ignore the error and still run the process?


#10

Hi badita,

Will this be supported in 2018.2? It’ll really be helpful if it works.

<wnd title='{someVariable}'/>

Thanks,
Tim


#11

now it works… but with differente format
"<wnd tile='"+someVariable+"'/>"