[UiPath] Selectors with Regex and Fuzzy matching (with example)

Having solid, reliable, bullet-proof selectors is a must for RPA automation. Selectors give the robot a clear idea of which element to work with. Where to type, where to read, where to click.

Unfortunately, structures of many applications, especially web apps, are not always build to be well understood by robots. In fact, many web apps include some way how to dynamically change the IDs and name attributes of the elements, so to prevent the use of bots. Somewhere in between are pages that are just not that bot-friendly.

To handle dynamic selectors, that may change in some way, we can use wildcards such as * or ? to replace part of the selector, that is prone to change.

To give us stronger tools to retrieve the correct element, UiPath offers two more ways how to tackle dynamically changing selectors.

Example workflow :tophat:

To test Fuzzy and Regex matching, I created a test scenario for you here:
FuzzyAndRegexSelectorsTester.zip (43.6 KB)
This example contains 3 HTML files with test fields. Names of the fields change and every time a form is submitted, the next file is opened - this goes in a loop.

Fuzzy matching :fog:

You probably noticed, that when UiPath can’t find a selector, it gives you back a list of other selectors that are close to the one you were looking for:
This comes along with the Fuzzy selectors feature. UiPath’s fuzzy selectors works with Levenshtein distance - Wikipedia algorithm to count similarity of selectors based on chosen tag.
In the example below, we set fuzzy matching at tag name.

matching:name='fuzzy'  fuzzylevel:name='0.8'


The fuzzylevel should be in range 0.1 – 1.0. This number is not strictly connected to the percentages of closest matches in the error (when UiPath cannot find a selector). Right now, there is no easy way how to determine score needed for a certain match, however, you can try changing the value and click “Validate” to understand the treshold.

You can try to adjust the fuzzylevel in our example provided.

Regex matching :mag:

We can use the power of regular expressions to our advantage. Just include this magical formula:


Where name is the tag we want to lookup with regex. In our example it is the second field. The example shows how to tackle three versions of selector where only on part changes. The example is based on common situation, where field names, ids or labels vary depending on language setup. So we are looking for three language variations of the tag name.


You can test your regex matching selectors in a same way as the fuzzy ones.
We recommend this website for regular expression build.

That’s it! :sunglasses:

So now you know, how to use Fuzzy and Regex matching! If you have any questions or tips, feel free to reply and post a comment. Happy automation! :robot:


Th1s 1s gr€at! :smile:


1 Like