Case Study: how to pass string variable to find UI element

Hey guys, that is one of my first questions on forum so I want to say hello to everyone and thank you for sharing knowledge! :slight_smile:

I am a RPA JR Dev and recently bumped into an issue:

Say you are filling out a form with labels and text fields. In Basic/Desktop recording in order to Type Into a text box, you put an anchor on the label and Type Into the Indicated Element text box. In Image Recording you can choose Scrape Relative in order to indicate the position of the text box relatively to the anchor. But, in all those cases, anchors are chosen based on UiElement/picture.

But what happens if we want to pass on the anchor not based on the field selected by mouse cursor but a string variable? For example: you have a list of voucher IDs and a dropdown menu to select “Done/Not Done” next to them. Your anchor/label would be a particular Voucher ID and your Indicated Element would be the dropdown list. But the label changes depending on a given invoice, so you want to pass it on as string variable, which robots decipher and searches in the whole visible UI for a string that matches the string variable.

I know that you can use “Click Text” to write a given string, but it does not seem to work with variables, only fixed string values.

Maybe a trivial thing but couldn’t find it online. Anyone can suggest a solution?

Best regards

Hi Karol,

You are able to insert string variables into the selector to template out the parts of the selector that are dynamic. So for example if your selector is "<webctrl innertext='*Reply*' tag='BUTTON' />", which is the selector for the Reply button on this page, but you have a variable to select either reply or cancel then the selector for that could be "<webctrl innertext='" + buttonText +"' tag='BUTTON' />" where buttonText is a string that is either "*Reply*" or "*cancel*"

1 Like