Localized

Best practices, code snippets for common functionality, examples, and guidelines.
ggaspari
Posts: 26
Joined: Tue Apr 10, 2012 8:40 am

Localized

Post by ggaspari » Mon Aug 27, 2012 2:22 pm

Hi guys,

I'd like to know the best way to make my tests working also on localized controls/objects/etc

In two words, for example I have a button like "/button[@text='&Close']" but my product has also a german version , so the button will be "/button[@text='&schließen']"

Any idea?

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Localized

Post by Support Team » Mon Aug 27, 2012 3:14 pm

Hi,

If you want to create tests for different languages there are three ways how you can do it:
1: You can use the data driven approach. For each language specific name in the repo you have to
create a variable which have to be bound to a specific column in your data connector.
In your case you need a data source with the language specific names for the variables.
For instance: instead of /button[@text='&Close'] you can use /button[@text='$close'].
Where $close is your specific variable. You can set this variable with inputs from, for instance, an excel sheet.
2: You have to edit your repository items in the following way:
/button[@text='&Close' or @text='&schließen'].
3: You have to edit the RxPath in a way that you use other unique identifiers which don't change if the
Language/OS changes, which are language independent. With the Spy tool you can easily check if there are such attributes.
For more information about the RxPath and the Spy tool please take a look at the following links:
RanoreXPath
Lesson 9: Ranorex Spy
Lesson 3: Data-Driven Testing
I hope this will help you solve the problem!

Regards,
Markus
Ranorex Support Team

User avatar
artur_gadomski
Posts: 207
Joined: Mon Jul 19, 2010 6:55 am
Location: Copenhagen, Denmark
Contact:

Re: Localized

Post by artur_gadomski » Tue Aug 28, 2012 6:25 am

If possible I suggest option 3. It requires least maintenance and should work on all languages. Controlname and UIautomationId should be good identifiers.

ggaspari
Posts: 26
Joined: Tue Apr 10, 2012 8:40 am

Re: Localized

Post by ggaspari » Tue Aug 28, 2012 9:42 am

Hi guys,
Yeah , problem solved!
Thanx for your help !

cveith
Posts: 7
Joined: Mon Oct 31, 2011 10:08 am

Re: Localized

Post by cveith » Tue Dec 18, 2012 1:53 am

Another way to consider is, putting your localized strings in Resource Files.

You can switch between the languages with CultureInfo.CurrentUICulture then. Perfect for label validations.

Don't forget to add a "using System.Globalization;" to your header ;)

regards

Christian

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Localized

Post by Support Team » Tue Dec 18, 2012 2:30 pm

Thanks for this suggestion!

Regards,
Markus

pramoodd
Posts: 13
Joined: Tue Mar 26, 2013 8:45 am

Re: Localized

Post by pramoodd » Tue Apr 02, 2013 11:50 am

@admin
While using the ranorex tool for localizing a Windows app,
the container of a item changes from languages to language.
for example, consider a text box .
the RX path in English is :
/form[@title~'^Select\ Facility\ Connectio']/container[@caption~'^1\.\ Enter\ login\ informatio']/text[@class='Edit' and @instance='0']

but the Rx path in German is :

/form[@title~'^Anlagen-Verbindung\ auswah']/container[@caption~'^1\.\ Login-Informationen\ ei']/text[@class='Edit' and @instance='0']

so the path match fails giving a error.(While executing the testcase).

any solution to solve this localization
Regards,
Praneeth Arnepalli

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Localized

Post by Support Team » Wed Apr 03, 2013 3:19 pm

Hello,

You could use variables for your localization in the RxPath of your elements.
These variables could be bound to a data source where each row represents a language.

Example for RxPath:

Code: Select all

/form[@title=$varTitle]/container[@caption=$varCaption]/text[@class='Edit' and @instance='0']
Please take a look at our User Guide for more info.

Regards,
Markus (T)

User avatar
iskrenpp
Posts: 11
Joined: Fri Aug 17, 2012 4:36 am

Re: Localized

Post by iskrenpp » Thu Oct 17, 2013 4:44 am

About localization - it is a very good practice to also check if localized text goes out of button text field size and gets cut-off. The way this is done is to find the pairs of attributes that are available for your case but the main idea is to find for example 'textHeight' and 'textWidth' and then only 'height' and 'width' of element of type Text - then via user code compare the 2 pairs between common type attributes - width with textWidth and height with textHeight. If any of textHeight or textWidth is bigger value than corresponding height and width then this means that text is cut off and incompletely displayed.

madhuri1221
Posts: 1
Joined: Fri Jan 29, 2016 2:34 pm

Re: Localized

Post by madhuri1221 » Fri Jan 29, 2016 2:37 pm

Hi.
Can you please give a brief overview so as to how this can be implemented in Ranorex. I cant seem to find any way.