Localized application

Ask general questions here.
Goransi
Posts: 5
Joined: Tue Mar 19, 2013 8:57 pm

Localized application

Post by Goransi » Sun Apr 28, 2013 10:45 am

I'm trying to write a common test module for a localized application.

1. The first issue I'm having is the fact that MenuItems do not support controlname attributes. Currently my menu items are located via text or accessiblename attribute. Is there a way to support controlname attribute?
2. I've tried to make text and accessiblename attribute point to a variable and then bind the variable to some external dictionary. As I understand the external data sources are treated as rows which contain various data items for a single variable. I don't see a way to use external data sources that treat first column as variable name and second column as variable value. Is there a way to achieve such functionality?
3. I've thought about a way to extend RanorexXPath to accept functions. Then I could write something like ...menuitem[text=localizationService.Translate("#ADMINISTRATION") and have Ranorex find the menu item based on the result of localizationService.Translate function. Is there a way to do this?
4. Finally I've somewhat managed to get the result I need by using global variables and module variables. What I did was create a module that uses localizationService to fill module variables with correct data. Next I bind the module variables to global parameters and use the data in subsequent test. This is quite error prone and difficult to implement for large number of variables. Is there a way to access and set global variables directly from code (without the need to use binding)?

If any of the 4. points is possible please let me know.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3908
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Localized application

Post by odklizec » Sun Apr 28, 2013 4:47 pm

Hi,

I would suggest you to take a snapshot of your application/menu and upload it here so we can review it to better understand your app. Here you can find how to take a snapshot file...
http://www.ranorex.com/support/user-gui ... files.html

Basically, if the "controlname" is visible in spy, there is no reason why it could not be used for the object identification. Do you see the "controlname" in spy? If not, then it's most probably not implemented in your menu. If you see it in spy, then the other reason why it has not been used for the object identification could be that it's not unique enough.

By default, rx recorder/spy picks the most unique attributes where some attributes have higher weight over others. If you you want to change the attribute weight, see this post...
http://www.ranorex.com/forum/default-pr ... -t907.html
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

Goransi
Posts: 5
Joined: Tue Mar 19, 2013 8:57 pm

Re: Localized application

Post by Goransi » Sun Apr 28, 2013 6:23 pm

Thank you for taking the time to research this. The snapshot of the menuitem is in the attachment (MenuItem).
I don't see the control name in either the spy or recorder.

(Removed, turns out the second repo also uses accessiblename). Does this mean there's something wrong with my repository for the first project? What would be the best way to clean and refill the repository?

Goran
Attachments
MenuItem2.rxsnp
(140.02 KiB) Downloaded 165 times
MenuItem.rxsnp
(135.83 KiB) Downloaded 157 times

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3908
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Localized application

Post by odklizec » Sun Apr 28, 2013 11:39 pm

Hi Goran,

I don't think there is something wrong with your repo. How I see it, after examining both snapshots, there is just no controlname attribute implemented in your menuitems. And as it looks, there is no language independent identifier that would help you with your problem, maybe except the ChildIndex attribute (available in Detail > General section), but I found no way how to change the weight of ChildIndex attribute.

The easiest, but in my opinion least maintainable option, would be to edit the repository items like this:
menuitem[@accessiblename='Administracija' or @accessiblename='Administration']

Another option, suggested by Ranorex folks, is using the data-driven approach, which I believe you already tried? But I somehow don't see how useful this approach could be for the localized apps? I mean the individual data (rows) are read in iterations. So if I'm not overlooking something important, only one iteration will return the green result (the one with actually used language), while the other iterations (those with not actually used language strings) will always fail? In addition, reiterating a set of test scenario steps with each language defined in external file (despite the language is not actually used) could be a waste of time and source of confusion for those reviewing the test reports.

BTW, I don't think the step 3 from your list is currently possible. So let's wait for another suggestion from Ranorex folks. I too would like to learn the best approach for localized apps. And while the data-driven approach sounds promising, I must be missing a crucial point ;)
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

Goransi
Posts: 5
Joined: Tue Mar 19, 2013 8:57 pm

Re: Localized application

Post by Goransi » Mon Apr 29, 2013 8:48 am

Thank you again for your help!

I'm still confused as to what I could do to implement controlename attribute. What we use is a common WinForms MenuItem which has .Name property specified. Is there anything on the application side I can do to enable Ranorex to locate MenuItems by controlname?

My next step is to try and use Tag attribute and see if Ranorex can pick up on that.

It would be possible to use data driven approach but in this case I'd have to pivot my table and use Columns as MnuItem Ids and a single wide row for all the MenuItems texts.

Hopefully I'll get to the bottom of this :)

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3908
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Localized application

Post by odklizec » Mon Apr 29, 2013 9:10 am

I think that only controls can have the controlname attribute. So the question is, if the menu items in your app are controls? Unfortunately, I'm a .net/C# noob, so I can't help with this. But I'm sure Ranorex folks will come with some suggestions.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Localized application

Post by Support Team » Tue Apr 30, 2013 2:23 pm

Hello,

In general only the whole menu is a control in WinForms. The elements within that control (MenuItems) can only be recognized via MSAA.
The problem is that the "Name" attribute of the MenuItems is not accessible.
As workaround I would suggest to use the attribute "AccessibleDescription" in your application in order to automate the menu. This attribute can also be used for language independent names.

Regards,
Bernhard
.
Image

Goransi
Posts: 5
Joined: Tue Mar 19, 2013 8:57 pm

Re: Localized application

Post by Goransi » Wed May 01, 2013 8:37 am

Thank you for your help odklizec and Support Team! USing AccessibleDescription should solve my problem.