Page 1 of 1

Multi Language Environment

Posted: Tue Aug 19, 2014 1:06 pm
by MiMa
Hi,

i am just starting with ranorex and came up with the following problem ..

We do GUI-Tests on Windows-Systems in German and English.

When I record tests all buttons / forms / menus are recorded in german as it is the current language on my dev-system. When I run these tests on an english lab-machine alle these tests fail, because it can't find, for example, the "schliessen"-button as it is the "Close"-button on this machine.

Is there a way to maintain repositories for this issue or do i have to record each test in all needed languages?

Can I use 2 repositories (german and english) and switch that during runtime?

Many thanks for your hints, ideas and Support :)

Michael

Re: Multi Language Environment

Posted: Tue Aug 19, 2014 1:21 pm
by MiMa
Just an example ...

in a test i have to open "Drucker hinzufügen" (add a Printer) in controlpanel printers dialog.

/form[@title='Geräte und Drucker']/element[@class='ShellTabWindowClass']//toolbar[@automationid='FolderBandModuleInner']/button[@automationid='{0EA51307-BE7E-4083-9987-26987A571759}']

the button is independent with automationid ... but the form has no language independent item to call :(

Re: Multi Language Environment

Posted: Tue Aug 19, 2014 1:37 pm
by krstcs
Do the elements in your application under test have any other attributes that could be used instead of the text? Maybe an ID attribute, or an AccessibleName, for instance? Something that won't change based on the language?

For example, if you have a button that changes the text, but has the id of 'closeButton', you could use that in your XPath: "/button[#'closeButton']". Then it wouldn't matter what the @text attribute was, Ranorex would still find the button. (I don't speak German, so... :D )

Barring that, the easiest way to handle it would be to variablize your RanoreXPath for the objects in question.

For example, you could create a variable called 'CloseButton_Localized' and pass the German or English text at run-time based on a dataset that contains the right one. Your path would then be: "/button[@text=$CloseButton_Localized]".


EDIT TO ADD:
Sorry, missed your second post, wasn't there when I first grabbed the page.

So, in your example, does the AutomationID change, or is that the unique id for that button? If it doesn't change, then you can just use it and then verify the correct language text is on the button at run-time.

Re: Multi Language Environment

Posted: Tue Aug 19, 2014 1:57 pm
by MiMa
Thanks for your fast reply :)

ok i understand the use of variables and as far as i understand they would do iterations through german and english, right?

what i want to do is during setup of testsuite to check Systems language and then set all needed localizations for this test.

is this possible?

regards michael

Re: Multi Language Environment

Posted: Tue Aug 19, 2014 2:24 pm
by krstcs
There are many ways you could do this, including Excel sheets or a database.

In code, you could, for example, pass in the word "German" or "English" as a GLOBAL PARAMETER (GP) when you start the test.

Then, you could have a data set of the two different words for each instance and it would return the correct word based on the GP passed in.

If you GP is called "LOCALIZATION" then you could have a method called GetLocalization that fetchs the correct word based on the GP and the index word (let's say you use German as the index). If you pass "German", then the method would return the word just passed to it, but if you pass "English" as the Localization, the method would pass the English word instead.

Code: Select all

private static Dictionary<string, string> LocalizationTable = new Dictionary<string, string>();

//in the init method (or main) add the words to the dictionary:
  LocalizationTable.Add("Ja", "Yes");  //and so on for all the words needed...

public static string GetLocalization(string localization, string germanWord)
{
  if (localization.Equals("English")
  {
    return LocalizationTable[germanWord];  //returns the English word and stops the method
  }

  return germanWord; //Returns the German word, if localization is not English
}
You would then need to use this everywhere that you wanted to localize.

I'm sure there are other ways to do it. I don't have to deal with this type of thing, so mine may not be the best way. :D


You could also look into using a database and having a stored procedure that sets the localization of the dataset in the DB at startup, based on the same GP above.