The same approach applies to different libraries, so we describe it here using Java as an example.

Using regex:

Suppose that we have an object jTextField1 that were recorded using a locator:


The location string in this case is:


Suppose that developers changed the name from jTextField1 to jTextFieldName and we need to tweak the locator to work with both versions of the app. Here we may use special regex: syntax to say that given part of location should be treated as a regular expression, i.e.:


It is possible that more than one section requires the tweaking, i.e. if root frame has also been renamed from frame0 to frame, we may have a locator looking like:



Using custom delimeter


By default the Java locator uses '/' to split parts of the locator.  If you need to use '/' in the regular expression, then escape it using '\', i.e.: \/.


The Managed locator uses '.' as a location parts separator. I.e.:


However, it may use different separator. The separator may be re-defined if used as a first symbol, i.e.:


- here the first '/' means use / as a separator. So for managed objects you may choose a separator that is not a part of your regular expression to make a safe locator.