How do Ranorex access the elements of the array in Java?

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
pramilas
Posts: 2
Joined: Tue Jan 20, 2015 7:41 am

How do Ranorex access the elements of the array in Java?

Post by pramilas » Fri Apr 24, 2015 12:38 pm

Hi,

The application under test have a table in the application and its row contains value by default.
Based on various parameters, the column contains different values. In one of the cell value , it returns an array of objects.
When I try to retrieve "Text" property of these cells I always get "[Lcom.ambientcorp.nms.common.type.ID;@65031a" values.
The cell value is an array of class instances and this returns a value indicating that an array is returned [Lcom.ambientcorp.nms.common.type.ID;@65031a

When a Java array comes back how do Ranorex access the elements of the array?

Regards,
Pramila

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

Re: How do Ranorex access the elements of the array in Java?

Post by odklizec » Fri Apr 24, 2015 1:07 pm

Hi,

Could you please post a Ranorex snapshot (or send it to [email protected]) of the table/element in question?

Also, what exactly do you want to do with the obtained "array"? Validate just one (or more) of its values?

It should be possible to obtain specific elements of that "array" by using GetValue action combined with carefully constructed regular expression. Check this user guide paragraph...
http://www.ranorex.com/support/user-gui ... html#c4090

Another possibility might be to use a custom code to parse the array and do whatever you want with the individual array elements.
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

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: How do Ranorex access the elements of the array in Java?

Post by krstcs » Fri Apr 24, 2015 2:10 pm

My primary SUT is a Java POS application. I have similar issues.

The problem isn't that an array is returned. The problem is that a STRING REPRESENTATION of the ARRAY POINTER is returned. This is typical with a Java table in Swing. If you developers don't set up the cell renderer the right way, Ranorex won't be able to see the actual value. Note: When I say "right way" here I don't mean that the devs did anything wrong with the way they did it, just that Java renders table cells strangely if the developer doesn't change it.

You will probably need to have your developers change the table to include the needed information if you want to get the actual values from inside the array.
Shortcuts usually aren't...

pramilas
Posts: 2
Joined: Tue Jan 20, 2015 7:41 am

Re: How do Ranorex access the elements of the array in Java?

Post by pramilas » Fri Apr 24, 2015 2:49 pm

please find the Ranorex snapshot of the table/element in question.
Thanks for the response.
Attachments
TableOutput.rar
(3.62 MiB) Downloaded 100 times

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: How do Ranorex access the elements of the array in Java?

Post by krstcs » Fri Apr 24, 2015 3:04 pm

Yeah, after looking at the snapshot, it's as I said, Ranorex is reading the array pointer instead of the array items. Your developers implemented the renderer to display the array as a comma separated list, which means Ranorex can't see the actual string text because it only sees the cell and not the renderer. You will need to have the developers change the cell to include the string in an attribute or something similar.
Shortcuts usually aren't...