Our application is available in German and English, other languages may follow. Given I have an XPath like /form/button[@text="Login"], is there a convenient way to have it translated?

At the moment I'm trying with SAP GUI like this:


I wonder whether there's a concept like .NET Resources where you can have a Resources.resx file and a Resources.de.resx file.

Of course I could use /form/button[@text="{0}"] and then use a string.Format() call, but that's absolutely inconvenient because the "Highlight element" feature gets broken.

I have tried:

  • looking at the properties of the .rxrep file, but it does not have a property that is related to my issue.
  • introducing a variable, which basically works. The XPath is then /form/button[@text=$Variable] but I could not find a way of translating the variables.
  • Can you please share your screenshot of your elements Html code. Which you want to translate? Sep 7, 2016 at 7:05
  • @ShailendraRathore: added a Screenshot. It's not HTML, it's SAP Sep 7, 2016 at 7:09
  • Although this is a very valid question I think if you want it answered quickly I would also ask it at the Ranorex forums: ranorex.com/forum/automation-tools-f16.html or ask Ranorex support which should be included in your license. Sep 7, 2016 at 12:03
  • @NielsvanReijmersdal: Thanks for the link to the forum. I don't have a license yet. I'm still in the evaluation phase. Sep 7, 2016 at 13:03
  • 1
    Even more reason for support to assist you, possible leads should always have high priority, maybe they can suggest a solution another direction in the hope you will license the software. Sep 7, 2016 at 13:06

2 Answers 2


Sure there is you can use XPath with logical OR and have all translations inside the XPath expression.

For example, you can use

/form/button[@text="Login" or @text="Eingeben" or  @text="შესვლის"]

3rd is Georgian :c). Risk of choosing different functionality due to translation is very low.

Update: using the contains(A,B) can move it to a higher level. Usually contains is used as


but can be used oppositely

/form/button[contains("Login | Eingeben | შესვლის",@text)]

where you are free to choose the delimiter. It would work even with comas, simple spaces, or whatever you like

"Login , Eingeben , შესვლის"
"Login # Eingeben # შესვლის"

and then it could be just copypasted from CSV or generated to a text array.

#end of update

But I recommend glueing your tests to other parameters than texts if available. This will be then translation independent. The application under development can change texts rapidly.

If the design of the application is already fixed, you can use simple numbers, as


is a 3rd button in the form. This is not possible to use when the application is still under development.


As far as I could get in SAP GUI, it has a rigid system of the element labelling, so id of the element should be in each element. Therefore, you can stick to the element labels/ids. example: /form/button[@id="elementID"].

  • Doing it with OR has the disadvantage that I cannot find out which texts I already have translated and which I don't. I have to go through all XPaths and check. If it were in a different file like RESX, it's immediately clear which ones are missing. Sep 8, 2016 at 8:51
  • Another disadvantage of the OR approach is that you cannot enforce the condition that the very same language is matched in each label's translation. Might become an issue with languages that are similar. Nov 18, 2016 at 9:57
  • @OR, true, but in reality I'm giving parameters like translation to data sources, usually XML or JSON and testing is then datadriven.
    – Dee
    Nov 18, 2016 at 12:53

Using text values to identify elements is not good practice for this very reason. (And because the text may be changed later in the development life cycle of your product)

The best way to solve this is to get your developers to assign a unique identifier to the control. The exact property to set will depend on platform/UI library. On Windows you might use the AutomationId or tag property, on Android it would be rId.

Assuming a change was made to your unit under test to add a proper identifier, your new XPath might look something like:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.