Use variables as wildcards

making my way through the tutorials

I’m upto “UI automation descriptors in Studio (v2024.10)” sub section “fine-tuning descriptor”.
The 2nd example shows how to use a variable to dynamically select a target. The example file doesn’t work.
When building the example from scratch, I’m unable to add an anchor, I’m told current mode doesn’t allow anchors. Screenshot won’t work when indicating targets.

If I force the target to fuzzy so I can add an anchor, then go to the xml and replace the employee name with a variable, I get red lines everywhere and
“The configured Project Settings targeting methods are not sufficient for the current target to be correctly identified. Please add other methods in Project Settings > UI Automation Modern > Targeting methods - web browsers”
So I figure I’m doing something wrong, as something like this would be mentioned in a tutorial.
Can anyone help?

@Nick_Scott

Not only in anchor variable can be used in any type of selector…you just need to right click and select the variabel to be inserted or give ‘{{variable}}’ it would add the variable in selector

Now when you add variable make sure you write a default value else it would not get validated

Cheers

Hi @Nick_Scott,

If you use a Strict selector for the target, it won’t allow you to set an anchor directly. You also need to enable the Fuzzy selector for the target first; then you can configure the anchor. Once done, you can uncheck the Fuzzy selector for target.

However, if your application is stable and selectors are reliable, you can avoid using an anchor.

Thanks

@Nick_Scott Go to
Project Settings → UI Automation Modern → Targeting methods (Web)

  1. Enable these:

    • Strict selector

    • Fuzzy selector

    • Image / CV (optional)

  2. Click Save

Now fix your workflow:

  1. Don’t edit XML manually
  2. Indicate the element again normally
  3. Open Selector / Descriptor editor
  4. Replace only dynamic value (like employee name) with a variable
    :backhand_index_pointing_right: Example:
    aaname='John'aaname='{{employeeName}}'

Please let me know if it works

thanks for your response, but my settings page does not have those options to enable.
Version 2026.0.191 STS
Please see screenshot.
The closest seems to be “Selector - default find type” which drop down has 4 options, disabled, one match, all matches and auto. Currently set to Auto, I will try this later when I’m at my machine.

thank-you so much for your response and taking the time to link the example - which works great.
Unfortunately this doesn’t apply to my situation, as I have to apply the variable to an anchor which is the part I’m having trouble with.
However it was useful to see how to use variable in targets, thanks again.

Here is my project. I didn’t want to include my email/password, so you will have to login to the acme website using your own login, then run the project and you should find that it brings up the wrong employee details.
If you check the “click employee details” activity (the last activity) you should see the employee name, carl C Carney, in the descriptor image, is replaced by the EmployeeName variable. The value of the variable is logged to output, but is not the employee detail shown after the click activity.
I assume I’ve missed something, so any help appreciated.

wildcards3-employee.zip (6.2 KB)

@Nick_Scott

Glad it helped

Even in anchor you would use it the same way..there is no difference as such

if youa re having trouble can you elaborate or show some screenshots

cheers

I included the project in a previous reply, here it is:

wildcards3-employee.zip (6.2 KB)

@Nick_Scott Yeah, the UI has changed a bit in newer versions, so those exact options aren’t visible anymore. What you’re seeing is correct.

Try switching “Selector – default find type” from Auto → All Matches — that usually helps with these targeting issues.

Also, don’t edit the XML directly. That’s likely why you’re getting red errors. Instead:

Re-indicate the element
Open the descriptor editor
Replace just the dynamic value (like the employee name) with a variable there

For anchors, in modern experience it’s better to use “Use Anchor” activity rather than trying to force it through selector mode.

In short, your settings look fine — it’s more about how the selector + anchor is being configured.

thanks again for your response, will have another go

No it still doesn’t work alas. I switch the selector-default find type, and it allows me to reindicate and set the anchor, then assign the variable all goes without a hitch.
But it still ignore the variable value when displaying the employee. I log the employee name so I’m fairly sure the value is correct.

I was unable to find a use anchor activity, tried all combinations of use and anchor.

Finally!
Managed to make it work. The tutorial is well out of date, I had to fill in the Text field (2) in the image below, not aaname (1) as described in the tutorial.
Nightmare.
Thanks for your (prompt) help guys.